goby-lang / goby

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

panic: runtime error: index out of range [recovered] for require 'file' #360

Closed darknessforcetw closed 7 years ago

darknessforcetw commented 7 years ago

goby -i

» require 'file'
panic: runtime error: index out of range

goroutine 1 [running]:
github.com/goby-lang/goby/compiler/bytecode.(*Generator).compileStatements(0xc420171308, 0xf79e20, 0x0, 0x0, 0xc4201bc900, 0xc42018b3a0)
    /home/nilo/go/src/github.com/goby-lang/goby/compiler/bytecode/statement_generation.go:22 +0x227
github.com/goby-lang/goby/compiler/bytecode.(*Generator).GenerateInstructions(0xc420171308, 0xf79e20, 0x0, 0x0, 0xc4201bc8d0, 0x618ab2, 0xc42018b2e0)
    /home/nilo/go/src/github.com/goby-lang/goby/compiler/bytecode/generator.go:54 +0x5b
github.com/goby-lang/goby/compiler.CompileToInstructions(0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xc420030c00, 0xab5040)
    /home/nilo/go/src/github.com/goby-lang/goby/compiler/compiler.go:34 +0x20f
github.com/goby-lang/goby/vm.(*VM).execRequiredFile(0xc420142000, 0xc4201bc630, 0x28, 0x0, 0x0, 0x0)
    /home/nilo/go/src/github.com/goby-lang/goby/vm/vm.go:328 +0x87
github.com/goby-lang/goby/vm.(*VM).execGobyLib(0xc420142000, 0xb0981f, 0x7)
    /home/nilo/go/src/github.com/goby-lang/goby/vm/vm.go:324 +0x12b
github.com/goby-lang/goby/vm.initFileClass(0xc420142000)
    /home/nilo/go/src/github.com/goby-lang/goby/vm/file.go:23 +0x17a
github.com/goby-lang/goby/vm.builtinCommonInstanceMethods.func6.1(0xc420144030, 0xc4201476b0, 0x1, 0x1, 0x0, 0xc4201476b0, 0x0)
    /home/nilo/go/src/github.com/goby-lang/goby/vm/class.go:483 +0xbb
github.com/goby-lang/goby/vm.(*thread).evalBuiltInMethod(0xc420144030, 0xf3aaa0, 0xc420147030, 0xc4201364e0, 0x0, 0x1, 0x0)
    /home/nilo/go/src/github.com/goby-lang/goby/vm/thread.go:123 +0x216
github.com/goby-lang/goby/vm.glob..func22(0xc420144030, 0xc420194bd0, 0xc42018afc0, 0x2, 0x2)
    /home/nilo/go/src/github.com/goby-lang/goby/vm/instruction.go:430 +0x376
github.com/goby-lang/goby/vm.(*thread).execInstruction(0xc420144030, 0xc420194bd0, 0xc4201bc3f0)
    /home/nilo/go/src/github.com/goby-lang/goby/vm/thread.go:67 +0x67
github.com/goby-lang/goby/vm.(*thread).evalCallFrame(0xc420144030, 0xc420194bd0)
    /home/nilo/go/src/github.com/goby-lang/goby/vm/thread.go:45 +0x54
github.com/goby-lang/goby/vm.(*thread).startFromTopFrame(0xc420144030)
    /home/nilo/go/src/github.com/goby-lang/goby/vm/thread.go:39 +0x55
github.com/goby-lang/goby/vm.(*VM).startFromTopFrame(0xc420142000)
    /home/nilo/go/src/github.com/goby-lang/goby/vm/vm.go:219 +0x2f
github.com/goby-lang/goby/vm.(*VM).REPLExec(0xc420142000, 0xc42015a090, 0x1, 0x1)
    /home/nilo/go/src/github.com/goby-lang/goby/vm/repl.go:43 +0x64e
github.com/goby-lang/goby/igb.StartIgb(0xb08694, 0x5)
    /home/nilo/go/src/github.com/goby-lang/goby/igb/repl.go:208 +0x10bb
main.main()
    /home/nilo/go/src/github.com/goby-lang/goby/goby.go:28 +0x743

require 'json' is true

I try to run the test.sh

src/github.com/goby-lang/goby  master  ./test.sh 
?       github.com/goby-lang/goby   [no test files]
?       github.com/goby-lang/goby/compiler  [no test files]
?       github.com/goby-lang/goby/compiler/ast  [no test files]
ok      github.com/goby-lang/goby/compiler/bytecode 1.030s  coverage: 92.2% of statements
ok      github.com/goby-lang/goby/compiler/lexer    1.011s  coverage: 96.2% of statements
ok      github.com/goby-lang/goby/compiler/parser   1.027s  coverage: 71.9% of statements
ok      github.com/goby-lang/goby/compiler/token    1.007s  coverage: 100.0% of statements
?       github.com/goby-lang/goby/igb   [no test files]
?       github.com/goby-lang/goby/test_fixtures/import_test/plugin  [no test files]
?       github.com/goby-lang/goby/test_fixtures/import_test/plugin/lib  [no test files]
?       github.com/goby-lang/goby/test_fixtures/import_test/struct  [no test files]
--- FAIL: TestRequireSuccess (0.00s)
panic: runtime error: index out of range [recovered]
    panic: runtime error: index out of range

goroutine 61 [running]:
testing.tRunner.func1(0xc420899380)
    /usr/local/go/src/testing/testing.go:622 +0x29d
panic(0xae1de0, 0xfa9b50)
    /usr/local/go/src/runtime/panic.go:489 +0x2cf
github.com/goby-lang/goby/compiler/bytecode.(*Generator).compileStatements(0xc420a17778, 0x10081e0, 0x0, 0x0, 0xc4204f4c00, 0xc4204f64c0)
    /home/nilo/go/src/github.com/goby-lang/goby/compiler/bytecode/statement_generation.go:22 +0x227
github.com/goby-lang/goby/compiler/bytecode.(*Generator).GenerateInstructions(0xc420a17778, 0x10081e0, 0x0, 0x0, 0xc4204f4bd0, 0x636cc2, 0xc4204f6400)
    /home/nilo/go/src/github.com/goby-lang/goby/compiler/bytecode/generator.go:54 +0x5b
github.com/goby-lang/goby/compiler.CompileToInstructions(0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x20, 0x7fc14f9d1e10)
    /home/nilo/go/src/github.com/goby-lang/goby/compiler/compiler.go:34 +0x20f
github.com/goby-lang/goby/vm.(*VM).execRequiredFile(0xc4200b62d0, 0xc4204f4930, 0x28, 0x0, 0x0, 0x0)
    github.com/goby-lang/goby/vm/_test/_obj_test/vm.go:371 +0x97
github.com/goby-lang/goby/vm.(*VM).execGobyLib(0xc4200b62d0, 0xb61636, 0x7)
    github.com/goby-lang/goby/vm/_test/_obj_test/vm.go:366 +0x14b
github.com/goby-lang/goby/vm.initFileClass(0xc4200b62d0)
    github.com/goby-lang/goby/vm/_test/_obj_test/file.go:26 +0x10c
github.com/goby-lang/goby/vm.builtinCommonInstanceMethods.func6.1(0xc4206a2240, 0xc4208be5e0, 0x1, 0x1, 0x0, 0xc4208be5e0, 0x0)
    github.com/goby-lang/goby/vm/_test/_obj_test/class.go:487 +0xdb
github.com/goby-lang/goby/vm.(*thread).evalBuiltInMethod(0xc4206a2240, 0xfc0220, 0xc4208a3fd0, 0xc4208a15e0, 0x0, 0x1, 0x0)
    github.com/goby-lang/goby/vm/_test/_obj_test/thread.go:149 +0x24a
github.com/goby-lang/goby/vm.glob..func22(0xc4206a2240, 0xc4204f27e0, 0xc4204f60a0, 0x2, 0x2)
    github.com/goby-lang/goby/vm/_test/_obj_test/instruction.go:518 +0x38a
github.com/goby-lang/goby/vm.(*thread).execInstruction(0xc4206a2240, 0xc4204f27e0, 0xc4204f4510)
    github.com/goby-lang/goby/vm/_test/_obj_test/thread.go:81 +0x77
github.com/goby-lang/goby/vm.(*thread).evalCallFrame(0xc4206a2240, 0xc4204f27e0)
    github.com/goby-lang/goby/vm/_test/_obj_test/thread.go:53 +0x86
github.com/goby-lang/goby/vm.(*thread).startFromTopFrame(0xc4206a2240)
    github.com/goby-lang/goby/vm/_test/_obj_test/thread.go:45 +0x56
github.com/goby-lang/goby/vm.(*VM).startFromTopFrame(0xc4200b62d0)
    github.com/goby-lang/goby/vm/_test/_obj_test/vm.go:235 +0x3f
github.com/goby-lang/goby/vm.(*VM).ExecInstructions(0xc4200b62d0, 0xc420356a88, 0x1, 0x1, 0xda1823, 0x3c)
    github.com/goby-lang/goby/vm/_test/_obj_test/vm.go:148 +0x3ba
github.com/goby-lang/goby/vm.(*VM).testEval(0xc4200b62d0, 0xc420899380, 0xb7a028, 0x2b, 0xda1823, 0x3c, 0x683253, 0x599f99b8)
    /home/nilo/go/src/github.com/goby-lang/goby/vm/vm_test.go:170 +0xc7
github.com/goby-lang/goby/vm.TestRequireSuccess(0xc420899380)
    /home/nilo/go/src/github.com/goby-lang/goby/vm/class_test.go:500 +0x74
testing.tRunner(0xc420899380, 0xb8c288)
    /usr/local/go/src/testing/testing.go:657 +0x96
created by testing.(*T).Run
    /usr/local/go/src/testing/testing.go:697 +0x2ca
FAIL    github.com/goby-lang/goby/vm    0.114s
st0012 commented 7 years ago

@darknessforcetw Can you tell me 1) How did you install Goby, from source right? 2) Did you set $GOBY_ROOY?

st0012 commented 7 years ago

@darknessforcetw BTW if you run the same command on latest master you shouldn't see those scary stack traces. It should tell you that you didn't set $GOBY_ROOT properly.

darknessforcetw commented 7 years ago

yap! From source the goby version is 0.1.1 I set GOBY_ROOT=$GOPATH/src/github.com/goby-lang/goby and apt-get remove Goby I It's work @_@ Thank you for much

st0012 commented 7 years ago

@darknessforcetw Feel free to ask if you meet any problems 😄