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:
commit
89a9f14981
11
otto_test.go
11
otto_test.go
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue
Block a user