Optimize parseBindingAtom code to get better error messages (#9762)
This commit is contained in:
parent
d720c6cfff
commit
444daf9224
@ -231,9 +231,6 @@ export default class LValParser extends NodeUtils {
|
||||
// Parses lvalue (assignable) atom.
|
||||
parseBindingAtom(): Pattern {
|
||||
switch (this.state.type) {
|
||||
case tt.name:
|
||||
return this.parseIdentifier();
|
||||
|
||||
case tt.bracketL: {
|
||||
const node = this.startNode();
|
||||
this.next();
|
||||
@ -243,10 +240,9 @@ export default class LValParser extends NodeUtils {
|
||||
|
||||
case tt.braceL:
|
||||
return this.parseObj(true);
|
||||
|
||||
default:
|
||||
throw this.unexpected();
|
||||
}
|
||||
|
||||
return this.parseIdentifier();
|
||||
}
|
||||
|
||||
parseBindingList(
|
||||
|
||||
@ -1,3 +1,3 @@
|
||||
{
|
||||
"throws": "Unexpected token (1:4)"
|
||||
"throws": "Unexpected keyword 'if' (1:4)"
|
||||
}
|
||||
|
||||
@ -1,3 +1,3 @@
|
||||
{
|
||||
"throws": "Unexpected token (1:11)"
|
||||
"throws": "Unexpected keyword 'if' (1:11)"
|
||||
}
|
||||
|
||||
@ -1,3 +1,3 @@
|
||||
{
|
||||
"throws": "Unexpected token (1:11)"
|
||||
"throws": "Unexpected keyword 'true' (1:11)"
|
||||
}
|
||||
|
||||
@ -1,3 +1,3 @@
|
||||
{
|
||||
"throws": "Unexpected token (1:11)"
|
||||
"throws": "Unexpected keyword 'false' (1:11)"
|
||||
}
|
||||
|
||||
@ -1,3 +1,3 @@
|
||||
{
|
||||
"throws": "Unexpected token (1:11)"
|
||||
"throws": "Unexpected keyword 'null' (1:11)"
|
||||
}
|
||||
|
||||
@ -1,3 +1,3 @@
|
||||
{
|
||||
"throws": "Unexpected token (1:4)"
|
||||
"throws": "Unexpected keyword 'this' (1:4)"
|
||||
}
|
||||
|
||||
@ -1,3 +1,3 @@
|
||||
{
|
||||
"throws": "Unexpected token (1:4)"
|
||||
"throws": "Unexpected keyword 'super' (1:4)"
|
||||
}
|
||||
|
||||
@ -1,3 +1,3 @@
|
||||
{
|
||||
"throws": "Unexpected token (1:4)"
|
||||
"throws": "Unexpected keyword 'default' (1:4)"
|
||||
}
|
||||
|
||||
@ -1,3 +1,3 @@
|
||||
{
|
||||
"throws": "Unexpected token (1:4)"
|
||||
"throws": "Unexpected keyword 'default' (1:4)"
|
||||
}
|
||||
|
||||
@ -1,3 +1,3 @@
|
||||
{
|
||||
"throws": "Unexpected token (1:6)"
|
||||
"throws": "Unexpected keyword 'default' (1:6)"
|
||||
}
|
||||
|
||||
@ -1,3 +1,3 @@
|
||||
{
|
||||
"throws": "Unexpected token (1:4)"
|
||||
"throws": "Unexpected keyword 'if' (1:4)"
|
||||
}
|
||||
|
||||
@ -1 +0,0 @@
|
||||
function t(if) { }
|
||||
@ -1,3 +0,0 @@
|
||||
{
|
||||
"throws": "Unexpected token (1:11)"
|
||||
}
|
||||
@ -1 +0,0 @@
|
||||
function t(true) { }
|
||||
@ -1,3 +0,0 @@
|
||||
{
|
||||
"throws": "Unexpected token (1:11)"
|
||||
}
|
||||
@ -1 +0,0 @@
|
||||
function t(false) { }
|
||||
@ -1,3 +0,0 @@
|
||||
{
|
||||
"throws": "Unexpected token (1:11)"
|
||||
}
|
||||
@ -1 +0,0 @@
|
||||
function t(null) { }
|
||||
@ -1,3 +0,0 @@
|
||||
{
|
||||
"throws": "Unexpected token (1:11)"
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user