Skip to content

Are legacy escapes in strict mode code a valid extension? #2432

Open
@jmdyck

Description

@jmdyck

Working on PR #1867, I've been looking at 17.1 Forbidden Extensions, and I noticed that, it does have an entry saying:

When processing strict mode code, the syntax of NumericLiteral must not be extended to include LegacyOctalIntegerLiteral and the syntax of DecimalIntegerLiteral must not be extended to include NonOctalDecimalIntegerLiteral as described in B.1.1.

but it doesn't have an entry saying:

When processing strict mode code, the syntax of EscapeSequence must not be extended to include LegacyOctalEscapeSequence or NonOctalDecimalEscapeSequence as defined in B.1.2.

This seems to indicate that it's okay for an implementation to provide the latter as an extension. I'm thinking this is probably an oversight (going back to ES6). Is it?


Background: B.1.1 and B.1.2 are otherwise fairly similar in terms of what's allowed and what's disallowed. Specifically:

12.8.3 Numeric Literals says:

A conforming implementation, when processing strict mode code, must not extend, as described in B.1.1, the syntax of NumericLiteral to include LegacyOctalIntegerLiteral, nor extend the syntax of DecimalIntegerLiteral to include NonOctalDecimalIntegerLiteral.

and 12.8.4 String Literals says:

A conforming implementation, when processing strict mode code, must not extend the syntax of EscapeSequence to include LegacyOctalEscapeSequence or NonOctalDecimalEscapeSequence as described in B.1.2.

(These sentences are both repeated in Annex C.)

Similarly, B.1.1 Numeric Literals says:

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

and B.1.2 String Literals says:

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

At which point, you might think "Isn't it pretty obvious then? They're both not allowed in strict mode code." However, I think this just means that these things are not allowed in what you might call a "baseline" or "minimal" implementation. But 17 Error Handling and Language Extensions gives implementations a lot of leeway to add extensions, as long as they aren't explicitly forbidden in 17.1. So it's odd that 17.1 would forbid (as an extension) B.1.1 in strict mode code, but not B.1.2 in strict mode code.

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