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

Leading ; causes a panic #560

Closed
hachi8833 opened this issue Jan 2, 2018 · 2 comments · Fixed by #567
Closed

Leading ; causes a panic #560

hachi8833 opened this issue Jan 2, 2018 · 2 comments · Fixed by #567
Assignees
Labels

Comments

@hachi8833
Copy link
Member

When the line is started with ;, the following panic is occurred.

» ;
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x30 pc=0x40f99fa]

goroutine 1 [running]:
github.com/goby-lang/goby/compiler/bytecode.(*Generator).compileExpression(0xc4201aefc0, 0xc4201da000, 0x0, 0x0, 0xc4201af050, 0xc4201b0640)
	/Users/hachi8833/deve/golang/gopath/sys/src/github.com/goby-lang/goby/compiler/bytecode/expression_generation.go:9 +0x3a
github.com/goby-lang/goby/compiler/bytecode.(*Generator).compileStatement(0xc4201aefc0, 0xc4201da000, 0x4820240, 0xc42000c080, 0xc4201af050, 0xc4201b0640)
	/Users/hachi8833/deve/golang/gopath/sys/src/github.com/goby-lang/goby/compiler/bytecode/statement_generation.go:40 +0x334
github.com/goby-lang/goby/compiler/bytecode.(*Generator).compileStatements(0xc4201aefc0, 0xc420052050, 0x1, 0x1, 0xc4201af050, 0xc4201b0640)
	/Users/hachi8833/deve/golang/gopath/sys/src/github.com/goby-lang/goby/compiler/bytecode/statement_generation.go:22 +0xd0
github.com/goby-lang/goby/compiler/bytecode.(*Generator).GenerateInstructions(0xc4201aefc0, 0xc420052050, 0x1, 0x1, 0x1, 0xc42001c110, 0xd)
	/Users/hachi8833/deve/golang/gopath/sys/src/github.com/goby-lang/goby/compiler/bytecode/generator.go:54 +0x5b
github.com/goby-lang/goby/igb.StartIgb(0x457257f, 0x5)
	/Users/hachi8833/deve/golang/gopath/sys/src/github.com/goby-lang/goby/igb/repl.go:229 +0xcf4
main.main()
	/Users/hachi8833/deve/golang/gopath/sys/src/github.com/goby-lang/goby/goby.go:29 +0x954
@hachi8833 hachi8833 added the bug label Jan 2, 2018
@hachi8833
Copy link
Member Author

hachi8833 commented Jan 2, 2018

I found a similar issue. The continuous semicolon ; also causes a panic when 3 or more:

» a=1; -a
#» 0    # invalid: should be -1
» a=1;; -a
#» -1   # works and valid
» a=1;;; -a
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x30 pc=0x40f99fa]

goroutine 1 [running]:
github.com/goby-lang/goby/compiler/bytecode.(*Generator).compileExpression(0xc4201a1500, 0xc420214000, 0x0, 0x0, 0xc4201a1590, 0xc4201a46c0)
	/Users/hachi8833/deve/golang/gopath/sys/src/github.com/goby-lang/goby/compiler/bytecode/expression_generation.go:9 +0x3a
github.com/goby-lang/goby/compiler/bytecode.(*Generator).compileInfixExpression(0xc4201a1500, 0xc420214000, 0xc4201aa300, 0xc4201a1590, 0xc4201a46c0)
	/Users/hachi8833/deve/golang/gopath/sys/src/github.com/goby-lang/goby/compiler/bytecode/expression_generation.go:265 +0xce
github.com/goby-lang/goby/compiler/bytecode.(*Generator).compileExpression(0xc4201a1500, 0xc420214000, 0x4820420, 0xc4201aa300, 0xc4201a1590, 0xc4201a46c0)
	/Users/hachi8833/deve/golang/gopath/sys/src/github.com/goby-lang/goby/compiler/bytecode/expression_generation.go:47 +0xc3a
github.com/goby-lang/goby/compiler/bytecode.(*Generator).compileStatement(0xc4201a1500, 0xc420214000, 0x4820240, 0xc4201ae0c0, 0xc4201a1590, 0xc4201a46c0)
	/Users/hachi8833/deve/golang/gopath/sys/src/github.com/goby-lang/goby/compiler/bytecode/statement_generation.go:40 +0x334
github.com/goby-lang/goby/compiler/bytecode.(*Generator).compileStatements(0xc4201a1500, 0xc4201ae100, 0x2, 0x2, 0xc4201a1590, 0xc4201a46c0)
	/Users/hachi8833/deve/golang/gopath/sys/src/github.com/goby-lang/goby/compiler/bytecode/statement_generation.go:22 +0xd0
github.com/goby-lang/goby/compiler/bytecode.(*Generator).GenerateInstructions(0xc4201a1500, 0xc4201ae100, 0x2, 0x2, 0x9, 0xc4201c41c0, 0x15)
	/Users/hachi8833/deve/golang/gopath/sys/src/github.com/goby-lang/goby/compiler/bytecode/generator.go:54 +0x5b
github.com/goby-lang/goby/igb.StartIgb(0x457257f, 0x5)
	/Users/hachi8833/deve/golang/gopath/sys/src/github.com/goby-lang/goby/igb/repl.go:229 +0xcf4
main.main()
	/Users/hachi8833/deve/golang/gopath/sys/src/github.com/goby-lang/goby/goby.go:29 +0x954

See #568.

@st0012
Copy link
Member

st0012 commented Jan 7, 2018

@hachi8833 The a=1; -a returns wrong value case is actually another issue. Can you help me open a new one?

@ghost ghost assigned st0012 Jan 7, 2018
@ghost ghost added the in progress label Jan 7, 2018
@st0012 st0012 mentioned this issue Jan 7, 2018
@ghost ghost removed the in progress label Jan 7, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants