1
0
mirror of https://github.com/robertkrimen/otto synced 2025-10-05 19:19:10 +08:00

Merge pull request #139 from deoxxa/fix-bracket-parsing-with-new

fix parsing of statements like `new a["b"]`
This commit is contained in:
Conrad Pankoff 2015-12-03 08:43:55 +11:00
commit 89a9f14981
2 changed files with 12 additions and 1 deletions

View File

@ -1015,6 +1015,17 @@ func TestOttoCall_new(t *testing.T) {
})
}
func TestOttoCall_newWithBrackets(t *testing.T) {
tt(t, func() {
test, vm := test()
_, err := vm.Run(`var a = {default: function B(x) { this.x = x; } }`)
is(err, nil)
test(`(new a['default'](1)).x`, 1)
})
}
func TestOttoCall_throw(t *testing.T) {
// FIXME? (Been broken for a while)
// Looks like this has been broken for a while... what

View File

@ -417,7 +417,7 @@ func (self *_parser) parseLeftHandSideExpression() ast.Expression {
for {
if self.token == token.PERIOD {
left = self.parseDotMember(left)
} else if self.token == token.LEFT_BRACE {
} else if self.token == token.LEFT_BRACKET {
left = self.parseBracketMember(left)
} else {
break