goby-lang / goby

Goby - Yet another programming language written in Go
MIT License
3.49k stars 171 forks source link

Missing `=` causes panic #327

Closed hachi8833 closed 6 years ago

hachi8833 commented 7 years ago
a [1,2,3,4,5]

Happened to find that the invalid Goby code above causes the following panic on REPL.

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x28 pc=0x40e9405]

goroutine 1 [running]:
github.com/goby-lang/goby/compiler/ast.(*BaseNode).MarkAsExp(0x0)
    /Users/hachi8833/deve/golang/gopath/sys/src/github.com/goby-lang/goby/compiler/ast/ast.go:31 +0x5
github.com/goby-lang/goby/compiler/parser.(*Parser).parseStatement(0xc420132a20, 0x47447e8, 0x1)
    /Users/hachi8833/deve/golang/gopath/sys/src/github.com/goby-lang/goby/compiler/parser/statement_parsing.go:34 +0xe1
github.com/goby-lang/goby/compiler/parser.(*Parser).ParseProgram(0xc420132a20, 0xd, 0xc420162600)
    /Users/hachi8833/deve/golang/gopath/sys/src/github.com/goby-lang/goby/compiler/parser/parser.go:173 +0xef
github.com/goby-lang/goby/igb.StartIgb(0x44e1057, 0x5)
    /Users/hachi8833/deve/golang/gopath/sys/src/github.com/goby-lang/goby/igb/repl.go:138 +0x89b
main.main()
    /Users/hachi8833/deve/golang/gopath/sys/src/github.com/goby-lang/goby/goby.go:28 +0x660
Alexius-Huang commented 7 years ago

I think this should be the case that there exists a method called a which sends in a value [1, 2, 3, 4, 5] as the parameter of the method something like that.

hachi8833 commented 6 years ago

Now the issue has been fixed on the current master branch (9742df3). Closing.

» a [1,2,3,4,5]
#» UndefinedMethodError: Undefined Method 'a' for <Instance of: Object>