Optimize parseBindingAtom code to get better error messages (#9762)

This commit is contained in:
Daniel Tschinder 2019-03-25 14:23:39 -07:00 committed by GitHub
parent d720c6cfff
commit 444daf9224
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
20 changed files with 13 additions and 33 deletions

View File

@ -231,9 +231,6 @@ export default class LValParser extends NodeUtils {
// Parses lvalue (assignable) atom. // Parses lvalue (assignable) atom.
parseBindingAtom(): Pattern { parseBindingAtom(): Pattern {
switch (this.state.type) { switch (this.state.type) {
case tt.name:
return this.parseIdentifier();
case tt.bracketL: { case tt.bracketL: {
const node = this.startNode(); const node = this.startNode();
this.next(); this.next();
@ -243,10 +240,9 @@ export default class LValParser extends NodeUtils {
case tt.braceL: case tt.braceL:
return this.parseObj(true); return this.parseObj(true);
default:
throw this.unexpected();
} }
return this.parseIdentifier();
} }
parseBindingList( parseBindingList(

View File

@ -1,3 +1,3 @@
{ {
"throws": "Unexpected token (1:4)" "throws": "Unexpected keyword 'if' (1:4)"
} }

View File

@ -1,3 +1,3 @@
{ {
"throws": "Unexpected token (1:11)" "throws": "Unexpected keyword 'if' (1:11)"
} }

View File

@ -1,3 +1,3 @@
{ {
"throws": "Unexpected token (1:11)" "throws": "Unexpected keyword 'true' (1:11)"
} }

View File

@ -1,3 +1,3 @@
{ {
"throws": "Unexpected token (1:11)" "throws": "Unexpected keyword 'false' (1:11)"
} }

View File

@ -1,3 +1,3 @@
{ {
"throws": "Unexpected token (1:11)" "throws": "Unexpected keyword 'null' (1:11)"
} }

View File

@ -1,3 +1,3 @@
{ {
"throws": "Unexpected token (1:4)" "throws": "Unexpected keyword 'this' (1:4)"
} }

View File

@ -1,3 +1,3 @@
{ {
"throws": "Unexpected token (1:4)" "throws": "Unexpected keyword 'super' (1:4)"
} }

View File

@ -1,3 +1,3 @@
{ {
"throws": "Unexpected token (1:4)" "throws": "Unexpected keyword 'default' (1:4)"
} }

View File

@ -1,3 +1,3 @@
{ {
"throws": "Unexpected token (1:4)" "throws": "Unexpected keyword 'default' (1:4)"
} }

View File

@ -1,3 +1,3 @@
{ {
"throws": "Unexpected token (1:6)" "throws": "Unexpected keyword 'default' (1:6)"
} }

View File

@ -1,3 +1,3 @@
{ {
"throws": "Unexpected token (1:4)" "throws": "Unexpected keyword 'if' (1:4)"
} }

View File

@ -1 +0,0 @@
function t(if) { }

View File

@ -1,3 +0,0 @@
{
"throws": "Unexpected token (1:11)"
}

View File

@ -1 +0,0 @@
function t(true) { }

View File

@ -1,3 +0,0 @@
{
"throws": "Unexpected token (1:11)"
}

View File

@ -1 +0,0 @@
function t(false) { }

View File

@ -1,3 +0,0 @@
{
"throws": "Unexpected token (1:11)"
}

View File

@ -1 +0,0 @@
function t(null) { }

View File

@ -1,3 +0,0 @@
{
"throws": "Unexpected token (1:11)"
}