cx
cx copied to clipboard
Compiler Error Improvement for indexing non-indexable types
To Reproduce
package main
func main()() {
var b bool = true
var bb bool = b[0]
panic(true, false, "must not compile")
}
Expected behavior No panic.
Screenshots
error: pending_13.cx:5 invalid indexing
panic: runtime error: index out of range
goroutine 1 [running, locked to thread]:
github.com/skycoin/cx/cxgo/actions.PreFinalSize(0xc000198740, 0xc0001fcb40, 0xc0001fc6c0)
/home/cxfx/go/src/github.com/skycoin/cx/cxgo/actions/functions.go:1161 +0x1ea
github.com/skycoin/cx/cxgo/actions.SetFinalSize(0xc0001988d8, 0xc0001fcb40)
/home/cxfx/go/src/github.com/skycoin/cx/cxgo/actions/functions.go:1131 +0xa6
github.com/skycoin/cx/cxgo/actions.ProcessExpressionArguments(0xc0001988d8, 0xc0001988b0, 0xc000198898, 0xc000082680, 0xc000266068, 0x1, 0x1, 0xc0000930e0, 0x1)
/home/cxfx/go/src/github.com/skycoin/cx/cxgo/actions/functions.go:397 +0x1de
github.com/skycoin/cx/cxgo/actions.FunctionDeclaration(0xc000082680, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xc000064040, 0x5, 0x8)
/home/cxfx/go/src/github.com/skycoin/cx/cxgo/actions/functions.go:142 +0x377
github.com/skycoin/cx/cxgo/parser.yyParse(0xfd3fe0, 0xc000094000, 0x0)
/home/cxfx/go/src/github.com/skycoin/cx/cxgo/parser/cxgo.go:1743 +0x1b31
github.com/skycoin/cx/cxgo/parser.Parse(...)
/home/cxfx/go/src/github.com/skycoin/cx/cxgo/parser/cxgo.go:18
main.main()
/home/cxfx/go/src/github.com/skycoin/cx/cxgo/main.go:826 +0xf33
Behavior should throw compiler error at compile time, "variable is not indexable type" or error stating that type cannot be indexed.
Should be compile time error, not run time error.