16 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 early errors are runtime errors.
An implementation must report as an
An implementation shall not treat other kinds of errors as early errors even if the compiler can prove that a construct cannot execute without error under any circumstances. An implementation may issue an early warning in such a case, but it should not report the error until the relevant construct is actually executed.
An implementation shall report all errors as specified, except for the following:
-
Except as restricted in
16.2 , an 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 theFunctionorRegExpconstructor ) that are allowed to throwSyntaxError are permitted to exhibit implementation-defined behaviour instead of throwingSyntaxError when they encounter an implementation-defined extension to the script syntax or regular expression pattern or flag syntax. -
Except as restricted in
16.2 , an 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 have implementation-defined behaviour instead of throwing an error (such asReferenceError ).
16.1 HostReportErrors ( errorList )
HostReportErrors is an implementation-defined abstract operation that allows host environments to report parsing errors, early errors, and runtime errors.
An implementation of HostReportErrors must complete normally in all cases. The default implementation of HostReportErrors is to unconditionally return an empty normal completion.
errorList will be a
16.2 Forbidden Extensions
An implementation must not extend this specification in the following ways:
-
ECMAScript function objects defined using syntactic constructors in
strict mode code must not be created with own properties named"caller"or"arguments". Such own properties also must not be created for function 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 theFunctionconstructor , generator functions created using theGeneratorconstructor , async functions created using theAsyncFunctionconstructor , and functions created using thebindmethod 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 the following methods must not be extended except as specified in ECMA-402:
Object.prototype.toLocaleString,Array.prototype.toLocaleString,Number.prototype.toLocaleString,Date.prototype.toLocaleDateString,Date.prototype.toLocaleString,Date.prototype.toLocaleTimeString,String.prototype.localeCompare,%TypedArray% .prototype.toLocaleString. -
The RegExp pattern grammars in
21.2.1 andB.1.4 must not be extended to recognize any of the source characters A-Z or a-z asIdentityEscape when the [U] grammar parameter is present.[+U] -
The Syntactic Grammar must not be extended in any manner that allows the token
:to immediately follow source text that matches theBindingIdentifier nonterminal symbol. -
When processing
strict mode code , the syntax ofNumericLiteral must not be extended to include prod-annexB-LegacyOctalIntegerLiteral and the syntax ofDecimalIntegerLiteral must not be extended to include prod-annexB-NonOctalDecimalIntegerLiteral as described inB.1.1 . -
TemplateCharacter must not be extended to include prod-annexB-LegacyOctalEscapeSequence as defined inB.1.2 . -
When processing
strict mode code , the extensions defined inB.3.2 ,B.3.3 ,B.3.4 , andB.3.6 must not be supported. -
When parsing for the
Module goal symbol , the lexical grammar extensions defined inB.1.3 must not be supported.