GithubHelp home page GithubHelp logo

Comments (8)

kspalaiologos avatar kspalaiologos commented on June 15, 2024 2

@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.

RReverser avatar RReverser commented on June 15, 2024 1

It's an early error, which is different from syntax error but treated the same way.

from acorn.

bakkot avatar bakkot commented on June 15, 2024 1

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.

appgurueu avatar appgurueu commented on June 15, 2024
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.

kspalaiologos avatar kspalaiologos commented on June 15, 2024

Shouldn't it still pass through? After all, isn't acorn merely a parser, not a static code analysis tool.

from acorn.

Kimapr avatar Kimapr commented on June 15, 2024
if(0)f()=0

executes without throwing any error in Node REPL

from acorn.

kspalaiologos avatar kspalaiologos commented on June 15, 2024

@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.

marijnh avatar marijnh commented on June 15, 2024

Thanks for confirming. I'm going to close this as working as intended then.

from acorn.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.