17 Error Handling and Language Extensions
implementation은 대부분의 error를 relevant ECMAScript language construct가 evaluated되는 time에 report해야 합니다. early error는 error를 contain하는 Script 안의 어떤 construct도 evaluation되기 전에 detect 및 report될 수 있는 error입니다. early error가 존재하면 construct의 evaluation은 prevented됩니다. implementation은 Script 안의 early error를 ParseScript에서 해당 Script를 parsing하는 part로 report해야 합니다. Module 안의 early error는 Module이 evaluated될 point에서 report되며 Module은 never initialized됩니다. eval code 안의 early error는 eval이 called되는 time에 report되고 eval code의 evaluation을 prevent합니다. early error가 아닌 모든 error는 runtime error입니다.
implementation은 이 specification의 “Static Semantics: Early Errors” subclause에 listed된 condition의 occurrence를 early error로 report해야 합니다.
compiler가 construct가 어떤 circumstance에서도 error 없이 execute될 수 없음을 prove할 수 있더라도, implementation은 other kinds of errors를 early error로 treat해서는 안 됩니다. implementation은 such case에 early warning을 issue할 수 있지만, relevant construct가 actually executed될 때까지 error를 report해서는 안 됩니다.
implementation은 다음을 제외하고 specified된 대로 모든 error를 report해야 합니다:
-
17.1에서 restricted된 경우를 제외하고, host 또는 implementation은 Script syntax, Module syntax 및 regular expression pattern 또는 flag syntax를 extend할 수 있습니다. 이를 permit하기 위해, SyntaxError를 throw하도록 allowed된 모든 operation(
eval calling, regular expression literal 사용, 또는 Function 또는 RegExp constructor 사용 등)은 script syntax 또는 regular expression pattern 또는 flag syntax에 대한 host-defined extension을 encounter할 때 SyntaxError를 throw하는 대신 host-defined behaviour를 exhibit하는 것이 permitted됩니다.
-
17.1에서 restricted된 경우를 제외하고, host 또는 implementation은 이 specification에 described된 것 외의 additional type, value, object, property 및 function을 provide할 수 있습니다. 이는 construct(예: global scope에서 variable lookup)가 error(예: ReferenceError)를 throwing하는 대신 host-defined behaviour를 가지게 할 수 있습니다.
17.1 Forbidden Extensions
implementation은 다음 ways로 이 specification을 extend해서는 안 됩니다:
-
strict mode code에서 syntactic constructor를 사용하여 defined된 ECMAScript function object는 "caller" 또는 "arguments"라는 own property를 가진 채 created되어서는 안 됩니다. definition이 strict mode code 안에 contained되어 있는지 여부와 관계없이, such own property는 ArrowFunction, MethodDefinition, GeneratorDeclaration, GeneratorExpression, AsyncGeneratorDeclaration, AsyncGeneratorExpression, ClassDeclaration, ClassExpression, AsyncFunctionDeclaration, AsyncFunctionExpression, 또는 AsyncArrowFunction을 사용하여 defined된 function object에 대해서도 created되어서는 안 됩니다. Built-in functions, Function constructor를 사용하여 created된 strict functions, Generator constructor를 사용하여 created된 generator functions, AsyncFunction constructor를 사용하여 created된 async functions, 그리고
bind method를 사용하여 created된 functions도 such own property를 가진 채 created되어서는 안 됩니다.
-
implementation이 어떤 function object를 "caller"라는 own property로 extend하는 경우, [[Get]] 또는 [[GetOwnProperty]]를 사용하여 observed되는 그 property의 value는 strict function object여서는 안 됩니다. 그것이 accessor property이면, property의 [[Get]] attribute의 value인 function은 called될 때 strict function을 never return해야 합니다.
-
mapped arguments object도 unmapped arguments object도 "caller"라는 own property를 가진 채 created되어서는 안 됩니다.
-
toLocaleString이라는 이름을 가진 것과 같이 ECMA-402에 specified된 built-in method의 behaviour는 ECMA-402에 specified된 경우를 제외하고 extend되어서는 안 됩니다.
-
22.2.1 및 B.1.2의 RegExp pattern grammar는 [UnicodeMode] grammar parameter가 present할 때 source character A-Z 또는 a-z 중 어느 것도 IdentityEscape[+UnicodeMode]로 recognize하도록 extend되어서는 안 됩니다.
-
Syntactic Grammar는 token
:가 BindingIdentifier nonterminal symbol에 matched된 source text 바로 뒤에 follow하도록 allow하는 어떤 manner로도 extend되어서는 안 됩니다.
-
strict mode code를 processing할 때, implementation은 12.9.3.1의 early error rule을 relax해서는 안 됩니다.
-
TemplateEscapeSequence는 12.9.4에 defined된 LegacyOctalEscapeSequence 또는 NonOctalDecimalEscapeSequence를 include하도록 extend되어서는 안 됩니다.
-
strict mode code를 processing할 때, B.3.1, B.3.2, B.3.3, 및 B.3.5에 defined된 extension은 support되어서는 안 됩니다.
-
Module goal symbol에 대해 parsing할 때, B.1.1에 defined된 lexical grammar extension은 support되어서는 안 됩니다.
-
ImportCall은 extend되어서는 안 됩니다.