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

"while(null) break;" panics #220

Closed
mstoykov opened this issue Oct 21, 2020 · 0 comments
Closed

"while(null) break;" panics #220

mstoykov opened this issue Oct 21, 2020 · 0 comments
Labels

Comments

@mstoykov
Copy link
Contributor

The following code panics:

while(null) {
  break;
}

the same goes if null is "".

panic: runtime error: index out of range [0] with length 0 [recovered]
        panic: runtime error: index out of range [0] with length 0

goroutine 6 [running]:
testing.tRunner.func1.1(0x828b60, 0xc000016b80)
        testing/testing.go:1003 +0x30d
testing.tRunner.func1(0xc0000ca360)
        testing/testing.go:1006 +0x3f9
panic(0x828b60, 0xc000016b80)
        runtime/panic.go:969 +0x166
github.com/dop251/goja.(*compiler).leaveBlock(0xc0000a0b00)
        github.com/dop251/goja/compiler.go:89 +0x1ee
github.com/dop251/goja.(*compiler).compileLabeledWhileStatement(0xc0000a0b00, 0xc000010de0, 0x7aab7e8e04f0c400, 0x0, 0x0)
        github.com/dop251/goja/compiler_stmt.go:426 +0x26e
github.com/dop251/goja.(*compiler).compileWhileStatement(0xc0000a0b00, 0xc000010de0, 0x203000)
        github.com/dop251/goja/compiler_stmt.go:376 +0x46
github.com/dop251/goja.(*compiler).compileStatement(0xc0000a0b00, 0x919920, 0xc000010de0, 0x919300)
        github.com/dop251/goja/compiler_stmt.go:36 +0x609
github.com/dop251/goja.(*compiler).compileStatements(0xc0000a0b00, 0xc0000ef680, 0x5, 0x8, 0x203001)
        github.com/dop251/goja/compiler_stmt.go:724 +0x105
github.com/dop251/goja.(*compiler).compile(0xc0000a0b00, 0xc0000a0ac0)
        github.com/dop251/goja/compiler.go:265 +0x1b0
@mstoykov mstoykov changed the title while(null) break; panics "while(null) break;" panics Oct 21, 2020
@dop251 dop251 added the bug label Oct 21, 2020
@dop251 dop251 closed this as completed in bf9dcfb Oct 21, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants