Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ng/parser: support type-elided slice constructions #209

Open
sbinet opened this issue Jan 16, 2018 · 0 comments
Open

ng/parser: support type-elided slice constructions #209

sbinet opened this issue Jan 16, 2018 · 0 comments

Comments

@sbinet
Copy link
Collaborator

sbinet commented Jan 16, 2018

the following fails in ng:

ng> type T struct { Name string }
ng> ts := []T{{Name:"name"}}
neugram: parser: panic: TODO parseStmt } (off 54)
goroutine 20 [running]:
runtime/debug.Stack(0x32, 0x0, 0x0)
	/home/binet/sdk/go/src/runtime/debug/stack.go:24 +0xa7
runtime/debug.PrintStack()
	/home/binet/sdk/go/src/runtime/debug/stack.go:16 +0x22
neugram.io/ng/parser.(*Parser).work.func1(0xc42013a070)
	/home/binet/work/gonum/src/neugram.io/ng/parser/parser.go:145 +0x116
panic(0xaf4b00, 0xc42001e720)
	/home/binet/sdk/go/src/runtime/panic.go:502 +0x229
neugram.io/ng/parser.(*Parser).parseStmt(0xc42013a070, 0xc42001e6e0, 0x1)
	/home/binet/work/gonum/src/neugram.io/ng/parser/parser.go:1233 +0x1836
neugram.io/ng/parser.(*Parser).work(0xc42013a070)
	/home/binet/work/gonum/src/neugram.io/ng/parser/parser.go:188 +0x1f4
created by neugram.io/ng/parser.New
	/home/binet/work/gonum/src/neugram.io/ng/parser/parser.go:30 +0x114
ng eval panic: expr TODO: &expr.Bad{
	Position: src.Pos{
		Filename: "/home/binet/work/gonum/src/neugram.io/ng/ng-interactive",
		Line: int32(2),
		Column: int16(11),
	},
	Error: parser.Error{
		Pos: src.Pos{
			Filename: "/home/binet/work/gonum/src/neugram.io/ng/ng-interactive",
			Line: int32(2),
			Column: int16(12),
		},
		Offset: int(45),
		Msg: "expected operand, got ident",
	},
}
goroutine 1 [running]:
runtime/debug.Stack(0x186, 0x0, 0x0)
	/home/binet/sdk/go/src/runtime/debug/stack.go:24 +0xa7
runtime/debug.PrintStack()
	/home/binet/sdk/go/src/runtime/debug/stack.go:16 +0x22
neugram.io/ng/eval.(*Program).Eval.func1(0xc42012c180, 0xc420137630, 0xc420137618)
	/home/binet/work/gonum/src/neugram.io/ng/eval/eval.go:476 +0x1ea
panic(0xaf4b00, 0xc42001e890)
	/home/binet/sdk/go/src/runtime/panic.go:502 +0x229
neugram.io/ng/typecheck.(*Checker).exprPartial(0xc42014e1b0, 0xc442c0, 0xc420099080, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0xc442c0, ...)
	/home/binet/work/gonum/src/neugram.io/ng/typecheck/typecheck.go:2679 +0x59aa
neugram.io/ng/typecheck.(*Checker).expr(0xc42014e1b0, 0xc442c0, 0xc420099080, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0)
	/home/binet/work/gonum/src/neugram.io/ng/typecheck/typecheck.go:1350 +0x79
neugram.io/ng/typecheck.(*Checker).checkSliceLiteral(0xc42014e1b0, 0xc44780, 0xc42009f860, 0x0, 0x0, 0x0, 0xc42001e6c0, 0x1, 0x1, 0xc42001e6a0, ...)
	/home/binet/work/gonum/src/neugram.io/ng/typecheck/typecheck.go:2811 +0x24a
neugram.io/ng/typecheck.(*Checker).exprPartial(0xc42014e1b0, 0xc44780, 0xc42009f860, 0x0, 0x3, 0xc40a00, 0xc42001e6a0, 0x0, 0x0, 0xc44780, ...)
	/home/binet/work/gonum/src/neugram.io/ng/typecheck/typecheck.go:2218 +0x4fa0
neugram.io/ng/typecheck.(*Checker).exprNoElide(0xc42014e1b0, 0xc44780, 0xc42009f860, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0)
	/home/binet/work/gonum/src/neugram.io/ng/typecheck/typecheck.go:1359 +0x79
neugram.io/ng/typecheck.(*Checker).stmt(0xc42014e1b0, 0xc448c0, 0xc42009f8b0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0)
	/home/binet/work/gonum/src/neugram.io/ng/typecheck/typecheck.go:166 +0x378
neugram.io/ng/typecheck.(*Checker).Add(0xc42014e1b0, 0xc448c0, 0xc42009f8b0, 0x0, 0x0)
	/home/binet/work/gonum/src/neugram.io/ng/typecheck/typecheck.go:3490 +0x94
neugram.io/ng/eval.(*Program).Eval(0xc42012c180, 0xc448c0, 0xc42009f8b0, 0xc4201680c0, 0x0, 0x0, 0x0, 0xc3fc00, 0xc42001e8a0)
	/home/binet/work/gonum/src/neugram.io/ng/eval/eval.go:481 +0xe2
main.handleResult(0x2, 0xc42000c4e0, 0x2, 0x2, 0x0, 0x0, 0x0, 0xc4200c4180, 0x4, 0x4)
	/home/binet/work/gonum/src/neugram.io/ng/ng.go:393 +0x72b
main.loop(0xc400000000)
	/home/binet/work/gonum/src/neugram.io/ng/ng.go:385 +0x5d2
main.main()
	/home/binet/work/gonum/src/neugram.io/ng/ng.go:147 +0x5be
ng: ng eval panic: expr TODO: &expr.Bad{
	Position: src.Pos{
		Filename: "/home/binet/work/gonum/src/neugram.io/ng/ng-interactive",
		Line: int32(2),
		Column: int16(11),
	},
	Error: parser.Error{
		Pos: src.Pos{
			Filename: "/home/binet/work/gonum/src/neugram.io/ng/ng-interactive",
			Line: int32(2),
			Column: int16(12),
		},
		Offset: int(45),
		Msg: "expected operand, got ident",
	},
}
name
neugram: parser: expected operand, got ident (off 45)
neugram: parser: expected "}", found "ident" (off 45)
neugram: parser: expected ";", found ":" (off 46)
neugram: parser: panic: TODO parseStmt } (off 54)

of course, this works, though:

ng> type T struct { Name string }
ng> ts := []T{T{Name:"name"}}
ng> ts
[]struct { Name string }{
	struct { Name string }{
		Name: "name",
	},
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant