Comments (8)
@RReverser's now-deleted remark on early errors is valid, I think: I was not aware of these. Maybe it would be nice to have a mode to disable them, though. Also, despite e.g. this being an early error, acorn doesn't seem to catch it... Am I missing something? Node:
> let a = 5;
undefined
> const a = 5;
Thrown:
SyntaxError: Identifier 'a' has already been declared
More curiosities:
> let (let);
Thrown:
ReferenceError: let is not defined
vs Acorn's The keyword 'let' is reserved (1:0)
.
I am currently trying to parse a dataset of JavaScript code, but its language semantics are making me very close to giving up :P.
from acorn.
It's an early error, which is different from syntax error but treated the same way.
from acorn.
The fact that if (false) f() = x
parses in browsers but not in the specification is a known deficiency of the specification which we haven't gotten around to fixing.
On the subject of early errors, I would not recommend treating early errors differently from other parse failures. The spec treats whether something is an early error or simply not matched by the grammar as a strictly editorial question. Users should not care about that distinction.
from acorn.
f(x) = y
is syntactically valid JS: An assignment expression is defined in terms of left hand side expressions which can be call expressions, so I'd say acorn is wrong here.
from acorn.
Shouldn't it still pass through? After all, isn't acorn merely a parser, not a static code analysis tool.
from acorn.
if(0)f()=0
executes without throwing any error in Node REPL
from acorn.
@appgurueu This is weird, because LHSExpression includes NewExpression, however...
> if(0)new f()=0
ReferenceError: Invalid left-hand side in assignment
[...]
> if(0)f()=0
undefined
from acorn.
Thanks for confirming. I'm going to close this as working as intended then.
from acorn.
Related Issues (20)
- some loc.start was undefined in acorn v8.11.2 HOT 1
- `import()` was parsed to Identifier HOT 1
- Token registration across plugins [WFC] HOT 2
- Unexpected parsing behavior after upgrading Acorn from v8.9.0 to v8.11.3 HOT 1
- Acorn fails with nullish coalescing HOT 5
- Incorrect line calculation after invalid escape sequence in tagged template HOT 3
- Strict mode detection logic
- SKG HOT 4
- How does it compare to the speed of vanilla JavaScript? HOT 1
- TypeScript complains when extending Parser HOT 1
- Justin Durand
- [acorn] Missing `value` property in `Token` (TypeScript) HOT 3
- Only fans.com
- Unsupported platform for [email protected] HOT 1
- Import Attributes
- Feature Request: ES2025 RegExp Duplicate named capturing groups HOT 6
- [acorn-walk] Type error when using VariableDeclarator with walk.simple HOT 1
- Property and AssignmentProperty have the same type HOT 1
- Peer dependency on acorn for acorn-walk types HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from acorn.