lukehaas / RunJS

RunJS is a JavaScript playground for macOS, Windows and Linux. Write code with instant feedback and access to Node.js and browser APIs.
https://runjs.app
2.01k stars 43 forks source link

Inaccurate `SyntaxError: 'with' in strict mode` error #573

Open DaveMcNamara opened 11 months ago

DaveMcNamara commented 11 months ago

I noticed this while pushing around our old buddy, the deprecated "with" statement. This is with Babel transpilation enabled, which I believe always enforces strict mode.

Running this is fine, and evaluates to 'true': with (true) console.log(toString());

But if I create a syntax error within the "with" statement: with (true) console.log(toString(!));

I get SyntaxError: 'with' in strict mode— even though it was happily using "with" in strict mode before I added nonsense.

lukehaas commented 11 months ago

@dajxd, thanks for raising this. It does seem odd. It's possibly an upstream issue. I'll take a deeper look.

oculus42 commented 10 months ago

Both statements throw the "with" error when run in Babel REPL. Does RunJS attempt to execute without Babel first and fall back to Babel if it errors?

lukehaas commented 10 months ago

@oculus42 nope, if Babel is enabled then it will use Babel.

lukehaas commented 10 months ago

@oculus42 try setting the source type in the Babel Repl to Unambiguous