RunJS icon indicating copy to clipboard operation
RunJS copied to clipboard

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

Open DaveMcNamara opened this issue 2 years ago • 4 comments

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.

DaveMcNamara avatar Aug 09 '23 20:08 DaveMcNamara

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

lukehaas avatar Aug 10 '23 07:08 lukehaas

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?

oculus42 avatar Sep 11 '23 13:09 oculus42

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

lukehaas avatar Sep 11 '23 15:09 lukehaas

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

lukehaas avatar Sep 11 '23 15:09 lukehaas