jquery / jquery/esprima

Unexpected token ILLEGAL on /^

Open
#2,030 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
7.1k
Forks
773
PR merge metrics
No merged PRs in 30d

Description

Unexpected token ILLEGAL on /^

I try parse following js

isImage=function(e){return/^image\//.test(e.type)
and get ParserExeption Line 1: Unexpected token ILLEGAL This code works in chrome without any errors.

Code to parse

var s = new Scanner(@"isImage=function(e){return/^image\//.test(e.type)}");
var tokens = new List();
Token token;
do
{
	s.ScanComments();
	token = s.Lex();
	tokens.Add(token);
} while (token.Type != TokenType.EOF);

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

Reproduce the report with the JavaScript string passed to Scanner and inspect the Scanner/Lex flow that produces the Unexpected token ILLEGAL error. The issue is resolved when the regular-expression literal /^image// is tokenized without an error, matching Chrome's behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
compilers
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.