jquery / jquery/esprima

Non-octal decimal integer literal is still mistakenly allowed in strict mode

Open
#1,731 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

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

Description

Test case:

esprima.parse('"use strict"; 08')

Actual: A syntax tree.

Expected. A thrown exception indicating that the source is not valid.


In the ES2015 specification, §B.1.1 Numeric Literals, it is mentioned:

The syntax and semantics of 11.8.3 is extended as follows except that this extension is not allowed for strict mode code:

The relevant productions are:

DecimalIntegerLiteral ::
    NonOctalDecimalIntegerLiteral

NonOctalDecimalIntegerLiteral ::
    0 NonOctalDigit

NonOctalDigit :: one of
    8 9

This restriction is now implemented in V8, see https://bugs.chromium.org/p/v8/issues/detail?id=4973.

According to V8 error messages, the exception message should be "Decimals with leading zeros are not allowed in strict mode".

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 the esprima.parse entry point and reproduce the strict-mode input "use strict"; 08. Trace how numeric literals are parsed in strict mode and make completion produce the expected exception rather than a syntax tree. Confirm the behavior against the supplied test case and expected error message.

Written by the indexing model from the issue text.

Assessment

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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.