Skip to content

Function declaration name is mistakenly treated as function code #1707

Description

@ariya

(As reported by @michaelficarra and explained by @bakkot as case 14,15,18-25 in #1502).

Test case:

esprima.parse('function eval() {"use strict"; }');

Actual: An exception "Function name may not be eval or arguments in strict mode".

Expected: A valid syntax tree.


A similar test case:

esprima.parse('function static() {"use strict"; }');

Actual: An exception "Use of future reserved word in strict mode".

Expected: A valid syntax tree.


A reference for this in the specification is on Types of Source Code:

Function code is source text that is parsed to supply the value of the [[ECMAScriptCode]] and [[FormalParameters]] internal slots (see 9.2) of an ECMAScript function object.

While the formal parameters are part of the function code, the declaration name however is not.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions