Skip to content

[4.0.7, 4.0.8, 4.0.9] Missing "Illegal 'use strict' directive" error #505

@mysticatea

Description

@mysticatea

In the following cases, it should throw SyntaxError "Illegal 'use strict' directive in function with non-simple parameter list". Acorn had worked correctly until 4.0.6, but currently Acorn does not throw.

Whether strict mode or not, it should throw early syntax errors if there is "use strict" directive in the body of functions which have non-simple parameters.

// in sourceType: "script"

"use strict"
function foo(a = 1) {
  "use strict"
}
// in sourceType: "module"

function foo(a = 1) {
  "use strict"
}

It is a Syntax Error if ContainsUseStrict of FunctionBody is true and IsSimpleParameterList of FormalParameters is false.
https://www.ecma-international.org/ecma-262/7.0/#sec-function-definitions-static-semantics-early-errors

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions