tc39 / eshost

A uniform wrapper around a multitude of ECMAScript hosts. CLI: https://github.com/bterlson/eshost-cli
Other
142 stars 36 forks source link

eshost fails inscrutably when the file starts with a string literal #115

Open bakkot opened 3 years ago

bakkot commented 3 years ago

Create a file tmp.js containing 'a|b'.split('|').forEach(print), then run eshost tmp.js (assuming the existence of eshost-cli). On my machine, at least, this produces output along the lines of

#### Chakra

SyntaxError: Expected ';'

#### engine262

SyntaxError: Unexpected token

#### GraalJS

SyntaxError: f-1634278503297-82335-eko3b0.sec9l.js:1:5 Expected ; but found const

#### Hermes

SyntaxError: ';' expected

#### JavaScriptCore

SyntaxError: Unexpected keyword 'const'. Parse error.

#### SpiderMonkey

SyntaxError: unexpected token: keyword 'var':

#### V8

SyntaxError: Unexpected token 'var'

#### XS

SyntaxError: missing ;

Poking around some, it looks like the problem is that it's attempting to inject the header with a regex which matches '', i.e., it is trying to insert the header between the '' and the .split, which obviously isn't going to work.