17 Error Handling and Language Extensions
An implementation must report most errors at the time the relevant ECMAScript language construct is evaluated. An early error is an error that can be detected and reported prior to the evaluation of any construct in the eval
is called and prevent evaluation of the eval code. All errors that are not
An implementation must report as an
An implementation shall not treat other kinds of errors as
An implementation shall report all errors as specified, except for the following:
-
Except as restricted in
17.1 , ahost or implementation may extendScript syntax,Module syntax, and regular expression pattern or flag syntax. To permit this, all operations (such as callingeval
, using a regular expression literal, or using the Function or RegExpconstructor ) that are allowed to throwSyntaxError are permitted to exhibithost-defined behaviour instead of throwingSyntaxError when they encounter ahost-defined extension to the script syntax or regular expression pattern or flag syntax. -
Except as restricted in
17.1 , ahost or implementation may provide additional types, values, objects, properties, and functions beyond those described in this specification. This may cause constructs (such as looking up a variable in the global scope) to havehost-defined behaviour instead of throwing an error (such asReferenceError ).
17.1 Forbidden Extensions
An implementation must not extend this specification in the following ways:
-
ECMAScript
function objects defined using syntacticconstructors instrict mode code must not be created with own properties named"caller" or"arguments" . Such own properties also must not be created forfunction objects defined using anArrowFunction ,MethodDefinition ,GeneratorDeclaration ,GeneratorExpression ,AsyncGeneratorDeclaration ,AsyncGeneratorExpression ,ClassDeclaration ,ClassExpression ,AsyncFunctionDeclaration ,AsyncFunctionExpression , orAsyncArrowFunction regardless of whether the definition is contained instrict mode code . Built-in functions,strict functions created using the Functionconstructor , generator functions created using the Generatorconstructor , async functions created using the AsyncFunctionconstructor , and functions created using thebind
method also must not be created with such own properties. -
If an implementation extends any
function object with an own property named"caller" the value of that property, as observed using [[Get]] or [[GetOwnProperty]], must not be astrict function object. If it is anaccessor property , the function that is the value of the property's [[Get]] attribute must never return astrict function when called. -
Neither mapped nor unmapped arguments objects may be created with an own property named
"caller" . -
The behaviour of built-in methods which are specified in ECMA-402, such as those named
toLocaleString
, must not be extended except as specified in ECMA-402. -
The RegExp pattern grammars in
22.2.1 andB.1.2 must not be extended to recognize any of the source characters A-Z or a-z asIdentityEscape when the [UnicodeMode] grammar parameter is present.[+UnicodeMode] -
The Syntactic Grammar must not be extended in any manner that allows the token
:
to immediately follow source text that is matched by theBindingIdentifier nonterminal symbol. -
When processing
strict mode code , an implementation must not relax theearly error rules of12.9.3.1 . -
TemplateEscapeSequence must not be extended to includeLegacyOctalEscapeSequence orNonOctalDecimalEscapeSequence as defined in12.9.4 . -
When processing
strict mode code , the extensions defined inB.3.1 ,B.3.2 ,B.3.3 , andB.3.5 must not be supported. -
When parsing for the
Module goal symbol , the lexical grammar extensions defined inB.1.1 must not be supported. -
ImportCall must not be extended.