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

Optimize parseBindingAtom code to get better error messages #9762

Merged
merged 1 commit into from Mar 25, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 2 additions & 6 deletions packages/babel-parser/src/parser/lval.js
Expand Up @@ -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();
Expand All @@ -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(
Expand Down
@@ -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)"
}

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.