tc39 / tc39/eshost

eshost fails inscrutably when the file starts with a string literal

Open
#115 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
147
Forks
45
Avg merge
1d 1h
Merged PRs (30d)
4

Description

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.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with lib/ConsoleAgent.js around lines 307-310, then reproduce the issue by creating tmp.js with the string-literal example and running eshost tmp.js. Inspect how the header injection handles the empty-string match. Done means the command no longer produces syntax errors across the listed hosts.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
cli
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.