Closed hachi8833 closed 6 years ago
def foo(tail) (5..tail).each do |t| if t % 2 == 0 && t % 5 == 0 puts "ouch!" break else puts t end end puts "out of the block" end
The code above works fine in normal run within a file, trailing foo 20 several times.
foo 20
When you first run foo 20 on REPL, it works, too. But if you run foo 20 again on REPL, you receive the following panic.
panic: runtime error: invalid memory address or nil pointer dereference [signal SIGSEGV: segmentation violation code=0x1 addr=0x60 pc=0x43cdad5] goroutine 1 [running]: github.com/goby-lang/goby/vm.(*VM).REPLExec(0xc420180000, 0xc420240fc0, 0x6, 0x8) /Users/hachi8833/deve/golang/gopath/sys/src/github.com/goby-lang/goby/vm/repl.go:38 +0x435 github.com/goby-lang/goby/igb.StartIgb(0x4560268, 0x7) /Users/hachi8833/deve/golang/gopath/sys/src/github.com/goby-lang/goby/igb/repl.go:225 +0xbff main.main() /Users/hachi8833/deve/golang/gopath/sys/src/github.com/goby-lang/goby/goby.go:29 +0x8fc
Note that this is the same on REPL even when you wrap foo in a class:
foo
class Foo def foo(tail) (5..tail).each do |t| if t % 2 == 0 && t % 5 == 0 puts "ouch!" break else puts t end end puts "out of the block" end end Foo.new.foo 20
@hachi8833 doesn't this relate/be identical with #584?
You're right. I should be closing this...
The code above works fine in normal run within a file, trailing
foo 20
several times.When you first run
foo 20
on REPL, it works, too. But if you runfoo 20
again on REPL, you receive the following panic.Note that this is the same on REPL even when you wrap
foo
in a class: