├── .gitattributes ├── .github └── workflows │ ├── build.yml │ └── pr.yml ├── .gitignore ├── .vscode ├── extensions.json ├── settings.json └── tasks.json ├── .yo-rc.json ├── LICENSE ├── README.md ├── gulpfile.js ├── package-lock.json ├── package.json └── spec ├── biblio.json ├── ecma262biblio.json ├── index.html ├── sec-break-statement-static-semantics-early-errors-patch.html ├── sec-class-definitions-patch.html ├── sec-continue-statement-static-semantics-early-errors-patch.html ├── sec-ecmascript-specification-types-patch.html ├── sec-introduction.html ├── sec-operations-on-objects-patch.html ├── sec-runtime-semantics-evaluatebody-patch.html ├── sec-static-semantics-computedpropertycontains-patch.html ├── sec-static-semantics-contains-patch.html ├── sec-static-semantics-containsduplicatelabels-patch.html ├── sec-static-semantics-containsundefinedbreaktarget-patch.html ├── sec-static-semantics-containsundefinedcontinuetarget-patch.html ├── sec-static-semantics-lexicallydeclarednames-patch.html ├── sec-static-semantics-lexicallyscopeddeclarations-patch.html ├── sec-static-semantics-propname-patch.html ├── sec-static-semantics-vardeclarednames-patch.html └── sec-static-semantics-varscopeddeclarations-patch.html /.gitattributes: -------------------------------------------------------------------------------- 1 | * text=auto 2 | -------------------------------------------------------------------------------- /.github/workflows/build.yml: -------------------------------------------------------------------------------- 1 | name: Publish Spec to gh-pages 2 | on: 3 | push: 4 | branches: [ main ] 5 | jobs: 6 | build: 7 | runs-on: ubuntu-latest 8 | steps: 9 | - uses: actions/checkout@v2 10 | - run: npm install 11 | - run: npm run build 12 | - name: Deploy 13 | uses: JamesIves/github-pages-deploy-action@4.1.4 14 | with: 15 | branch: gh-pages 16 | folder: docs 17 | clean-exclude: | 18 | pr 19 | -------------------------------------------------------------------------------- /.github/workflows/pr.yml: -------------------------------------------------------------------------------- 1 | name: Publish PR to gh-pages/pr/ 2 | on: 3 | pull_request: 4 | branches: [ main ] 5 | jobs: 6 | build: 7 | runs-on: ubuntu-latest 8 | if: ${{ github.event.number }} 9 | steps: 10 | - uses: actions/checkout@v2 11 | - run: npm install 12 | - run: npm run build 13 | - name: Deploy 14 | uses: JamesIves/github-pages-deploy-action@4.1.4 15 | with: 16 | branch: gh-pages 17 | folder: docs 18 | target-folder: pr/${{ github.event.number }}/ 19 | - id: get-preview-url 20 | name: Get preview url 21 | run: echo "::set-output name=preview-url::https://tc39.es/$(basename $GITHUB_REPOSITORY)/pr/${{ github.event.number }}" 22 | shell: bash 23 | - name: Post Preview Comment 24 | uses: phulsechinmay/rewritable-pr-comment@v0.3.0 25 | with: 26 | GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 27 | COMMENT_IDENTIFIER: tc39_pr_preview_comment 28 | message: | 29 | A preview of this PR can be found at ${{ steps.get-preview-url.outputs.preview-url }}. 30 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | coverage 3 | docs -------------------------------------------------------------------------------- /.vscode/extensions.json: -------------------------------------------------------------------------------- 1 | { 2 | "recommendations": [ 3 | "rbuckton.grammarkdown-vscode", 4 | "rbuckton.ecmarkup-vscode" 5 | ] 6 | } -------------------------------------------------------------------------------- /.vscode/settings.json: -------------------------------------------------------------------------------- 1 | { 2 | "[markdown]": { 3 | "files.trimTrailingWhitespace": false 4 | }, 5 | "files.associations": { 6 | // "*.html": "ecmarkup", 7 | "*.emu": "ecmarkup" 8 | } 9 | } -------------------------------------------------------------------------------- /.vscode/tasks.json: -------------------------------------------------------------------------------- 1 | { 2 | // See https://go.microsoft.com/fwlink/?LinkId=733558 3 | // for the documentation about the tasks.json format 4 | "version": "2.0.0", 5 | "tasks": [ 6 | { 7 | "type": "gulp", 8 | "task": "build", 9 | "group": { 10 | "kind": "build", 11 | "isDefault": true 12 | } 13 | } 14 | ] 15 | } -------------------------------------------------------------------------------- /.yo-rc.json: -------------------------------------------------------------------------------- 1 | { 2 | "generator-ecmascript-proposal": { 3 | "promptValues": { 4 | "hasChampion": true, 5 | "championName": "Ron Buckton", 6 | "championGithub": "rbuckton", 7 | "spec": "https://rbuckton.github.io/proposal-class-static-block", 8 | "stage": "0", 9 | "sections": [ 10 | "prior-art", 11 | "syntax", 12 | "semantics", 13 | "examples", 14 | "grammar", 15 | "references", 16 | "prior-discussion" 17 | ], 18 | "build": "gulp", 19 | "vscode": true 20 | } 21 | } 22 | } -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | BSD 3-Clause License 2 | 3 | Copyright (c) 2017, Ron Buckton, Ecma International 4 | All rights reserved. 5 | 6 | Redistribution and use in source and binary forms, with or without 7 | modification, are permitted provided that the following conditions are met: 8 | 9 | * Redistributions of source code must retain the above copyright notice, this 10 | list of conditions and the following disclaimer. 11 | 12 | * Redistributions in binary form must reproduce the above copyright notice, 13 | this list of conditions and the following disclaimer in the documentation 14 | and/or other materials provided with the distribution. 15 | 16 | * Neither the name of the copyright holder nor the names of its 17 | contributors may be used to endorse or promote products derived from 18 | this software without specific prior written permission. 19 | 20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 21 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 22 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE 24 | FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 25 | DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 26 | SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER 27 | CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 28 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 29 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | # ECMAScript class static initialization blocks 3 | 4 | Class `static` blocks provide a mechanism to perform additional static initialization during class 5 | definition evaluation. 6 | 7 | This is not intended as a replacement for public fields, as they provide useful information for 8 | static analysis tools and are a valid target for decorators. Rather, this is intended to augment 9 | existing use cases and enable new use cases not currently handled by that proposal. 10 | 11 | 12 | 13 | 14 | ## Status 15 | 16 | **Stage:** 4 17 | **Champion:** Ron Buckton (@rbuckton) 18 | 19 | _For detailed status of this proposal see [TODO](#todo), below._ 20 | 21 | 22 | 23 | ## Authors 24 | 25 | * Ron Buckton (@rbuckton) 26 | 27 | 28 | 29 | # Motivations 30 | 31 | The current proposals for static fields and static private fields provide a mechanism to perform 32 | per-field initialization of the static-side of a class during ClassDefinitionEvaluation, however 33 | there are some cases that cannot be covered easily. For example, if you need to evaluate statements 34 | during initialization (such as `try..catch`), or set two fields from a single value, you have to 35 | perform that logic outside of the class definition. 36 | 37 | ```js 38 | // without static blocks: 39 | class C { 40 | static x = ...; 41 | static y; 42 | static z; 43 | } 44 | 45 | try { 46 | const obj = doSomethingWith(C.x); 47 | C.y = obj.y 48 | C.z = obj.z; 49 | } 50 | catch { 51 | C.y = ...; 52 | C.z = ...; 53 | } 54 | 55 | // with static blocks: 56 | class C { 57 | static x = ...; 58 | static y; 59 | static z; 60 | static { 61 | try { 62 | const obj = doSomethingWith(this.x); 63 | this.y = obj.y; 64 | this.z = obj.z; 65 | } 66 | catch { 67 | this.y = ...; 68 | this.z = ...; 69 | } 70 | } 71 | } 72 | ``` 73 | 74 | In addition, there are cases where information sharing needs to occur between a class with an 75 | instance private field and another class or function declared in the same scope. 76 | 77 | Static blocks provide an opportunity to evaluate statements in the context of the current class 78 | declaration, with privileged access to private state (be they instance-private or static-private): 79 | 80 | ```js 81 | let getX; 82 | 83 | export class C { 84 | #x 85 | constructor(x) { 86 | this.#x = { data: x }; 87 | } 88 | 89 | static { 90 | // getX has privileged access to #x 91 | getX = (obj) => obj.#x; 92 | } 93 | } 94 | 95 | export function readXData(obj) { 96 | return getX(obj).data; 97 | } 98 | ``` 99 | 100 | ## Relation to "Private Declarations" 101 | 102 | Proposal: https://github.com/tc39/proposal-private-declarations 103 | 104 | The Private Declarations proposal also intends to address the issue of privileged access between two classes, by lifting 105 | the private name out of the class declaration and into the enclosing scope. While there is some overlap in that respect, 106 | private declarations do not solve the issue of multi-step static initialization without potentially exposing a private 107 | name to the outer scope purely for initialization purposes: 108 | 109 | ```js 110 | // with private declarations 111 | private #z; // exposed purely for post-declaration initialization 112 | class C { 113 | static y; 114 | static outer #z; 115 | } 116 | const obj = ...; 117 | C.y = obj.y; 118 | C.#z = obj.z; 119 | 120 | // with static block 121 | class C { 122 | static y; 123 | static #z; // not exposed outside of class 124 | static { 125 | const obj = ...; 126 | this.y = obj.y; 127 | this.#z = obj.z; 128 | } 129 | } 130 | ``` 131 | 132 | In addition, Private Declarations expose a private name that potentially allows both read and write access to shared private state 133 | when read-only access might be desireable. To work around this with private declarations requires additional complexity (though there is 134 | a similar cost for `static{}` as well): 135 | 136 | ```js 137 | // with private declarations 138 | private #zRead; 139 | class C { 140 | #z = ...; // only writable inside of the class 141 | get #zRead() { return this.#z; } // wrapper needed to ensure read-only access 142 | } 143 | 144 | // with static 145 | let zRead; 146 | class C { 147 | #z = ...; // only writable inside of the class 148 | static { zRead = obj => obj.#z; } // callback needed to ensure read-only access 149 | } 150 | ``` 151 | 152 | In the long run, however, there is nothing that prevents these two proposals from working side-by-side: 153 | 154 | ```js 155 | private #shared; 156 | class C { 157 | static outer #shared; 158 | static #local; 159 | static { 160 | const obj = ...; 161 | this.#shared = obj.shared; 162 | this.#local = obj.local; 163 | } 164 | } 165 | class D { 166 | method() { 167 | C.#shared; // ok 168 | C.#local; // no access 169 | } 170 | } 171 | ``` 172 | 173 | 174 | 175 | 176 | # Prior Art 177 | 178 | - C#: [Static Constructors](https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/classes-and-structs/static-constructors) 179 | - Java: [Static Initializers](https://docs.oracle.com/javase/specs/jls/se10/html/jls-8.html#jls-8.7) 180 | 181 | 182 | 183 | # Syntax 184 | 185 | ```js 186 | class C { 187 | static { 188 | // statements 189 | } 190 | } 191 | ``` 192 | 193 | 194 | 195 | # Semantics 196 | 197 | - A `static {}` initialization block creates a new lexical scope (e.g. `var`, `function`, and block-scoped 198 | declarations are local to the `static {}` initialization block. This lexical scope is nested within the lexical 199 | scope of the class body (granting privileged access to instance private state for the class). 200 | - A class may have any number of `static {}` initialization blocks in its class body. 201 | - `static {}` initialization blocks are evaluated in document order interleaved with static field initializers. 202 | - A `static {}` initialization block may not have decorators (instead you would decorate the class itself). 203 | - When evaluated, a `static {}` initialization block's `this` receiver is the constructor object of the class 204 | (as with static field initializers). 205 | - It is a **Syntax Error** to reference `arguments` from within a `static {}` initialization block. 206 | - It is a **Syntax Error** to include a _SuperCall_ (i.e., `super()`) from within a `static {}` initialization block. 207 | - A `static {}` initialization block may contain _SuperProperty_ references as a means to access or invoke static 208 | members on a base class that may have been overridden by the derived class containing the `static {}` 209 | initialization block. 210 | - A `static {}` initialization block should be represented as an independent stack frame in debuggers and exception 211 | traces. 212 | 213 | 214 | 215 | 216 | # Examples 217 | 218 | ```js 219 | // "friend" access (same module) 220 | let A, B; 221 | { 222 | let friendA; 223 | 224 | A = class A { 225 | #x; 226 | 227 | static { 228 | friendA = { 229 | getX(obj) { return obj.#x }, 230 | setX(obj, value) { obj.#x = value } 231 | }; 232 | } 233 | }; 234 | 235 | B = class B { 236 | constructor(a) { 237 | const x = friendA.getX(a); // ok 238 | friendA.setX(a, x); // ok 239 | } 240 | }; 241 | } 242 | ``` 243 | 244 | 245 | 246 | 251 | 252 | 253 | 254 | 263 | 264 | 265 | 266 | # References 267 | 268 | * [Stage 0 Presentation](https://docs.google.com/presentation/d/1TLFrhKMW2UHlHIcjKN02cEJsSq4HL7odS6TE6M-OGYg/edit?usp=sharing) 269 | 270 | 271 | 272 | 273 | 280 | 281 | 282 | 283 | # TODO 284 | 285 | The following is a high-level list of tasks to progress through each stage of the [TC39 proposal process](https://tc39.github.io/process-document/): 286 | 287 | ### Stage 1 Entrance Criteria 288 | 289 | * [x] Identified a "[champion][Champion]" who will advance the addition. 290 | * [x] [Prose][Prose] outlining the problem or need and the general shape of a solution. 291 | * [x] Illustrative [examples][Examples] of usage. 292 | * [x] High-level [API][API]. 293 | 294 | ### Stage 2 Entrance Criteria 295 | 296 | * [x] [Initial specification text][Specification]. 297 | * [x] [Transpiler support][Transpiler] (_Optional_). 298 | * Babel `v7.12.0` 299 | * TypeScript `v4.4 beta` ([TypeScript Playground](https://www.typescriptlang.org/play?ts=4.4.0-dev.20210628#code/DYUwLgBA5uAaCEAuCAKAxsgwgSggXgD4IA7AVwFsAjEAJwG4AoBtYAQwGd2JMIBvBiBADEAD3wQADI0HswrMAEs0fAYOhxxywhDQA6UdIgBfBieYB7Yu3Ohdwc1BQwwsFMRAB3bimy+6QA)) 300 | 301 | ### Stage 3 Entrance Criteria 302 | 303 | * [x] [Complete specification text][Specification]. 304 | * [x] Designated reviewers have [signed off][Stage3ReviewerSignOff] on the current spec text. 305 | * [x] The ECMAScript editor has [signed off][Stage3EditorSignOff] on the current spec text. 306 | 307 | ### Stage 4 Entrance Criteria 308 | > For up-to-date information on Stage 4 criteria, check: [#48](https://github.com/tc39/proposal-class-static-block/issues/48) 309 | * [x] [Test262](https://github.com/tc39/test262) acceptance tests have been written for mainline usage scenarios and [merged][Test262PullRequest]. 310 | * [x] Two compatible implementations which pass the acceptance tests: 311 | * [x] [SpiderMonkey][Implementation1] — Partially shipping Shipping [behind a flag in 92](https://github.com/tc39/proposal-class-static-block/issues/48#issuecomment-867967054), Intent to ship [unflagged in 93](https://bugzilla.mozilla.org/show_bug.cgi?id=1725689): \ 312 | ![SpiderMonkey Example](https://user-images.githubusercontent.com/3902892/123336344-9912f100-d4fa-11eb-949f-b3692d22cd21.png "Example showing class static blocks working in FireFox Nightly") 313 | * [x] [V8][Implementation2] — Shipping unflagged (at least as of 9.4.146): \ 314 | ![V8 Example](https://user-images.githubusercontent.com/3902892/129283096-45218040-2056-452b-8418-3f394b616174.png "Example showing class static blocks working in Chrome 9.4.146") 315 | * [x] A [pull request][Ecma262PullRequest] has been sent to tc39/ecma262 with the integrated spec text. 316 | * [x] The ECMAScript editor has signed off on the [pull request][Ecma262PullRequest]. 317 | 318 | 319 | [Process]: https://tc39.github.io/process-document/ 320 | [Proposals]: https://github.com/tc39/proposals/ 321 | [Grammarkdown]: http://github.com/rbuckton/grammarkdown#readme 322 | [Champion]: #status 323 | [Prose]: #motivations 324 | [Examples]: #examples 325 | [API]: #api 326 | [Specification]: https://arai-a.github.io/ecma262-compare/?pr=2440 327 | [Transpiler]: https://www.typescriptlang.org/play?ts=4.4.0-dev.20210628#code/DYUwLgBA5uAaCEAuCAKAxsgwgSggXgD4IA7AVwFsAjEAJwG4AoBtYAQwGd2JMIBvBiBADEAD3wQADI0HswrMAEs0fAYOhxxywhDQA6UdIgBfBieYB7Yu3Ohdwc1BQwwsFMRAB3bimy+6QA 328 | [Stage3ReviewerSignOff]: https://github.com/tc39/proposal-class-static-block/issues/23 329 | [Stage3EditorSignOff]: https://github.com/tc39/proposal-class-static-block/pull/31 330 | [Test262PullRequest]: https://github.com/tc39/test262/pull/2968 331 | [Implementation1]: https://bugzilla.mozilla.org/show_bug.cgi?id=1712138 332 | [Implementation2]: https://bugs.chromium.org/p/v8/issues/detail?id=11375 333 | [Ecma262PullRequest]: https://github.com/tc39/ecma262/pull/2440 334 | -------------------------------------------------------------------------------- /gulpfile.js: -------------------------------------------------------------------------------- 1 | const del = require("del"); 2 | const path = require("path"); 3 | const gulp = require("gulp"); 4 | const emu = require("gulp-emu"); 5 | const gls = require("gulp-live-server"); 6 | 7 | const clean = () => del("docs/**/*"); 8 | gulp.task("clean", clean); 9 | 10 | const build = () => gulp 11 | .src(["spec/index.html"]) 12 | .pipe(emu({ 13 | ecma262Biblio: false 14 | })) 15 | .pipe(gulp.dest("docs")); 16 | gulp.task("build", build); 17 | 18 | const watch = () => gulp 19 | .watch(["spec/**/*"], build); 20 | gulp.task("watch", watch); 21 | 22 | const serve = () => { 23 | const server = gls.static("docs", 8080); 24 | const promise = server.start(); 25 | (/** @type {import("chokidar").FSWatcher}*/(gulp.watch(["docs/**/*"]))) 26 | .on("change", file => { 27 | server.notify({ path: path.resolve(file) }); 28 | }); 29 | return promise; 30 | }; 31 | gulp.task("start", gulp.parallel(watch, serve)); 32 | gulp.task("default", build); -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "proposal-class-static-block", 3 | "version": "0.0.0", 4 | "private": true, 5 | "description": "ECMAScript class static initialization blocks", 6 | "homepage": "https://github.com/tc39/proposal-class-static-block#readme", 7 | "author": { 8 | "name": "Ron Buckton", 9 | "email": "ron.buckton@microsoft.com" 10 | }, 11 | "keywords": [ 12 | "javascript", 13 | "ecmascript" 14 | ], 15 | "scripts": { 16 | "build": "gulp build", 17 | "start": "gulp start" 18 | }, 19 | "license": "SEE LICENSE IN https://tc39.github.io/ecma262/#sec-copyright-and-software-license", 20 | "devDependencies": { 21 | "del": "^5.1.0", 22 | "ecmarkup": "^7.1.0", 23 | "gulp": "^4.0.2", 24 | "gulp-emu": "^1.3.2", 25 | "gulp-live-server": "0.0.31" 26 | }, 27 | "repository": "tc39/proposal-class-static-block" 28 | } 29 | -------------------------------------------------------------------------------- /spec/biblio.json: -------------------------------------------------------------------------------- 1 | { 2 | "https://arai-a.github.io/ecma262-compare/?pr=1668&id=sec-class-definitions-static-semantics-containsarguments": [ 3 | {"type": "clause", "id": "sec-class-definitions-static-semantics-containsarguments", "aoid": "ContainsArguments", "title": "Static Semantics: ContainsArguments", "titleHTML": "Static Semantics: ContainsArguments", "namespace": "https://tc39.es/ecma262/", "number": "14.6.15", "location": "", "referencingIds": [], "key": "Static Semantics: ContainsArguments" } 4 | ] 5 | } -------------------------------------------------------------------------------- /spec/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 |
 6 | title: ECMAScript class static initialization blocks
 7 | stage: 3
 8 | contributors: Ron Buckton, Ecma International
 9 | 
10 | 11 | 12 | 13 | 14 | 15 |

Introduction

16 | 17 |
18 | 19 | 20 |

ECMAScript Data Types and Values

21 | 22 |
23 | 24 | 25 |

Abstract Operations

26 | 27 |
28 | 29 | 30 |

Syntax-Directed Operations

31 |

In addition to those defined in this section, specialized syntax-directed operations are defined throughout this specification.

32 | 33 |

Scope Analysis

34 | 35 | 36 | 37 | 38 |
39 | 40 | 41 |

Labels

42 | 43 | 44 | 45 |
46 | 47 |

Contains

48 | 49 | 50 |
51 | 52 |

Miscellaneous

53 |

These operations are used in multiple places throughout the specification.

54 | 55 |
56 |
57 | 58 | 59 |

Ordinary and Exotic Objects Behaviours

60 | 61 |

ECMAScript Function Objects

62 | 63 |

[[Call]] ( _thisArgument_, _argumentsList_ )

64 | 65 |
66 |
67 |
68 | 69 | 70 |

ECMAScript Language: Statements and Declarations

71 | 72 |

The `continue` Statement

73 | 74 |
75 | 76 |

The `break` Statement

77 | 78 |
79 |
80 | 81 | 82 |

ECMAScript Language: Functions and Classes

83 | 84 |
85 | -------------------------------------------------------------------------------- /spec/sec-break-statement-static-semantics-early-errors-patch.html: -------------------------------------------------------------------------------- 1 | 2 |

Static Semantics: Early Errors

3 | BreakStatement : `break` `;` 4 | 9 |
10 | -------------------------------------------------------------------------------- /spec/sec-class-definitions-patch.html: -------------------------------------------------------------------------------- 1 | 2 |

Class Definitions

3 |

Syntax

4 | 5 | ClassElement[Yield, Await] : 6 | MethodDefinition[?Yield, ?Await] 7 | `static` MethodDefinition[?Yield, ?Await] 8 | FieldDefinition[?Yield, ?Await] `;` 9 | `static` FieldDefinition[?Yield, ?Await] `;` 10 | ClassStaticBlock 11 | `;` 12 | 13 | 14 | ClassStaticBlock : 15 | `static` `{` ClassStaticBlockBody `}` 16 | 17 | ClassStaticBlockBody : 18 | ClassStaticBlockStatementList 19 | 20 | ClassStaticBlockStatementList : 21 | StatementList[~Yield, +Await, ~Return]? 22 | 23 | 24 | 25 | 26 |

Static Semantics: Early Errors

27 | 28 | ClassStaticBlockBody : ClassStaticBlockStatementList 29 |
    30 |
  • 31 | It is a Syntax Error if the LexicallyDeclaredNames of |ClassStaticBlockStatementList| contains any duplicate entries. 32 |
  • 33 |
  • 34 | It is a Syntax Error if any element of the LexicallyDeclaredNames of |ClassStaticBlockStatementList| also occurs in the VarDeclaredNames of |ClassStaticBlockStatementList|. 35 |
  • 36 |
  • 37 | It is a Syntax Error if ContainsDuplicateLabels of |ClassStaticBlockStatementList| with argument « » is *true*. 38 |
  • 39 |
  • 40 | It is a Syntax Error if ContainsUndefinedBreakTarget of |ClassStaticBlockStatementList| with argument « » is *true*. 41 |
  • 42 |
  • 43 | It is a Syntax Error if ContainsUndefinedContinueTarget of |ClassStaticBlockStatementList| with arguments « » and « » is *true*. 44 |
  • 45 |
  • 46 | It is a Syntax Error if ContainsArguments of |ClassStaticBlockStatementList| is *true*. 47 |
  • 48 |
  • 49 | It is a Syntax Error if |ClassStaticBlockStatementList| Contains |SuperCall| is *true*. 50 |
  • 51 |
  • 52 | It is a Syntax Error if ContainsAwait of |ClassStaticBlockStatementList| is *true*. 53 |
  • 54 |
55 |
56 |
57 | 58 | 59 |

Static Semantics: ClassElementKind

60 | ClassElement : MethodDefinition 61 | 62 | 1. If PropName of |MethodDefinition| is *"constructor"*, return ~ConstructorMethod~. 63 | 1. Return ~NonConstructorMethod~. 64 | 65 | 66 | ClassElement : 67 | `static` MethodDefinition 68 | FieldDefinition `;` 69 | `static` FieldDefinition `;` 70 | 71 | 72 | 1. Return ~NonConstructorMethod~. 73 | 74 | 75 | ClassElement : ClassStaticBlock 76 | 77 | 1. Return ~NonConstructorMethod~. 78 | 79 | 80 | ClassElement : `;` 81 | 82 | 1. Return ~empty~. 83 | 84 |
85 | 86 | 87 |

Static Semantics: IsStatic

88 | ClassElement : MethodDefinition 89 | 90 | 1. Return *false*. 91 | 92 | ClassElement : `static` MethodDefinition 93 | 94 | 1. Return *true*. 95 | 96 | ClassElement : FieldDefinition `;` 97 | 98 | 1. Return *false*. 99 | 100 | ClassElement : `static` FieldDefinition `;` 101 | 102 | 1. Return *true*. 103 | 104 | 105 | ClassElement : ClassStaticBlock 106 | 107 | 1. Return *true*. 108 | 109 | 110 | ClassElement : `;` 111 | 112 | 1. Return *false*. 113 | 114 |
115 | 116 | 117 | 118 |

Static Semantics: PrivateBoundIdentifiers

119 | 120 | FieldDefinition : ClassElementName Initializer? 121 | 122 | 123 | 1. Return PrivateBoundIdentifiers of |ClassElementName|. 124 | 125 | 126 | 127 | ClassElementName : PrivateIdentifier 128 | 129 | 130 | 1. Return a List whose sole element is the StringValue of |PrivateIdentifier|. 131 | 132 | 133 | 134 | ClassElementName : PropertyName 135 | 136 | ClassElement : ClassStaticBlock 137 | 138 | ClassElement : `;` 139 | 140 | 141 | 1. Return a new empty List. 142 | 143 | 144 | 145 | ClassElementList : ClassElementList ClassElement 146 | 147 | 148 | 1. Let _names_ be PrivateBoundIdentifiers of |ClassElementList|. 149 | 1. Append to _names_ the elements of PrivateBoundIdentifiers of |ClassElement|. 150 | 1. Return _names_. 151 | 152 | 153 | 154 | MethodDefinition : 155 | ClassElementName `(` UniqueFormalParameters `)` `{` FunctionBody `}` 156 | `get` ClassElementName `(` `)` `{` FunctionBody `}` 157 | `set` ClassElementName `(` PropertySetParameterList `)` `{` FunctionBody `}` 158 | 159 | GeneratorMethod : 160 | `*` ClassElementName `(` UniqueFormalParameters `)` `{` GeneratorBody `}` 161 | 162 | AsyncMethod : 163 | `async` ClassElementName `(` UniqueFormalParameters `)` `{` AsyncFunctionBody `}` 164 | 165 | AsyncGeneratorMethod : 166 | `async` `*` ClassElementName `(` UniqueFormalParameters `)` `{` AsyncGeneratorBody `}` 167 | 168 | 169 | 1. Return PrivateBoundIdentifiers of |ClassElementName|. 170 | 171 |
172 | 173 | 174 |

Static Semantics: ContainsAwait

175 | 176 | 177 |

Every grammar production alternative in this specification which is not listed below implicitly has the following default definition of ContainsAwait:

178 | 179 | 1. For each child node _child_ of this Parse Node, do 180 | 1. If _child_ is an instance of a nonterminal, then 181 | 1. If ContainsAwait for _child_ is *true*, return *true*. 182 | 1. Return *false*. 183 | 184 | 185 | 186 | FunctionDeclaration : 187 | `function` BindingIdentifier `(` FormalParameters `)` `{` FunctionBody `}` 188 | `function` `(` FormalParameters `)` `{` FunctionBody `}` 189 | 190 | FunctionExpression : 191 | `function` BindingIdentifier? `(` FormalParameters `)` `{` FunctionBody `}` 192 | 193 | GeneratorDeclaration : 194 | `function` `*` BindingIdentifier `(` FormalParameters `)` `{` GeneratorBody `}` 195 | `function` `*` `(` FormalParameters `)` `{` GeneratorBody `}` 196 | 197 | GeneratorExpression : 198 | `function` `*` BindingIdentifier? `(` FormalParameters `)` `{` GeneratorBody `}` 199 | 200 | AsyncGeneratorDeclaration : 201 | `async` `function` `*` BindingIdentifier `(` FormalParameters `)` `{` AsyncGeneratorBody `}` 202 | `async` `function` `*` `(` FormalParameters `)` `{` AsyncGeneratorBody `}` 203 | 204 | AsyncGeneratorExpression : 205 | `async` `function` `*` BindingIdentifier? `(` FormalParameters `)` `{` AsyncGeneratorBody `}` 206 | 207 | AsyncFunctionDeclaration : 208 | `async` `function` BindingIdentifier `(` FormalParameters `)` `{` AsyncFunctionBody `}` 209 | `async` `function` `(` FormalParameters `)` `{` AsyncFunctionBody `}` 210 | 211 | AsyncFunctionExpression : 212 | `async` `function` BindingIdentifier? `(` FormalParameters `)` `{` AsyncFunctionBody `}` 213 | 214 | 215 | 1. Return *false*. 216 | 217 | 218 |

Static semantic rules that depend upon substructure generally do not look into function definitions.

219 |
220 | 221 | ClassTail : ClassHeritage? `{` ClassBody `}` 222 | 223 | 1. If |ClassHeritage| is present, then 224 | 1. If ContainsAwait for |ClassHeritage| is *true*, return *true*. 225 | 1. Return the result of ComputedPropertyContainsAwait for |ClassBody|. 226 | 227 | 228 |

Static semantic rules that depend upon substructure generally do not look into class bodies except for |PropertyName|s.

229 |
230 | 231 | 232 | ArrowFunction : ArrowParameters `=>` ConciseBody 233 | 234 | AsyncArrowFunction : 235 | `async` AsyncArrowBindingIdentifier `=>` AsyncConciseBody 236 | CoverCallExpressionAndAsyncArrowHead `=>` AsyncConciseBody 237 | 238 | 239 | 1. Return *false*. 240 | 241 | 242 |

Static semantic rules that depend upon substructure containing `await` do not need to look into arrow functions.

243 |
244 | 245 | 246 | UnaryExpression : AwaitExpression 247 | 248 | 249 | 1. Return *true*. 250 | 251 | 252 | 253 | ForInOfStatement : `for` `await` `(` LeftHandSideExpression `of` AssignmentExpression `)` Statement 254 | 255 | ForInOfStatement : `for` `await` `(` `var` ForBinding `of` AssignmentExpression `)` Statement 256 | 257 | ForInOfStatement : `for` `await` `(` ForDeclaration `of` AssignmentExpression `)` Statement 258 | 259 | 260 | 1. Return *true*. 261 | 262 |
263 |
264 | 265 | 266 |

Static Semantics: ComputedPropertyContainsAwait

267 | 268 | 269 | ClassElementName : PrivateIdentifier 270 | 271 | PropertyName : LiteralPropertyName 272 | 273 | 274 | 1. Return *false*. 275 | 276 | PropertyName : ComputedPropertyName 277 | 278 | 1. Return the result of ContainsAwait for |ComputedPropertyName|. 279 | 280 | 281 | MethodDefinition : 282 | ClassElementName `(` UniqueFormalParameters `)` `{` FunctionBody `}` 283 | `get` ClassElementName `(` `)` `{` FunctionBody `}` 284 | `set` ClassElementName `(` PropertySetParameterList `)` `{` FunctionBody `}` 285 | 286 | 287 | 1. Return the result of ComputedPropertyContainsAwait for |ClassElementName|. 288 | 289 | GeneratorMethod : `*` ClassElementName `(` UniqueFormalParameters `)` `{` GeneratorBody `}` 290 | 291 | 1. Return the result of ComputedPropertyContainsAwait for |ClassElementName|. 292 | 293 | AsyncGeneratorMethod : `async` `*` ClassElementName `(` UniqueFormalParameters `)` `{` AsyncGeneratorBody `}` 294 | 295 | 1. Return the result of ComputedPropertyContainsAwait for |ClassElementName|. 296 | 297 | ClassElementList : ClassElementList ClassElement 298 | 299 | 1. Let ComputedPropertyContainsAwait for |ClassElementList| is *true*, return *true*. 300 | 1. Return the result of ComputedPropertyContainsAwait for |ClassElement|. 301 | 302 | 303 | ClassElement : ClassStaticBlock 304 | 305 | ClassElement : `;` 306 | 307 | 308 | 1. Return *false*. 309 | 310 | 311 | AsyncMethod : `async` ClassElementName `(` UniqueFormalParameters `)` `{` AsyncFunctionBody `}` 312 | 313 | 314 | 1. Return the result of ComputedPropertyContainsAwait for |ClassElementName|. 315 | 316 | 317 | FieldDefinition : ClassElementName Initializer? 318 | 319 | 320 | 1. Return the result of ComputedPropertyContainsAwait for |ClassElementName|. 321 | 322 | 323 |
324 | 325 | 326 |

Runtime Semantics: ClassStaticBlockDefinitionEvaluation

327 | 328 |

With parameter _homeObject_.

329 | ClassStaticBlock : `static` `{` ClassStaticBlockBody `}` 330 | 331 | 1. Let _lex_ be the running execution context's LexicalEnvironment. 332 | 1. Let _privateScope_ be the running execution context's PrivateEnvironment. 333 | 1. Let _sourceText_ be the empty sequence of Unicode code points. 334 | 1. Let _formalParameters_ be an instance of the production FormalParameters : [empty]. 335 | 1. Let _bodyFunction_ be OrdinaryFunctionCreate(%Function.prototype%, _sourceText_, _formalParameters_, |ClassStaticBlockBody|, ~non-lexical-this~, _lex_, _privateScope_). 336 | 1. Perform MakeMethod(_bodyFunction_, _homeObject_). 337 | 1. Return the ClassStaticBlockDefinition Record { [[BodyFunction]]: _bodyFunction_ }. 338 | 339 | The function created for _bodyFunction_ is never directly accessible to ECMAScript code. 340 |
341 |
342 | 343 | 344 |

Runtime Semantics: EvaluateClassStaticBlockBody

345 | 346 |

With parameter _functionObject_.

347 | ClassStaticBlockBody : ClassStaticBlockStatementList 348 | 349 | 1. Perform ? FunctionDeclarationInstantiation(_functionObject_, « »). 350 | 1. Return the result of evaluating |ClassStaticBlockStatementList|. 351 | 352 |
353 |
354 | 355 | 356 |

Runtime Semantics: ClassElementEvaluation

357 |

With parameters _object_ and _enumerable_.

358 | 359 | 360 | ClassElement : FieldDefinition `;` 361 | 362 | ClassElement : `static` FieldDefinition `;` 363 | 364 | 365 | 1. Return ClassFieldDefinitionEvaluation of |FieldDefinition| with argument _object_. 366 | 367 | 368 | 369 | ClassElement : MethodDefinition 370 | 371 | ClassElement : `static` MethodDefinition 372 | 373 | 374 | 1. Return MethodDefinitionEvaluation of |MethodDefinition| with arguments _object_ and _enumerable_. 375 | 376 | 377 | 378 | ClassElement : ClassStaticBlock 379 | 380 | 1. Return ClassStaticBlockDefinitionEvaluation of |ClassStaticBlock| with argument _object_. 381 | 382 | 383 | 384 | 385 | ClassElement : `;` 386 | 387 | 388 | 1. Return. 389 | 390 |
391 | 392 | 393 |

Runtime Semantics: ClassDefinitionEvaluation

394 |

With parameters _classBinding_ and _className_.

395 | 396 |

For ease of specification, private methods and accessors are included alongside private fields in the [[PrivateElements]] slot of class instances. However, any given object has either all or none of the private methods and accessors defined by a given class. This feature has been designed so that implementations may choose to implement private methods and accessors using a strategy which does not require tracking each method or accessor individually.

397 |

For example, an implementation could directly associate instance private methods with their corresponding Private Name and track, for each object, which class constructors have run with that object as their `this` value. Looking up an instance private method on an object then consists of checking that the class constructor which defines the method has been used to initialize the object, then returning the method associated with the Private Name.

398 |

This differs from private fields: because field initializers can throw during class instantiation, an individual object may have some proper subset of the private fields of a given class, and so private fields must in general be tracked individually.

399 |
400 | ClassTail : ClassHeritage? `{` ClassBody? `}` 401 | 402 | 1. Let _env_ be the LexicalEnvironment of the running execution context. 403 | 1. Let _classScope_ be NewDeclarativeEnvironment(_env_). 404 | 1. If _classBinding_ is not *undefined*, then 405 | 1. Perform _classScope_.CreateImmutableBinding(_classBinding_, *true*). 406 | 1. Let _outerPrivateEnvironment_ be the running execution context's PrivateEnvironment. 407 | 1. Let _classPrivateEnvironment_ be NewPrivateEnvironment(_outerPrivateEnvironment_). 408 | 1. If |ClassBody_opt| is present, then 409 | 1. For each String _dn_ of the PrivateBoundIdentifiers of |ClassBody_opt|, do 410 | 1. If _classPrivateEnvironment_.[[Names]] contains a Private Name whose [[Description]] is _dn_, then 411 | 1. Assert: This is only possible for getter/setter pairs. 412 | 1. Else, 413 | 1. Let _name_ be a new Private Name whose [[Description]] value is _dn_. 414 | 1. Append _name_ to _classPrivateEnvironment_.[[Names]]. 415 | 1. If |ClassHeritage_opt| is not present, then 416 | 1. Let _protoParent_ be %Object.prototype%. 417 | 1. Let _constructorParent_ be %Function.prototype%. 418 | 1. Else, 419 | 1. Set the running execution context's LexicalEnvironment to _classScope_. 420 | 1. NOTE: The running execution context's PrivateEnvironment is _outerPrivateEnvironment_ when evaluating |ClassHeritage|. 421 | 1. Let _superclassRef_ be the result of evaluating |ClassHeritage|. 422 | 1. Set the running execution context's LexicalEnvironment to _env_. 423 | 1. Let _superclass_ be ? GetValue(_superclassRef_). 424 | 1. If _superclass_ is *null*, then 425 | 1. Let _protoParent_ be *null*. 426 | 1. Let _constructorParent_ be %Function.prototype%. 427 | 1. Else if IsConstructor(_superclass_) is *false*, throw a *TypeError* exception. 428 | 1. Else, 429 | 1. Let _protoParent_ be ? Get(_superclass_, *"prototype"*). 430 | 1. If Type(_protoParent_) is neither Object nor Null, throw a *TypeError* exception. 431 | 1. Let _constructorParent_ be _superclass_. 432 | 1. Let _proto_ be ! OrdinaryObjectCreate(_protoParent_). 433 | 1. If |ClassBody_opt| is not present, let _constructor_ be ~empty~. 434 | 1. Else, let _constructor_ be ConstructorMethod of |ClassBody|. 435 | 1. Set the running execution context's LexicalEnvironment to _classScope_. 436 | 1. Set the running execution context's PrivateEnvironment to _classPrivateEnvironment_. 437 | 1. If _constructor_ is ~empty~, then 438 | 1. Let _steps_ be the algorithm steps defined in . 439 | 1. Let _F_ be ! CreateBuiltinFunction(_steps_, 0, _className_, « [[ConstructorKind]], [[SourceText]] », ~empty~, _constructorParent_). 440 | 1. Else, 441 | 1. Let _constructorInfo_ be ! DefineMethod of _constructor_ with arguments _proto_ and _constructorParent_. 442 | 1. Let _F_ be _constructorInfo_.[[Closure]]. 443 | 1. Perform ! MakeClassConstructor(_F_). 444 | 1. Perform ! SetFunctionName(_F_, _className_). 445 | 1. Perform ! MakeConstructor(_F_, *false*, _proto_). 446 | 1. If |ClassHeritage_opt| is present, set _F_.[[ConstructorKind]] to ~derived~. 447 | 1. Perform ! CreateMethodProperty(_proto_, *"constructor"*, _F_). 448 | 1. If |ClassBody_opt| is not present, let _elements_ be a new empty List. 449 | 1. Else, let _elements_ be NonConstructorElements of |ClassBody|. 450 | 1. Let _instancePrivateMethods_ be a new empty List. 451 | 1. Let _staticPrivateMethods_ be a new empty List. 452 | 1. Let _instanceFields_ be a new empty List. 453 | 1. Let _staticFields__staticElements_ be a new empty List. 454 | 1. For each |ClassElement| _e_ of _elements_, do 455 | 1. If IsStatic of _e_ is *false*, then 456 | 1. Let _field__element_ be ClassElementEvaluation of _e_ with arguments _proto_ and *false*. 457 | 1. Else, 458 | 1. Let _field__element_ be ClassElementEvaluation of _e_ with arguments _F_ and *false*. 459 | 1. If _field__element_ is an abrupt completion, then 460 | 1. Set the running execution context's LexicalEnvironment to _lex_. 461 | 1. Set the running execution context's PrivateEnvironment to _outerPrivateEnvironment_. 462 | 1. Return Completion(_field__element_). 463 | 1. Set _field__element_ to _field__element_.[[Value]]. 464 | 1. If _field__element_ is a PrivateElement, then 465 | 1. Assert: _field__element_.[[Kind]] is either ~method~ or ~accessor~. 466 | 1. If IsStatic of _e_ is *false*, let _container_ be _instancePrivateMethods_. 467 | 1. Else, let _container_ be _staticPrivateMethods_. 468 | 1. If _container_ contains a PrivateElement whose [[Key]] is _field__element_.[[Key]], then 469 | 1. Let _existing_ be that PrivateElement. 470 | 1. Assert: _field__element_.[[Kind]] and _existing_.[[Kind]] are both ~accessor~. 471 | 1. If _field__element_.[[Get]] is *undefined*, then 472 | 1. Let _combined_ be PrivateElement { [[Key]]: _field__element_.[[Key]], [[Kind]]: ~accessor~, [[Get]]: _existing_.[[Get]], [[Set]]: _field__element_.[[Set]] }. 473 | 1. Else, 474 | 1. Let _combined_ be PrivateElement { [[Key]]: _field__element_.[[Key]], [[Kind]]: ~accessor~, [[Get]]: _field__element_.[[Get]], [[Set]]: _existing_.[[Set]] }. 475 | 1. Replace _existing_ in _container_ with _combined_. 476 | 1. Else, 477 | 1. Append _field__element_ to _container_. 478 | 1. Else if _field__element_ is a ClassFieldDefinition Record, then 479 | 1. If IsStatic of _e_ is *false*, append _field__element_ to _instanceFields_. 480 | 1. Else, append _field__element_ to _staticFields__staticElements_. 481 | 1. If _element_ is a ClassStaticBlockDefinition Record, then 482 | 1. Append _element_ to _staticElements_. 483 | 1. Set the running execution context's LexicalEnvironment to _lex_. 484 | 1. If _classBinding_ is not *undefined*, then 485 | 1. Perform _classScopeEnvRec_.InitializeBinding(_classBinding_, _F_). 486 | 1. Set _F_.[[Fields]] to _instanceFields_. 487 | 1. For each PrivateElement _method_ of _staticPrivateMethods_, do 488 | 1. Perform ! PrivateMethodOrAccessorAdd(_method_, _F_). 489 | 1. For each element _fieldRecord__elementRecord_ of _staticFields__staticElements_, do 490 | 1. Let _result_ be DefineField(_F_, _fieldRecord_). 491 | 1. If _elementRecord_ is a ClassFieldDefinition Record, then 492 | 1. Let _result_ be DefineField(_F_, _elementRecord_). 493 | 1. Else, 494 | 1. Assert: _elementRecord_ is a ClassStaticBlockDefinition Record. 495 | 1. Let _result_ be EvaluateStaticBlock(_F_, _elementRecord_). 496 | 1. If _result_ is an abrupt completion, then 497 | 1. Set the running execution context's PrivateEnvironment to _outerPrivateEnvironment_. 498 | 1. Return _result_. 499 | 1. Set the running execution context's PrivateEnvironment to _outerPrivateEnvironment_. 500 | 1. Return _F_. 501 | 502 |
503 | 504 | 505 |

Runtime Semantics: Evaluation

506 | ClassDeclaration : `class` BindingIdentifier ClassTail 507 | 508 | 1. Perform ? BindingClassDeclarationEvaluation of this |ClassDeclaration|. 509 | 1. Return NormalCompletion(~empty~). 510 | 511 | 512 |

ClassDeclaration : `class` ClassTail only occurs as part of an |ExportDeclaration| and is never directly evaluated.

513 |
514 | ClassExpression : `class` ClassTail 515 | 516 | 1. Let _value_ be ? ClassDefinitionEvaluation of |ClassTail| with arguments *undefined* and *""*. 517 | 1. Set _value_.[[SourceText]] to the source text matched by |ClassExpression|. 518 | 1. Return _value_. 519 | 520 | ClassExpression : `class` BindingIdentifier ClassTail 521 | 522 | 1. Let _className_ be StringValue of |BindingIdentifier|. 523 | 1. Let _value_ be ? ClassDefinitionEvaluation of |ClassTail| with arguments _className_ and _className_. 524 | 1. Set _value_.[[SourceText]] to the source text matched by |ClassExpression|. 525 | 1. Return _value_. 526 | 527 | ClassElementName : PrivateIdentifier 528 | 529 | 1. Let _privateIdentifier_ be StringValue of |PrivateIdentifier|. 530 | 1. Let _privateEnvRec_ be the running execution context's PrivateEnvironment. 531 | 1. Let _names_ be _privateEnvRec_.[[Names]]. 532 | 1. Assert: Exactly one element of _names_ is a Private Name whose [[Description]] is _privateIdentifier_. 533 | 1. Let _privateName_ be the Private Name in _names_ whose [[Description]] is _privateIdentifier_. 534 | 1. Return _privateName_. 535 | 536 | 537 | ClassStaticBlockStatementList : [empty] 538 | 539 | 1. Return NormalCompletion(*undefined*). 540 | 541 | 542 |
543 |
544 | -------------------------------------------------------------------------------- /spec/sec-continue-statement-static-semantics-early-errors-patch.html: -------------------------------------------------------------------------------- 1 | 2 |

Static Semantics: Early Errors

3 | 4 | ContinueStatement : `continue` `;` 5 | 6 | ContinueStatement : `continue` LabelIdentifier `;` 7 | 8 | 13 |
14 | 15 | -------------------------------------------------------------------------------- /spec/sec-ecmascript-specification-types-patch.html: -------------------------------------------------------------------------------- 1 | 2 |

ECMAScript Specification Types

3 | 4 |

ClassStaticBlockDefinition Records

5 | 6 |

A ClassStaticBlockDefinition Record is a Record value used to encapsulate the executable code for a class static initialization block.

7 |

ClassStaticBlockDefinition Records have the fields listed in .

8 | 9 | 10 | 11 | 12 | 15 | 18 | 21 | 22 | 23 | 26 | 29 | 32 | 33 | 34 |
13 | Field Name 14 | 16 | Value 17 | 19 | Meaning 20 |
24 | [[BodyFunction]] 25 | 27 | An function object. 28 | 30 | The function object to be called during static initialization of a class. 31 |
35 |
36 |
37 |
38 |
-------------------------------------------------------------------------------- /spec/sec-introduction.html: -------------------------------------------------------------------------------- 1 |

This proposal defines new syntax to perform privleged static initialization of a class.

2 |

See the proposal repository for background material and discussion.

-------------------------------------------------------------------------------- /spec/sec-operations-on-objects-patch.html: -------------------------------------------------------------------------------- 1 | 2 |

Operations on Objects

3 | 4 |

EvaluateStaticBlock ( _receiver_ , _blockRecord_ )

5 | 6 |

The abstract operation EvaluateStaticBlock takes arguments _receiver_ (an Object) and _blockRecord_ (a ClassStaticBlockDefinition Record). It performs the following steps when called:

7 | 8 | 1. Assert: Type(_receiver_) is Object. 9 | 1. Assert: _blockRecord_ is a ClassStaticBlockDefinition Record. 10 | 1. Perform ? Call(_blockRecord_.[[BodyFunction]], _receiver_). 11 | 12 |
13 |
14 |
-------------------------------------------------------------------------------- /spec/sec-runtime-semantics-evaluatebody-patch.html: -------------------------------------------------------------------------------- 1 | 2 |

Runtime Semantics: EvaluateBody

3 |

With parameters _functionObject_ and _argumentsList_ (a List).

4 | FunctionBody : FunctionStatementList 5 | 6 | 1. Return ? EvaluateFunctionBody of |FunctionBody| with arguments _functionObject_ and _argumentsList_. 7 | 8 | ConciseBody : ExpressionBody 9 | 10 | 1. Return ? EvaluateConciseBody of |ConciseBody| with arguments _functionObject_ and _argumentsList_. 11 | 12 | GeneratorBody : FunctionBody 13 | 14 | 1. Return ? EvaluateGeneratorBody of |GeneratorBody| with arguments _functionObject_ and _argumentsList_. 15 | 16 | 17 | AsyncGeneratorBody : FunctionBody 18 | 19 | 20 | 1. Return ? EvaluateAsyncGeneratorBody of |AsyncGeneratorBody| with arguments _functionObject_ and _argumentsList_. 21 | 22 | 23 | AsyncFunctionBody : FunctionBody 24 | 25 | 26 | 1. Return ? EvaluateAsyncFunctionBody of |AsyncFunctionBody| with arguments _functionObject_ and _argumentsList_. 27 | 28 | 29 | AsyncConciseBody : ExpressionBody 30 | 31 | 32 | 1. Return ? EvaluateAsyncConciseBody of |AsyncConciseBody| with arguments _functionObject_ and _argumentsList_. 33 | 34 | 35 | Initializer : 36 | `=` AssignmentExpression 37 | 38 | 39 | 1. Assert: _argumentsList_ is empty. 40 | 1. Assert: _functionObject_.[[ClassFieldInitializerName]] is not ~empty~. 41 | 1. If IsAnonymousFunctionDefinition(|AssignmentExpression|) is *true*, then 42 | 1. Let _value_ be NamedEvaluation of |Initializer| with argument _functionObject_.[[ClassFieldInitializerName]]. 43 | 1. Else, 44 | 1. Let _rhs_ be the result of evaluating |AssignmentExpression|. 45 | 1. Let _value_ be ? GetValue(_rhs_). 46 | 1. Return Completion { [[Type]]: ~return~, [[Value]]: _value_, [[Target]]: ~empty~ }. 47 | 48 | 49 |

Even though field initializers constitute a function boundary, calling FunctionDeclarationInstantiation does not have any observable effect and so is omitted.

50 |
51 | 52 | 53 | ClassStaticBlockBody : ClassStaticBlockStatementList 54 | 55 | 56 | 1. Assert: _argumentsList_ is empty. 57 | 1. Return ? EvaluateClassStaticBlockBody of |ClassStaticBlockBody| with argument _functionObject_. 58 | 59 | 60 |
61 | -------------------------------------------------------------------------------- /spec/sec-static-semantics-computedpropertycontains-patch.html: -------------------------------------------------------------------------------- 1 | 2 |

Static Semantics: ComputedPropertyContains

3 |

With parameter _symbol_.

4 | PropertyName : LiteralPropertyName 5 | 6 | 1. Return *false*. 7 | 8 | PropertyName : ComputedPropertyName 9 | 10 | 1. Return the result of |ComputedPropertyName| Contains _symbol_. 11 | 12 | 13 | MethodDefinition : 14 | PropertyName `(` UniqueFormalParameters `)` `{` FunctionBody `}` 15 | `get` PropertyName `(` `)` `{` FunctionBody `}` 16 | `set` PropertyName `(` PropertySetParameterList `)` `{` FunctionBody `}` 17 | 18 | 19 | 1. Return the result of ComputedPropertyContains for |PropertyName| with argument _symbol_. 20 | 21 | GeneratorMethod : `*` PropertyName `(` UniqueFormalParameters `)` `{` GeneratorBody `}` 22 | 23 | 1. Return the result of ComputedPropertyContains for |PropertyName| with argument _symbol_. 24 | 25 | AsyncGeneratorMethod : `async` `*` PropertyName `(` UniqueFormalParameters `)` `{` AsyncGeneratorBody `}` 26 | 27 | 1. Return the result of ComputedPropertyContains for |PropertyName| with argument _symbol_. 28 | 29 | ClassElementList : ClassElementList ClassElement 30 | 31 | 1. Let _inList_ be ComputedPropertyContains of |ClassElementList| with argument _symbol_. 32 | 1. If _inList_ is *true*, return *true*. 33 | 1. Return the result of ComputedPropertyContains for |ClassElement| with argument _symbol_. 34 | 35 | 36 | ClassElement : ClassStaticBlock 37 | 38 | 1. Return *false*. 39 | 40 | 41 | ClassElement : `;` 42 | 43 | 1. Return *false*. 44 | 45 | 46 | AsyncMethod : `async` PropertyName `(` UniqueFormalParameters `)` `{` AsyncFunctionBody `}` 47 | 48 | 49 | 1. Return the result of ComputedPropertyContains for |PropertyName| with argument _symbol_. 50 | 51 |
52 | -------------------------------------------------------------------------------- /spec/sec-static-semantics-contains-patch.html: -------------------------------------------------------------------------------- 1 | 2 |

Static Semantics: Contains

3 |

With parameter _symbol_.

4 |

Every grammar production alternative in this specification which is not listed below implicitly has the following default definition of Contains:

5 | 6 | 1. For each child node _child_ of this Parse Node, do 7 | 1. If _child_ is an instance of _symbol_, return *true*. 8 | 1. If _child_ is an instance of a nonterminal, then 9 | 1. Let _contained_ be the result of _child_ Contains _symbol_. 10 | 1. If _contained_ is *true*, return *true*. 11 | 1. Return *false*. 12 | 13 | 14 | FunctionDeclaration : 15 | `function` BindingIdentifier `(` FormalParameters `)` `{` FunctionBody `}` 16 | `function` `(` FormalParameters `)` `{` FunctionBody `}` 17 | 18 | FunctionExpression : 19 | `function` BindingIdentifier? `(` FormalParameters `)` `{` FunctionBody `}` 20 | 21 | GeneratorDeclaration : 22 | `function` `*` BindingIdentifier `(` FormalParameters `)` `{` GeneratorBody `}` 23 | `function` `*` `(` FormalParameters `)` `{` GeneratorBody `}` 24 | 25 | GeneratorExpression : 26 | `function` `*` BindingIdentifier? `(` FormalParameters `)` `{` GeneratorBody `}` 27 | 28 | AsyncGeneratorDeclaration : 29 | `async` `function` `*` BindingIdentifier `(` FormalParameters `)` `{` AsyncGeneratorBody `}` 30 | `async` `function` `*` `(` FormalParameters `)` `{` AsyncGeneratorBody `}` 31 | 32 | AsyncGeneratorExpression : 33 | `async` `function` `*` BindingIdentifier? `(` FormalParameters `)` `{` AsyncGeneratorBody `}` 34 | 35 | AsyncFunctionDeclaration : 36 | `async` `function` BindingIdentifier `(` FormalParameters `)` `{` AsyncFunctionBody `}` 37 | `async` `function` `(` FormalParameters `)` `{` AsyncFunctionBody `}` 38 | 39 | AsyncFunctionExpression : 40 | `async` `function` BindingIdentifier? `(` FormalParameters `)` `{` AsyncFunctionBody `}` 41 | 42 | 43 | 1. Return *false*. 44 | 45 | 46 |

Static semantic rules that depend upon substructure generally do not look into function definitions.

47 |
48 | ClassTail : ClassHeritage? `{` ClassBody `}` 49 | 50 | 1. If _symbol_ is |ClassBody|, return *true*. 51 | 1. If _symbol_ is |ClassHeritage|, then 52 | 1. If |ClassHeritage| is present, return *true*; otherwise return *false*. 53 | 1. Let _inHeritage_ be |ClassHeritage| Contains _symbol_. 54 | 1. If _inHeritage_ is *true*, return *true*. 55 | 1. Return the result of ComputedPropertyContains for |ClassBody| with argument _symbol_. 56 | 57 | 58 |

Static semantic rules that depend upon substructure generally do not look into class bodies except for |PropertyName|s.

59 |
60 | 61 | 62 | ClassStaticBlock : `static` `{` ClassStaticBlockBody `}` 63 | 64 | 1. Return *false*. 65 | 66 | 67 |

Static semantic rules that depend upon substructure generally do not look into `static` initialization blocks.

68 |
69 |
70 | 71 | ArrowFunction : ArrowParameters `=>` ConciseBody 72 | 73 | 1. If _symbol_ is not one of |NewTarget|, |SuperProperty|, |SuperCall|, `super` or `this`, return *false*. 74 | 1. If |ArrowParameters| Contains _symbol_ is *true*, return *true*. 75 | 1. Return |ConciseBody| Contains _symbol_. 76 | 77 | ArrowParameters : CoverParenthesizedExpressionAndArrowParameterList 78 | 79 | 1. Let _formals_ be CoveredFormalsList of |CoverParenthesizedExpressionAndArrowParameterList|. 80 | 1. Return _formals_ Contains _symbol_. 81 | 82 | 83 | AsyncArrowFunction : `async` AsyncArrowBindingIdentifier `=>` AsyncConciseBody 84 | 85 | 86 | 1. If _symbol_ is not one of |NewTarget|, |SuperProperty|, |SuperCall|, `super`, or `this`, return *false*. 87 | 1. Return |AsyncConciseBody| Contains _symbol_. 88 | 89 | 90 | AsyncArrowFunction : CoverCallExpressionAndAsyncArrowHead `=>` AsyncConciseBody 91 | 92 | 93 | 1. If _symbol_ is not one of |NewTarget|, |SuperProperty|, |SuperCall|, `super`, or `this`, return *false*. 94 | 1. Let _head_ be CoveredAsyncArrowHead of |CoverCallExpressionAndAsyncArrowHead|. 95 | 1. If _head_ Contains _symbol_ is *true*, return *true*. 96 | 1. Return |AsyncConciseBody| Contains _symbol_. 97 | 98 | 99 |

Contains is used to detect `new.target`, `this`, and `super` usage within an |ArrowFunction| or |AsyncArrowFunction|.

100 |
101 | PropertyDefinition : MethodDefinition 102 | 103 | 1. If _symbol_ is |MethodDefinition|, return *true*. 104 | 1. Return the result of ComputedPropertyContains for |MethodDefinition| with argument _symbol_. 105 | 106 | LiteralPropertyName : IdentifierName 107 | 108 | 1. Return *false*. 109 | 110 | MemberExpression : MemberExpression `.` IdentifierName 111 | 112 | 1. If |MemberExpression| Contains _symbol_ is *true*, return *true*. 113 | 1. Return *false*. 114 | 115 | SuperProperty : `super` `.` IdentifierName 116 | 117 | 1. If _symbol_ is the |ReservedWord| `super`, return *true*. 118 | 1. Return *false*. 119 | 120 | CallExpression : CallExpression `.` IdentifierName 121 | 122 | 1. If |CallExpression| Contains _symbol_ is *true*, return *true*. 123 | 1. Return *false*. 124 | 125 | OptionalChain : `?.` IdentifierName 126 | 127 | 1. Return *false*. 128 | 129 | OptionalChain : OptionalChain `.` IdentifierName 130 | 131 | 1. If |OptionalChain| Contains _symbol_ is *true*, return *true*. 132 | 1. Return *false*. 133 | 134 |
135 | -------------------------------------------------------------------------------- /spec/sec-static-semantics-containsduplicatelabels-patch.html: -------------------------------------------------------------------------------- 1 | 2 |

Static Semantics: ContainsDuplicateLabels

3 |

With parameter _labelSet_.

4 | 5 | Statement : 6 | VariableStatement 7 | EmptyStatement 8 | ExpressionStatement 9 | ContinueStatement 10 | BreakStatement 11 | ReturnStatement 12 | ThrowStatement 13 | DebuggerStatement 14 | 15 | Block : `{` `}` 16 | 17 | StatementListItem : Declaration 18 | 19 | 20 | 1. Return *false*. 21 | 22 | StatementList : StatementList StatementListItem 23 | 24 | 1. Let _hasDuplicates_ be ContainsDuplicateLabels of |StatementList| with argument _labelSet_. 25 | 1. If _hasDuplicates_ is *true*, return *true*. 26 | 1. Return ContainsDuplicateLabels of |StatementListItem| with argument _labelSet_. 27 | 28 | IfStatement : `if` `(` Expression `)` Statement `else` Statement 29 | 30 | 1. Let _hasDuplicate_ be ContainsDuplicateLabels of the first |Statement| with argument _labelSet_. 31 | 1. If _hasDuplicate_ is *true*, return *true*. 32 | 1. Return ContainsDuplicateLabels of the second |Statement| with argument _labelSet_. 33 | 34 | IfStatement : `if` `(` Expression `)` Statement 35 | 36 | 1. Return ContainsDuplicateLabels of |Statement| with argument _labelSet_. 37 | 38 | DoWhileStatement : `do` Statement `while` `(` Expression `)` `;` 39 | 40 | 1. Return ContainsDuplicateLabels of |Statement| with argument _labelSet_. 41 | 42 | WhileStatement : `while` `(` Expression `)` Statement 43 | 44 | 1. Return ContainsDuplicateLabels of |Statement| with argument _labelSet_. 45 | 46 | 47 | ForStatement : 48 | `for` `(` Expression? `;` Expression? `;` Expression? `)` Statement 49 | `for` `(` `var` VariableDeclarationList `;` Expression? `;` Expression? `)` Statement 50 | `for` `(` LexicalDeclaration Expression? `;` Expression? `)` Statement 51 | 52 | 53 | 1. Return ContainsDuplicateLabels of |Statement| with argument _labelSet_. 54 | 55 | 56 | ForInOfStatement : 57 | `for` `(` LeftHandSideExpression `in` Expression `)` Statement 58 | `for` `(` `var` ForBinding `in` Expression `)` Statement 59 | `for` `(` ForDeclaration `in` Expression `)` Statement 60 | `for` `(` LeftHandSideExpression `of` AssignmentExpression `)` Statement 61 | `for` `(` `var` ForBinding `of` AssignmentExpression `)` Statement 62 | `for` `(` ForDeclaration `of` AssignmentExpression `)` Statement 63 | `for` `await` `(` LeftHandSideExpression `of` AssignmentExpression `)` Statement 64 | `for` `await` `(` `var` ForBinding `of` AssignmentExpression `)` Statement 65 | `for` `await` `(` ForDeclaration `of` AssignmentExpression `)` Statement 66 | 67 | 68 | 1. Return ContainsDuplicateLabels of |Statement| with argument _labelSet_. 69 | 70 | 71 |

This section is extended by Annex .

72 |
73 | WithStatement : `with` `(` Expression `)` Statement 74 | 75 | 1. Return ContainsDuplicateLabels of |Statement| with argument _labelSet_. 76 | 77 | SwitchStatement : `switch` `(` Expression `)` CaseBlock 78 | 79 | 1. Return ContainsDuplicateLabels of |CaseBlock| with argument _labelSet_. 80 | 81 | CaseBlock : `{` `}` 82 | 83 | 1. Return *false*. 84 | 85 | CaseBlock : `{` CaseClauses? DefaultClause CaseClauses? `}` 86 | 87 | 1. If the first |CaseClauses| is present, then 88 | 1. Let _hasDuplicates_ be ContainsDuplicateLabels of the first |CaseClauses| with argument _labelSet_. 89 | 1. If _hasDuplicates_ is *true*, return *true*. 90 | 1. Let _hasDuplicates_ be ContainsDuplicateLabels of |DefaultClause| with argument _labelSet_. 91 | 1. If _hasDuplicates_ is *true*, return *true*. 92 | 1. If the second |CaseClauses| is not present, return *false*. 93 | 1. Return ContainsDuplicateLabels of the second |CaseClauses| with argument _labelSet_. 94 | 95 | CaseClauses : CaseClauses CaseClause 96 | 97 | 1. Let _hasDuplicates_ be ContainsDuplicateLabels of |CaseClauses| with argument _labelSet_. 98 | 1. If _hasDuplicates_ is *true*, return *true*. 99 | 1. Return ContainsDuplicateLabels of |CaseClause| with argument _labelSet_. 100 | 101 | CaseClause : `case` Expression `:` StatementList? 102 | 103 | 1. If the |StatementList| is present, return ContainsDuplicateLabels of |StatementList| with argument _labelSet_. 104 | 1. Return *false*. 105 | 106 | DefaultClause : `default` `:` StatementList? 107 | 108 | 1. If the |StatementList| is present, return ContainsDuplicateLabels of |StatementList| with argument _labelSet_. 109 | 1. Return *false*. 110 | 111 | LabelledStatement : LabelIdentifier `:` LabelledItem 112 | 113 | 1. Let _label_ be the StringValue of |LabelIdentifier|. 114 | 1. If _label_ is an element of _labelSet_, return *true*. 115 | 1. Let _newLabelSet_ be a copy of _labelSet_ with _label_ appended. 116 | 1. Return ContainsDuplicateLabels of |LabelledItem| with argument _newLabelSet_. 117 | 118 | LabelledItem : FunctionDeclaration 119 | 120 | 1. Return *false*. 121 | 122 | TryStatement : `try` Block Catch 123 | 124 | 1. Let _hasDuplicates_ be ContainsDuplicateLabels of |Block| with argument _labelSet_. 125 | 1. If _hasDuplicates_ is *true*, return *true*. 126 | 1. Return ContainsDuplicateLabels of |Catch| with argument _labelSet_. 127 | 128 | TryStatement : `try` Block Finally 129 | 130 | 1. Let _hasDuplicates_ be ContainsDuplicateLabels of |Block| with argument _labelSet_. 131 | 1. If _hasDuplicates_ is *true*, return *true*. 132 | 1. Return ContainsDuplicateLabels of |Finally| with argument _labelSet_. 133 | 134 | TryStatement : `try` Block Catch Finally 135 | 136 | 1. Let _hasDuplicates_ be ContainsDuplicateLabels of |Block| with argument _labelSet_. 137 | 1. If _hasDuplicates_ is *true*, return *true*. 138 | 1. Let _hasDuplicates_ be ContainsDuplicateLabels of |Catch| with argument _labelSet_. 139 | 1. If _hasDuplicates_ is *true*, return *true*. 140 | 1. Return ContainsDuplicateLabels of |Finally| with argument _labelSet_. 141 | 142 | Catch : `catch` `(` CatchParameter `)` Block 143 | 144 | 1. Return ContainsDuplicateLabels of |Block| with argument _labelSet_. 145 | 146 | FunctionStatementList : [empty] 147 | 148 | 1. Return *false*. 149 | 150 | 151 | ClassStaticBlockStatementList : [empty] 152 | 153 | 1. Return *false*. 154 | 155 | 156 | ModuleItemList : ModuleItemList ModuleItem 157 | 158 | 1. Let _hasDuplicates_ be ContainsDuplicateLabels of |ModuleItemList| with argument _labelSet_. 159 | 1. If _hasDuplicates_ is *true*, return *true*. 160 | 1. Return ContainsDuplicateLabels of |ModuleItem| with argument _labelSet_. 161 | 162 | 163 | ModuleItem : 164 | ImportDeclaration 165 | ExportDeclaration 166 | 167 | 168 | 1. Return *false*. 169 | 170 |
171 | -------------------------------------------------------------------------------- /spec/sec-static-semantics-containsundefinedbreaktarget-patch.html: -------------------------------------------------------------------------------- 1 | 2 |

Static Semantics: ContainsUndefinedBreakTarget

3 |

With parameter _labelSet_.

4 | 5 | Statement : 6 | VariableStatement 7 | EmptyStatement 8 | ExpressionStatement 9 | ContinueStatement 10 | ReturnStatement 11 | ThrowStatement 12 | DebuggerStatement 13 | 14 | Block : `{` `}` 15 | 16 | StatementListItem : Declaration 17 | 18 | 19 | 1. Return *false*. 20 | 21 | StatementList : StatementList StatementListItem 22 | 23 | 1. Let _hasUndefinedLabels_ be ContainsUndefinedBreakTarget of |StatementList| with argument _labelSet_. 24 | 1. If _hasUndefinedLabels_ is *true*, return *true*. 25 | 1. Return ContainsUndefinedBreakTarget of |StatementListItem| with argument _labelSet_. 26 | 27 | IfStatement : `if` `(` Expression `)` Statement `else` Statement 28 | 29 | 1. Let _hasUndefinedLabels_ be ContainsUndefinedBreakTarget of the first |Statement| with argument _labelSet_. 30 | 1. If _hasUndefinedLabels_ is *true*, return *true*. 31 | 1. Return ContainsUndefinedBreakTarget of the second |Statement| with argument _labelSet_. 32 | 33 | IfStatement : `if` `(` Expression `)` Statement 34 | 35 | 1. Return ContainsUndefinedBreakTarget of |Statement| with argument _labelSet_. 36 | 37 | DoWhileStatement : `do` Statement `while` `(` Expression `)` `;` 38 | 39 | 1. Return ContainsUndefinedBreakTarget of |Statement| with argument _labelSet_. 40 | 41 | WhileStatement : `while` `(` Expression `)` Statement 42 | 43 | 1. Return ContainsUndefinedBreakTarget of |Statement| with argument _labelSet_. 44 | 45 | 46 | ForStatement : 47 | `for` `(` Expression? `;` Expression? `;` Expression? `)` Statement 48 | `for` `(` `var` VariableDeclarationList `;` Expression? `;` Expression? `)` Statement 49 | `for` `(` LexicalDeclaration Expression? `;` Expression? `)` Statement 50 | 51 | 52 | 1. Return ContainsUndefinedBreakTarget of |Statement| with argument _labelSet_. 53 | 54 | 55 | ForInOfStatement : 56 | `for` `(` LeftHandSideExpression `in` Expression `)` Statement 57 | `for` `(` `var` ForBinding `in` Expression `)` Statement 58 | `for` `(` ForDeclaration `in` Expression `)` Statement 59 | `for` `(` LeftHandSideExpression `of` AssignmentExpression `)` Statement 60 | `for` `(` `var` ForBinding `of` AssignmentExpression `)` Statement 61 | `for` `(` ForDeclaration `of` AssignmentExpression `)` Statement 62 | `for` `await` `(` LeftHandSideExpression `of` AssignmentExpression `)` Statement 63 | `for` `await` `(` `var` ForBinding `of` AssignmentExpression `)` Statement 64 | `for` `await` `(` ForDeclaration `of` AssignmentExpression `)` Statement 65 | 66 | 67 | 1. Return ContainsUndefinedBreakTarget of |Statement| with argument _labelSet_. 68 | 69 | 70 |

This section is extended by Annex .

71 |
72 | BreakStatement : `break` `;` 73 | 74 | 1. Return *false*. 75 | 76 | BreakStatement : `break` LabelIdentifier `;` 77 | 78 | 1. If the StringValue of |LabelIdentifier| is not an element of _labelSet_, return *true*. 79 | 1. Return *false*. 80 | 81 | WithStatement : `with` `(` Expression `)` Statement 82 | 83 | 1. Return ContainsUndefinedBreakTarget of |Statement| with argument _labelSet_. 84 | 85 | SwitchStatement : `switch` `(` Expression `)` CaseBlock 86 | 87 | 1. Return ContainsUndefinedBreakTarget of |CaseBlock| with argument _labelSet_. 88 | 89 | CaseBlock : `{` `}` 90 | 91 | 1. Return *false*. 92 | 93 | CaseBlock : `{` CaseClauses? DefaultClause CaseClauses? `}` 94 | 95 | 1. If the first |CaseClauses| is present, then 96 | 1. Let _hasUndefinedLabels_ be ContainsUndefinedBreakTarget of the first |CaseClauses| with argument _labelSet_. 97 | 1. If _hasUndefinedLabels_ is *true*, return *true*. 98 | 1. Let _hasUndefinedLabels_ be ContainsUndefinedBreakTarget of |DefaultClause| with argument _labelSet_. 99 | 1. If _hasUndefinedLabels_ is *true*, return *true*. 100 | 1. If the second |CaseClauses| is not present, return *false*. 101 | 1. Return ContainsUndefinedBreakTarget of the second |CaseClauses| with argument _labelSet_. 102 | 103 | CaseClauses : CaseClauses CaseClause 104 | 105 | 1. Let _hasUndefinedLabels_ be ContainsUndefinedBreakTarget of |CaseClauses| with argument _labelSet_. 106 | 1. If _hasUndefinedLabels_ is *true*, return *true*. 107 | 1. Return ContainsUndefinedBreakTarget of |CaseClause| with argument _labelSet_. 108 | 109 | CaseClause : `case` Expression `:` StatementList? 110 | 111 | 1. If the |StatementList| is present, return ContainsUndefinedBreakTarget of |StatementList| with argument _labelSet_. 112 | 1. Return *false*. 113 | 114 | DefaultClause : `default` `:` StatementList? 115 | 116 | 1. If the |StatementList| is present, return ContainsUndefinedBreakTarget of |StatementList| with argument _labelSet_. 117 | 1. Return *false*. 118 | 119 | LabelledStatement : LabelIdentifier `:` LabelledItem 120 | 121 | 1. Let _label_ be the StringValue of |LabelIdentifier|. 122 | 1. Let _newLabelSet_ be a copy of _labelSet_ with _label_ appended. 123 | 1. Return ContainsUndefinedBreakTarget of |LabelledItem| with argument _newLabelSet_. 124 | 125 | LabelledItem : FunctionDeclaration 126 | 127 | 1. Return *false*. 128 | 129 | TryStatement : `try` Block Catch 130 | 131 | 1. Let _hasUndefinedLabels_ be ContainsUndefinedBreakTarget of |Block| with argument _labelSet_. 132 | 1. If _hasUndefinedLabels_ is *true*, return *true*. 133 | 1. Return ContainsUndefinedBreakTarget of |Catch| with argument _labelSet_. 134 | 135 | TryStatement : `try` Block Finally 136 | 137 | 1. Let _hasUndefinedLabels_ be ContainsUndefinedBreakTarget of |Block| with argument _labelSet_. 138 | 1. If _hasUndefinedLabels_ is *true*, return *true*. 139 | 1. Return ContainsUndefinedBreakTarget of |Finally| with argument _labelSet_. 140 | 141 | TryStatement : `try` Block Catch Finally 142 | 143 | 1. Let _hasUndefinedLabels_ be ContainsUndefinedBreakTarget of |Block| with argument _labelSet_. 144 | 1. If _hasUndefinedLabels_ is *true*, return *true*. 145 | 1. Let _hasUndefinedLabels_ be ContainsUndefinedBreakTarget of |Catch| with argument _labelSet_. 146 | 1. If _hasUndefinedLabels_ is *true*, return *true*. 147 | 1. Return ContainsUndefinedBreakTarget of |Finally| with argument _labelSet_. 148 | 149 | Catch : `catch` `(` CatchParameter `)` Block 150 | 151 | 1. Return ContainsUndefinedBreakTarget of |Block| with argument _labelSet_. 152 | 153 | FunctionStatementList : [empty] 154 | 155 | 1. Return *false*. 156 | 157 | 158 | ClassStaticBlockStatementList : [empty] 159 | 160 | 1. Return *false*. 161 | 162 | 163 | ModuleItemList : ModuleItemList ModuleItem 164 | 165 | 1. Let _hasUndefinedLabels_ be ContainsUndefinedBreakTarget of |ModuleItemList| with argument _labelSet_. 166 | 1. If _hasUndefinedLabels_ is *true*, return *true*. 167 | 1. Return ContainsUndefinedBreakTarget of |ModuleItem| with argument _labelSet_. 168 | 169 | 170 | ModuleItem : 171 | ImportDeclaration 172 | ExportDeclaration 173 | 174 | 175 | 1. Return *false*. 176 | 177 |
178 | -------------------------------------------------------------------------------- /spec/sec-static-semantics-containsundefinedcontinuetarget-patch.html: -------------------------------------------------------------------------------- 1 | 2 |

Static Semantics: ContainsUndefinedContinueTarget

3 |

With parameters _iterationSet_ and _labelSet_.

4 | 5 | Statement : 6 | VariableStatement 7 | EmptyStatement 8 | ExpressionStatement 9 | BreakStatement 10 | ReturnStatement 11 | ThrowStatement 12 | DebuggerStatement 13 | 14 | Block : `{` `}` 15 | 16 | StatementListItem : Declaration 17 | 18 | 19 | 1. Return *false*. 20 | 21 | BreakableStatement : IterationStatement 22 | 23 | 1. Let _newIterationSet_ be a copy of _iterationSet_ with all the elements of _labelSet_ appended. 24 | 1. Return ContainsUndefinedContinueTarget of |IterationStatement| with arguments _newIterationSet_ and « ». 25 | 26 | StatementList : StatementList StatementListItem 27 | 28 | 1. Let _hasUndefinedLabels_ be ContainsUndefinedContinueTarget of |StatementList| with arguments _iterationSet_ and « ». 29 | 1. If _hasUndefinedLabels_ is *true*, return *true*. 30 | 1. Return ContainsUndefinedContinueTarget of |StatementListItem| with arguments _iterationSet_ and « ». 31 | 32 | IfStatement : `if` `(` Expression `)` Statement `else` Statement 33 | 34 | 1. Let _hasUndefinedLabels_ be ContainsUndefinedContinueTarget of the first |Statement| with arguments _iterationSet_ and « ». 35 | 1. If _hasUndefinedLabels_ is *true*, return *true*. 36 | 1. Return ContainsUndefinedContinueTarget of the second |Statement| with arguments _iterationSet_ and « ». 37 | 38 | IfStatement : `if` `(` Expression `)` Statement 39 | 40 | 1. Return ContainsUndefinedContinueTarget of |Statement| with arguments _iterationSet_ and « ». 41 | 42 | DoWhileStatement : `do` Statement `while` `(` Expression `)` `;` 43 | 44 | 1. Return ContainsUndefinedContinueTarget of |Statement| with arguments _iterationSet_ and « ». 45 | 46 | WhileStatement : `while` `(` Expression `)` Statement 47 | 48 | 1. Return ContainsUndefinedContinueTarget of |Statement| with arguments _iterationSet_ and « ». 49 | 50 | 51 | ForStatement : 52 | `for` `(` Expression? `;` Expression? `;` Expression? `)` Statement 53 | `for` `(` `var` VariableDeclarationList `;` Expression? `;` Expression? `)` Statement 54 | `for` `(` LexicalDeclaration Expression? `;` Expression? `)` Statement 55 | 56 | 57 | 1. Return ContainsUndefinedContinueTarget of |Statement| with arguments _iterationSet_ and « ». 58 | 59 | 60 | ForInOfStatement : 61 | `for` `(` LeftHandSideExpression `in` Expression `)` Statement 62 | `for` `(` `var` ForBinding `in` Expression `)` Statement 63 | `for` `(` ForDeclaration `in` Expression `)` Statement 64 | `for` `(` LeftHandSideExpression `of` AssignmentExpression `)` Statement 65 | `for` `(` `var` ForBinding `of` AssignmentExpression `)` Statement 66 | `for` `(` ForDeclaration `of` AssignmentExpression `)` Statement 67 | `for` `await` `(` LeftHandSideExpression `of` AssignmentExpression `)` Statement 68 | `for` `await` `(` `var` ForBinding `of` AssignmentExpression `)` Statement 69 | `for` `await` `(` ForDeclaration `of` AssignmentExpression `)` Statement 70 | 71 | 72 | 1. Return ContainsUndefinedContinueTarget of |Statement| with arguments _iterationSet_ and « ». 73 | 74 | 75 |

This section is extended by Annex .

76 |
77 | ContinueStatement : `continue` `;` 78 | 79 | 1. Return *false*. 80 | 81 | ContinueStatement : `continue` LabelIdentifier `;` 82 | 83 | 1. If the StringValue of |LabelIdentifier| is not an element of _iterationSet_, return *true*. 84 | 1. Return *false*. 85 | 86 | WithStatement : `with` `(` Expression `)` Statement 87 | 88 | 1. Return ContainsUndefinedContinueTarget of |Statement| with arguments _iterationSet_ and « ». 89 | 90 | SwitchStatement : `switch` `(` Expression `)` CaseBlock 91 | 92 | 1. Return ContainsUndefinedContinueTarget of |CaseBlock| with arguments _iterationSet_ and « ». 93 | 94 | CaseBlock : `{` `}` 95 | 96 | 1. Return *false*. 97 | 98 | CaseBlock : `{` CaseClauses? DefaultClause CaseClauses? `}` 99 | 100 | 1. If the first |CaseClauses| is present, then 101 | 1. Let _hasUndefinedLabels_ be ContainsUndefinedContinueTarget of the first |CaseClauses| with arguments _iterationSet_ and « ». 102 | 1. If _hasUndefinedLabels_ is *true*, return *true*. 103 | 1. Let _hasUndefinedLabels_ be ContainsUndefinedContinueTarget of |DefaultClause| with arguments _iterationSet_ and « ». 104 | 1. If _hasUndefinedLabels_ is *true*, return *true*. 105 | 1. If the second |CaseClauses| is not present, return *false*. 106 | 1. Return ContainsUndefinedContinueTarget of the second |CaseClauses| with arguments _iterationSet_ and « ». 107 | 108 | CaseClauses : CaseClauses CaseClause 109 | 110 | 1. Let _hasUndefinedLabels_ be ContainsUndefinedContinueTarget of |CaseClauses| with arguments _iterationSet_ and « ». 111 | 1. If _hasUndefinedLabels_ is *true*, return *true*. 112 | 1. Return ContainsUndefinedContinueTarget of |CaseClause| with arguments _iterationSet_ and « ». 113 | 114 | CaseClause : `case` Expression `:` StatementList? 115 | 116 | 1. If the |StatementList| is present, return ContainsUndefinedContinueTarget of |StatementList| with arguments _iterationSet_ and « ». 117 | 1. Return *false*. 118 | 119 | DefaultClause : `default` `:` StatementList? 120 | 121 | 1. If the |StatementList| is present, return ContainsUndefinedContinueTarget of |StatementList| with arguments _iterationSet_ and « ». 122 | 1. Return *false*. 123 | 124 | LabelledStatement : LabelIdentifier `:` LabelledItem 125 | 126 | 1. Let _label_ be the StringValue of |LabelIdentifier|. 127 | 1. Let _newLabelSet_ be a copy of _labelSet_ with _label_ appended. 128 | 1. Return ContainsUndefinedContinueTarget of |LabelledItem| with arguments _iterationSet_ and _newLabelSet_. 129 | 130 | LabelledItem : FunctionDeclaration 131 | 132 | 1. Return *false*. 133 | 134 | TryStatement : `try` Block Catch 135 | 136 | 1. Let _hasUndefinedLabels_ be ContainsUndefinedContinueTarget of |Block| with arguments _iterationSet_ and « ». 137 | 1. If _hasUndefinedLabels_ is *true*, return *true*. 138 | 1. Return ContainsUndefinedContinueTarget of |Catch| with arguments _iterationSet_ and « ». 139 | 140 | TryStatement : `try` Block Finally 141 | 142 | 1. Let _hasUndefinedLabels_ be ContainsUndefinedContinueTarget of |Block| with arguments _iterationSet_ and « ». 143 | 1. If _hasUndefinedLabels_ is *true*, return *true*. 144 | 1. Return ContainsUndefinedContinueTarget of |Finally| with arguments _iterationSet_ and « ». 145 | 146 | TryStatement : `try` Block Catch Finally 147 | 148 | 1. Let _hasUndefinedLabels_ be ContainsUndefinedContinueTarget of |Block| with arguments _iterationSet_ and « ». 149 | 1. If _hasUndefinedLabels_ is *true*, return *true*. 150 | 1. Let _hasUndefinedLabels_ be ContainsUndefinedContinueTarget of |Catch| with arguments _iterationSet_ and « ». 151 | 1. If _hasUndefinedLabels_ is *true*, return *true*. 152 | 1. Return ContainsUndefinedContinueTarget of |Finally| with arguments _iterationSet_ and « ». 153 | 154 | Catch : `catch` `(` CatchParameter `)` Block 155 | 156 | 1. Return ContainsUndefinedContinueTarget of |Block| with arguments _iterationSet_ and « ». 157 | 158 | FunctionStatementList : [empty] 159 | 160 | 1. Return *false*. 161 | 162 | 163 | ClassStaticBlockStatementList : [empty] 164 | 165 | 1. Return *false*. 166 | 167 | 168 | ModuleItemList : ModuleItemList ModuleItem 169 | 170 | 1. Let _hasUndefinedLabels_ be ContainsUndefinedContinueTarget of |ModuleItemList| with arguments _iterationSet_ and « ». 171 | 1. If _hasUndefinedLabels_ is *true*, return *true*. 172 | 1. Return ContainsUndefinedContinueTarget of |ModuleItem| with arguments _iterationSet_ and « ». 173 | 174 | 175 | ModuleItem : 176 | ImportDeclaration 177 | ExportDeclaration 178 | 179 | 180 | 1. Return *false*. 181 | 182 |
183 | -------------------------------------------------------------------------------- /spec/sec-static-semantics-lexicallydeclarednames-patch.html: -------------------------------------------------------------------------------- 1 | 2 |

Static Semantics: LexicallyDeclaredNames

3 | Block : `{` `}` 4 | 5 | 1. Return a new empty List. 6 | 7 | StatementList : StatementList StatementListItem 8 | 9 | 1. Let _names_ be LexicallyDeclaredNames of |StatementList|. 10 | 1. Append to _names_ the elements of the LexicallyDeclaredNames of |StatementListItem|. 11 | 1. Return _names_. 12 | 13 | StatementListItem : Statement 14 | 15 | 1. If |Statement| is Statement : LabelledStatement , return LexicallyDeclaredNames of |LabelledStatement|. 16 | 1. Return a new empty List. 17 | 18 | StatementListItem : Declaration 19 | 20 | 1. Return the BoundNames of |Declaration|. 21 | 22 | CaseBlock : `{` `}` 23 | 24 | 1. Return a new empty List. 25 | 26 | CaseBlock : `{` CaseClauses? DefaultClause CaseClauses? `}` 27 | 28 | 1. If the first |CaseClauses| is present, let _names_ be the LexicallyDeclaredNames of the first |CaseClauses|. 29 | 1. Else, let _names_ be a new empty List. 30 | 1. Append to _names_ the elements of the LexicallyDeclaredNames of |DefaultClause|. 31 | 1. If the second |CaseClauses| is not present, return _names_. 32 | 1. Return the result of appending to _names_ the elements of the LexicallyDeclaredNames of the second |CaseClauses|. 33 | 34 | CaseClauses : CaseClauses CaseClause 35 | 36 | 1. Let _names_ be LexicallyDeclaredNames of |CaseClauses|. 37 | 1. Append to _names_ the elements of the LexicallyDeclaredNames of |CaseClause|. 38 | 1. Return _names_. 39 | 40 | CaseClause : `case` Expression `:` StatementList? 41 | 42 | 1. If the |StatementList| is present, return the LexicallyDeclaredNames of |StatementList|. 43 | 1. Return a new empty List. 44 | 45 | DefaultClause : `default` `:` StatementList? 46 | 47 | 1. If the |StatementList| is present, return the LexicallyDeclaredNames of |StatementList|. 48 | 1. Return a new empty List. 49 | 50 | LabelledStatement : LabelIdentifier `:` LabelledItem 51 | 52 | 1. Return the LexicallyDeclaredNames of |LabelledItem|. 53 | 54 | LabelledItem : Statement 55 | 56 | 1. Return a new empty List. 57 | 58 | LabelledItem : FunctionDeclaration 59 | 60 | 1. Return BoundNames of |FunctionDeclaration|. 61 | 62 | FunctionStatementList : [empty] 63 | 64 | 1. Return a new empty List. 65 | 66 | FunctionStatementList : StatementList 67 | 68 | 1. Return TopLevelLexicallyDeclaredNames of |StatementList|. 69 | 70 | 71 | ClassStaticBlockStatementList : [empty] 72 | 73 | 1. Return a new empty List. 74 | 75 | ClassStaticBlockStatementList : StatementList 76 | 77 | 1. Return the TopLevelLexicallyDeclaredNames of |StatementList|. 78 | 79 | 80 | ConciseBody : ExpressionBody 81 | 82 | 1. Return a new empty List. 83 | 84 | 85 | AsyncConciseBody : ExpressionBody 86 | 87 | 88 | 1. Return a new empty List. 89 | 90 | ScriptBody : StatementList 91 | 92 | 1. Return TopLevelLexicallyDeclaredNames of |StatementList|. 93 | 94 | 95 |

At the top level of a |Script|, function declarations are treated like var declarations rather than like lexical declarations.

96 |
97 | 98 |

The LexicallyDeclaredNames of a |Module| includes the names of all of its imported bindings.

99 |
100 | ModuleItemList : ModuleItemList ModuleItem 101 | 102 | 1. Let _names_ be LexicallyDeclaredNames of |ModuleItemList|. 103 | 1. Append to _names_ the elements of the LexicallyDeclaredNames of |ModuleItem|. 104 | 1. Return _names_. 105 | 106 | ModuleItem : ImportDeclaration 107 | 108 | 1. Return the BoundNames of |ImportDeclaration|. 109 | 110 | ModuleItem : ExportDeclaration 111 | 112 | 1. If |ExportDeclaration| is `export` |VariableStatement|, return a new empty List. 113 | 1. Return the BoundNames of |ExportDeclaration|. 114 | 115 | ModuleItem : StatementListItem 116 | 117 | 1. Return LexicallyDeclaredNames of |StatementListItem|. 118 | 119 | 120 |

At the top level of a |Module|, function declarations are treated like lexical declarations rather than like var declarations.

121 |
122 |
123 | -------------------------------------------------------------------------------- /spec/sec-static-semantics-lexicallyscopeddeclarations-patch.html: -------------------------------------------------------------------------------- 1 | 2 |

Static Semantics: LexicallyScopedDeclarations

3 | StatementList : StatementList StatementListItem 4 | 5 | 1. Let _declarations_ be LexicallyScopedDeclarations of |StatementList|. 6 | 1. Append to _declarations_ the elements of the LexicallyScopedDeclarations of |StatementListItem|. 7 | 1. Return _declarations_. 8 | 9 | StatementListItem : Statement 10 | 11 | 1. If |Statement| is Statement : LabelledStatement , return LexicallyScopedDeclarations of |LabelledStatement|. 12 | 1. Return a new empty List. 13 | 14 | StatementListItem : Declaration 15 | 16 | 1. Return a List whose sole element is DeclarationPart of |Declaration|. 17 | 18 | CaseBlock : `{` `}` 19 | 20 | 1. Return a new empty List. 21 | 22 | CaseBlock : `{` CaseClauses? DefaultClause CaseClauses? `}` 23 | 24 | 1. If the first |CaseClauses| is present, let _declarations_ be the LexicallyScopedDeclarations of the first |CaseClauses|. 25 | 1. Else, let _declarations_ be a new empty List. 26 | 1. Append to _declarations_ the elements of the LexicallyScopedDeclarations of |DefaultClause|. 27 | 1. If the second |CaseClauses| is not present, return _declarations_. 28 | 1. Return the result of appending to _declarations_ the elements of the LexicallyScopedDeclarations of the second |CaseClauses|. 29 | 30 | CaseClauses : CaseClauses CaseClause 31 | 32 | 1. Let _declarations_ be LexicallyScopedDeclarations of |CaseClauses|. 33 | 1. Append to _declarations_ the elements of the LexicallyScopedDeclarations of |CaseClause|. 34 | 1. Return _declarations_. 35 | 36 | CaseClause : `case` Expression `:` StatementList? 37 | 38 | 1. If the |StatementList| is present, return the LexicallyScopedDeclarations of |StatementList|. 39 | 1. Return a new empty List. 40 | 41 | DefaultClause : `default` `:` StatementList? 42 | 43 | 1. If the |StatementList| is present, return the LexicallyScopedDeclarations of |StatementList|. 44 | 1. Return a new empty List. 45 | 46 | LabelledStatement : LabelIdentifier `:` LabelledItem 47 | 48 | 1. Return the LexicallyScopedDeclarations of |LabelledItem|. 49 | 50 | LabelledItem : Statement 51 | 52 | 1. Return a new empty List. 53 | 54 | LabelledItem : FunctionDeclaration 55 | 56 | 1. Return a List whose sole element is |FunctionDeclaration|. 57 | 58 | FunctionStatementList : [empty] 59 | 60 | 1. Return a new empty List. 61 | 62 | FunctionStatementList : StatementList 63 | 64 | 1. Return the TopLevelLexicallyScopedDeclarations of |StatementList|. 65 | 66 | 67 | ClassStaticBlockStatementList : [empty] 68 | 69 | 1. Return a new empty List. 70 | 71 | ClassStaticBlockStatementList : StatementList 72 | 73 | 1. Return the TopLevelLexicallyScopedDeclarations of |StatementList|. 74 | 75 | 76 | ConciseBody : ExpressionBody 77 | 78 | 1. Return a new empty List. 79 | 80 | 81 | AsyncConciseBody : ExpressionBody 82 | 83 | 84 | 1. Return a new empty List. 85 | 86 | ScriptBody : StatementList 87 | 88 | 1. Return TopLevelLexicallyScopedDeclarations of |StatementList|. 89 | 90 | Module : [empty] 91 | 92 | 1. Return a new empty List. 93 | 94 | ModuleItemList : ModuleItemList ModuleItem 95 | 96 | 1. Let _declarations_ be LexicallyScopedDeclarations of |ModuleItemList|. 97 | 1. Append to _declarations_ the elements of the LexicallyScopedDeclarations of |ModuleItem|. 98 | 1. Return _declarations_. 99 | 100 | ModuleItem : ImportDeclaration 101 | 102 | 1. Return a new empty List. 103 | 104 | 105 | ExportDeclaration : 106 | `export` ExportFromClause FromClause `;` 107 | `export` NamedExports `;` 108 | `export` VariableStatement 109 | 110 | 111 | 1. Return a new empty List. 112 | 113 | ExportDeclaration : `export` Declaration 114 | 115 | 1. Return a List whose sole element is DeclarationPart of |Declaration|. 116 | 117 | ExportDeclaration : `export` `default` HoistableDeclaration 118 | 119 | 1. Return a List whose sole element is DeclarationPart of |HoistableDeclaration|. 120 | 121 | ExportDeclaration : `export` `default` ClassDeclaration 122 | 123 | 1. Return a List whose sole element is |ClassDeclaration|. 124 | 125 | ExportDeclaration : `export` `default` AssignmentExpression `;` 126 | 127 | 1. Return a List whose sole element is this |ExportDeclaration|. 128 | 129 |
130 | -------------------------------------------------------------------------------- /spec/sec-static-semantics-propname-patch.html: -------------------------------------------------------------------------------- 1 | 2 |

Static Semantics: PropName

3 | PropertyDefinition : IdentifierReference 4 | 5 | 1. Return StringValue of |IdentifierReference|. 6 | 7 | PropertyDefinition : `...` AssignmentExpression 8 | 9 | 1. Return ~empty~. 10 | 11 | PropertyDefinition : PropertyName `:` AssignmentExpression 12 | 13 | 1. Return PropName of |PropertyName|. 14 | 15 | LiteralPropertyName : IdentifierName 16 | 17 | 1. Return StringValue of |IdentifierName|. 18 | 19 | LiteralPropertyName : StringLiteral 20 | 21 | 1. Return the SV of |StringLiteral|. 22 | 23 | LiteralPropertyName : NumericLiteral 24 | 25 | 1. Let _nbr_ be the NumericValue of |NumericLiteral|. 26 | 1. Return ! ToString(_nbr_). 27 | 28 | ComputedPropertyName : `[` AssignmentExpression `]` 29 | 30 | 1. Return ~empty~. 31 | 32 | 33 | MethodDefinition : 34 | PropertyName `(` UniqueFormalParameters `)` `{` FunctionBody `}` 35 | `get` PropertyName `(` `)` `{` FunctionBody `}` 36 | `set` PropertyName `(` PropertySetParameterList `)` `{` FunctionBody `}` 37 | 38 | 39 | 1. Return PropName of |PropertyName|. 40 | 41 | GeneratorMethod : `*` PropertyName `(` UniqueFormalParameters `)` `{` GeneratorBody `}` 42 | 43 | 1. Return PropName of |PropertyName|. 44 | 45 | AsyncGeneratorMethod : `async` `*` PropertyName `(` UniqueFormalParameters `)` `{` AsyncGeneratorBody `}` 46 | 47 | 1. Return PropName of |PropertyName|. 48 | 49 | 50 | ClassElement : ClassStaticBlock 51 | 52 | 1. Return ~empty~. 53 | 54 | 55 | ClassElement : `;` 56 | 57 | 1. Return ~empty~. 58 | 59 | 60 | AsyncMethod : `async` PropertyName `(` UniqueFormalParameters `)` `{` AsyncFunctionBody `}` 61 | 62 | 63 | 1. Return PropName of |PropertyName|. 64 | 65 |
66 | -------------------------------------------------------------------------------- /spec/sec-static-semantics-vardeclarednames-patch.html: -------------------------------------------------------------------------------- 1 | 2 |

Static Semantics: VarDeclaredNames

3 | 4 | Statement : 5 | EmptyStatement 6 | ExpressionStatement 7 | ContinueStatement 8 | BreakStatement 9 | ReturnStatement 10 | ThrowStatement 11 | DebuggerStatement 12 | 13 | 14 | 1. Return a new empty List. 15 | 16 | Block : `{` `}` 17 | 18 | 1. Return a new empty List. 19 | 20 | StatementList : StatementList StatementListItem 21 | 22 | 1. Let _names_ be VarDeclaredNames of |StatementList|. 23 | 1. Append to _names_ the elements of the VarDeclaredNames of |StatementListItem|. 24 | 1. Return _names_. 25 | 26 | StatementListItem : Declaration 27 | 28 | 1. Return a new empty List. 29 | 30 | VariableStatement : `var` VariableDeclarationList `;` 31 | 32 | 1. Return BoundNames of |VariableDeclarationList|. 33 | 34 | IfStatement : `if` `(` Expression `)` Statement `else` Statement 35 | 36 | 1. Let _names_ be VarDeclaredNames of the first |Statement|. 37 | 1. Append to _names_ the elements of the VarDeclaredNames of the second |Statement|. 38 | 1. Return _names_. 39 | 40 | IfStatement : `if` `(` Expression `)` Statement 41 | 42 | 1. Return the VarDeclaredNames of |Statement|. 43 | 44 | DoWhileStatement : `do` Statement `while` `(` Expression `)` `;` 45 | 46 | 1. Return the VarDeclaredNames of |Statement|. 47 | 48 | WhileStatement : `while` `(` Expression `)` Statement 49 | 50 | 1. Return the VarDeclaredNames of |Statement|. 51 | 52 | ForStatement : `for` `(` Expression? `;` Expression? `;` Expression? `)` Statement 53 | 54 | 1. Return the VarDeclaredNames of |Statement|. 55 | 56 | ForStatement : `for` `(` `var` VariableDeclarationList `;` Expression? `;` Expression? `)` Statement 57 | 58 | 1. Let _names_ be BoundNames of |VariableDeclarationList|. 59 | 1. Append to _names_ the elements of the VarDeclaredNames of |Statement|. 60 | 1. Return _names_. 61 | 62 | ForStatement : `for` `(` LexicalDeclaration Expression? `;` Expression? `)` Statement 63 | 64 | 1. Return the VarDeclaredNames of |Statement|. 65 | 66 | 67 | ForInOfStatement : 68 | `for` `(` LeftHandSideExpression `in` Expression `)` Statement 69 | `for` `(` ForDeclaration `in` Expression `)` Statement 70 | `for` `(` LeftHandSideExpression `of` AssignmentExpression `)` Statement 71 | `for` `(` ForDeclaration `of` AssignmentExpression `)` Statement 72 | `for` `await` `(` LeftHandSideExpression `of` AssignmentExpression `)` Statement 73 | `for` `await` `(` ForDeclaration `of` AssignmentExpression `)` Statement 74 | 75 | 76 | 1. Return the VarDeclaredNames of |Statement|. 77 | 78 | 79 | ForInOfStatement : 80 | `for` `(` `var` ForBinding `in` Expression `)` Statement 81 | `for` `(` `var` ForBinding `of` AssignmentExpression `)` Statement 82 | `for` `await` `(` `var` ForBinding `of` AssignmentExpression `)` Statement 83 | 84 | 85 | 1. Let _names_ be the BoundNames of |ForBinding|. 86 | 1. Append to _names_ the elements of the VarDeclaredNames of |Statement|. 87 | 1. Return _names_. 88 | 89 | 90 |

This section is extended by Annex .

91 |
92 | WithStatement : `with` `(` Expression `)` Statement 93 | 94 | 1. Return the VarDeclaredNames of |Statement|. 95 | 96 | SwitchStatement : `switch` `(` Expression `)` CaseBlock 97 | 98 | 1. Return the VarDeclaredNames of |CaseBlock|. 99 | 100 | CaseBlock : `{` `}` 101 | 102 | 1. Return a new empty List. 103 | 104 | CaseBlock : `{` CaseClauses? DefaultClause CaseClauses? `}` 105 | 106 | 1. If the first |CaseClauses| is present, let _names_ be the VarDeclaredNames of the first |CaseClauses|. 107 | 1. Else, let _names_ be a new empty List. 108 | 1. Append to _names_ the elements of the VarDeclaredNames of |DefaultClause|. 109 | 1. If the second |CaseClauses| is not present, return _names_. 110 | 1. Return the result of appending to _names_ the elements of the VarDeclaredNames of the second |CaseClauses|. 111 | 112 | CaseClauses : CaseClauses CaseClause 113 | 114 | 1. Let _names_ be VarDeclaredNames of |CaseClauses|. 115 | 1. Append to _names_ the elements of the VarDeclaredNames of |CaseClause|. 116 | 1. Return _names_. 117 | 118 | CaseClause : `case` Expression `:` StatementList? 119 | 120 | 1. If the |StatementList| is present, return the VarDeclaredNames of |StatementList|. 121 | 1. Return a new empty List. 122 | 123 | DefaultClause : `default` `:` StatementList? 124 | 125 | 1. If the |StatementList| is present, return the VarDeclaredNames of |StatementList|. 126 | 1. Return a new empty List. 127 | 128 | LabelledStatement : LabelIdentifier `:` LabelledItem 129 | 130 | 1. Return the VarDeclaredNames of |LabelledItem|. 131 | 132 | LabelledItem : FunctionDeclaration 133 | 134 | 1. Return a new empty List. 135 | 136 | TryStatement : `try` Block Catch 137 | 138 | 1. Let _names_ be VarDeclaredNames of |Block|. 139 | 1. Append to _names_ the elements of the VarDeclaredNames of |Catch|. 140 | 1. Return _names_. 141 | 142 | TryStatement : `try` Block Finally 143 | 144 | 1. Let _names_ be VarDeclaredNames of |Block|. 145 | 1. Append to _names_ the elements of the VarDeclaredNames of |Finally|. 146 | 1. Return _names_. 147 | 148 | TryStatement : `try` Block Catch Finally 149 | 150 | 1. Let _names_ be VarDeclaredNames of |Block|. 151 | 1. Append to _names_ the elements of the VarDeclaredNames of |Catch|. 152 | 1. Append to _names_ the elements of the VarDeclaredNames of |Finally|. 153 | 1. Return _names_. 154 | 155 | Catch : `catch` `(` CatchParameter `)` Block 156 | 157 | 1. Return the VarDeclaredNames of |Block|. 158 | 159 | FunctionStatementList : [empty] 160 | 161 | 1. Return a new empty List. 162 | 163 | FunctionStatementList : StatementList 164 | 165 | 1. Return TopLevelVarDeclaredNames of |StatementList|. 166 | 167 | 168 | ClassStaticBlockStatementList : [empty] 169 | 170 | 1. Return a new empty List. 171 | 172 | ClassStaticBlockStatementList : StatementList 173 | 174 | 1. Return the TopLevelVarDeclaredNames of |StatementList|. 175 | 176 | 177 | ConciseBody : ExpressionBody 178 | 179 | 1. Return a new empty List. 180 | 181 | 182 | AsyncConciseBody : ExpressionBody 183 | 184 | 185 | 1. Return a new empty List. 186 | 187 | ScriptBody : StatementList 188 | 189 | 1. Return TopLevelVarDeclaredNames of |StatementList|. 190 | 191 | Module : [empty] 192 | 193 | 1. Return a new empty List. 194 | 195 | ModuleItemList : ModuleItemList ModuleItem 196 | 197 | 1. Let _names_ be VarDeclaredNames of |ModuleItemList|. 198 | 1. Append to _names_ the elements of the VarDeclaredNames of |ModuleItem|. 199 | 1. Return _names_. 200 | 201 | ModuleItem : ImportDeclaration 202 | 203 | 1. Return a new empty List. 204 | 205 | ModuleItem : ExportDeclaration 206 | 207 | 1. If |ExportDeclaration| is `export` |VariableStatement|, return BoundNames of |ExportDeclaration|. 208 | 1. Return a new empty List. 209 | 210 |
211 | -------------------------------------------------------------------------------- /spec/sec-static-semantics-varscopeddeclarations-patch.html: -------------------------------------------------------------------------------- 1 | 2 |

Static Semantics: VarScopedDeclarations

3 | 4 | Statement : 5 | EmptyStatement 6 | ExpressionStatement 7 | ContinueStatement 8 | BreakStatement 9 | ReturnStatement 10 | ThrowStatement 11 | DebuggerStatement 12 | 13 | 14 | 1. Return a new empty List. 15 | 16 | Block : `{` `}` 17 | 18 | 1. Return a new empty List. 19 | 20 | StatementList : StatementList StatementListItem 21 | 22 | 1. Let _declarations_ be VarScopedDeclarations of |StatementList|. 23 | 1. Append to _declarations_ the elements of the VarScopedDeclarations of |StatementListItem|. 24 | 1. Return _declarations_. 25 | 26 | StatementListItem : Declaration 27 | 28 | 1. Return a new empty List. 29 | 30 | VariableDeclarationList : VariableDeclaration 31 | 32 | 1. Return a List whose sole element is |VariableDeclaration|. 33 | 34 | VariableDeclarationList : VariableDeclarationList `,` VariableDeclaration 35 | 36 | 1. Let _declarations_ be VarScopedDeclarations of |VariableDeclarationList|. 37 | 1. Append |VariableDeclaration| to _declarations_. 38 | 1. Return _declarations_. 39 | 40 | IfStatement : `if` `(` Expression `)` Statement `else` Statement 41 | 42 | 1. Let _declarations_ be VarScopedDeclarations of the first |Statement|. 43 | 1. Append to _declarations_ the elements of the VarScopedDeclarations of the second |Statement|. 44 | 1. Return _declarations_. 45 | 46 | IfStatement : `if` `(` Expression `)` Statement 47 | 48 | 1. Return the VarScopedDeclarations of |Statement|. 49 | 50 | DoWhileStatement : `do` Statement `while` `(` Expression `)` `;` 51 | 52 | 1. Return the VarScopedDeclarations of |Statement|. 53 | 54 | WhileStatement : `while` `(` Expression `)` Statement 55 | 56 | 1. Return the VarScopedDeclarations of |Statement|. 57 | 58 | ForStatement : `for` `(` Expression? `;` Expression? `;` Expression? `)` Statement 59 | 60 | 1. Return the VarScopedDeclarations of |Statement|. 61 | 62 | ForStatement : `for` `(` `var` VariableDeclarationList `;` Expression? `;` Expression? `)` Statement 63 | 64 | 1. Let _declarations_ be VarScopedDeclarations of |VariableDeclarationList|. 65 | 1. Append to _declarations_ the elements of the VarScopedDeclarations of |Statement|. 66 | 1. Return _declarations_. 67 | 68 | ForStatement : `for` `(` LexicalDeclaration Expression? `;` Expression? `)` Statement 69 | 70 | 1. Return the VarScopedDeclarations of |Statement|. 71 | 72 | 73 | ForInOfStatement : 74 | `for` `(` LeftHandSideExpression `in` Expression `)` Statement 75 | `for` `(` ForDeclaration `in` Expression `)` Statement 76 | `for` `(` LeftHandSideExpression `of` AssignmentExpression `)` Statement 77 | `for` `(` ForDeclaration `of` AssignmentExpression `)` Statement 78 | `for` `await` `(` LeftHandSideExpression `of` AssignmentExpression `)` Statement 79 | `for` `await` `(` ForDeclaration `of` AssignmentExpression `)` Statement 80 | 81 | 82 | 1. Return the VarScopedDeclarations of |Statement|. 83 | 84 | 85 | ForInOfStatement : 86 | `for` `(` `var` ForBinding `in` Expression `)` Statement 87 | `for` `(` `var` ForBinding `of` AssignmentExpression `)` Statement 88 | `for` `await` `(` `var` ForBinding `of` AssignmentExpression `)` Statement 89 | 90 | 91 | 1. Let _declarations_ be a List whose sole element is |ForBinding|. 92 | 1. Append to _declarations_ the elements of the VarScopedDeclarations of |Statement|. 93 | 1. Return _declarations_. 94 | 95 | 96 |

This section is extended by Annex .

97 |
98 | WithStatement : `with` `(` Expression `)` Statement 99 | 100 | 1. Return the VarScopedDeclarations of |Statement|. 101 | 102 | SwitchStatement : `switch` `(` Expression `)` CaseBlock 103 | 104 | 1. Return the VarScopedDeclarations of |CaseBlock|. 105 | 106 | CaseBlock : `{` `}` 107 | 108 | 1. Return a new empty List. 109 | 110 | CaseBlock : `{` CaseClauses? DefaultClause CaseClauses? `}` 111 | 112 | 1. If the first |CaseClauses| is present, let _declarations_ be the VarScopedDeclarations of the first |CaseClauses|. 113 | 1. Else, let _declarations_ be a new empty List. 114 | 1. Append to _declarations_ the elements of the VarScopedDeclarations of |DefaultClause|. 115 | 1. If the second |CaseClauses| is not present, return _declarations_. 116 | 1. Return the result of appending to _declarations_ the elements of the VarScopedDeclarations of the second |CaseClauses|. 117 | 118 | CaseClauses : CaseClauses CaseClause 119 | 120 | 1. Let _declarations_ be VarScopedDeclarations of |CaseClauses|. 121 | 1. Append to _declarations_ the elements of the VarScopedDeclarations of |CaseClause|. 122 | 1. Return _declarations_. 123 | 124 | CaseClause : `case` Expression `:` StatementList? 125 | 126 | 1. If the |StatementList| is present, return the VarScopedDeclarations of |StatementList|. 127 | 1. Return a new empty List. 128 | 129 | DefaultClause : `default` `:` StatementList? 130 | 131 | 1. If the |StatementList| is present, return the VarScopedDeclarations of |StatementList|. 132 | 1. Return a new empty List. 133 | 134 | LabelledStatement : LabelIdentifier `:` LabelledItem 135 | 136 | 1. Return the VarScopedDeclarations of |LabelledItem|. 137 | 138 | LabelledItem : FunctionDeclaration 139 | 140 | 1. Return a new empty List. 141 | 142 | TryStatement : `try` Block Catch 143 | 144 | 1. Let _declarations_ be VarScopedDeclarations of |Block|. 145 | 1. Append to _declarations_ the elements of the VarScopedDeclarations of |Catch|. 146 | 1. Return _declarations_. 147 | 148 | TryStatement : `try` Block Finally 149 | 150 | 1. Let _declarations_ be VarScopedDeclarations of |Block|. 151 | 1. Append to _declarations_ the elements of the VarScopedDeclarations of |Finally|. 152 | 1. Return _declarations_. 153 | 154 | TryStatement : `try` Block Catch Finally 155 | 156 | 1. Let _declarations_ be VarScopedDeclarations of |Block|. 157 | 1. Append to _declarations_ the elements of the VarScopedDeclarations of |Catch|. 158 | 1. Append to _declarations_ the elements of the VarScopedDeclarations of |Finally|. 159 | 1. Return _declarations_. 160 | 161 | Catch : `catch` `(` CatchParameter `)` Block 162 | 163 | 1. Return the VarScopedDeclarations of |Block|. 164 | 165 | FunctionStatementList : [empty] 166 | 167 | 1. Return a new empty List. 168 | 169 | FunctionStatementList : StatementList 170 | 171 | 1. Return the TopLevelVarScopedDeclarations of |StatementList|. 172 | 173 | 174 | ClassStaticBlockStatementList : [empty] 175 | 176 | 1. Return a new empty List. 177 | 178 | ClassStaticBlockStatementList : StatementList 179 | 180 | 1. Return the TopLevelVarScopedDeclarations of |StatementList|. 181 | 182 | 183 | ConciseBody : ExpressionBody 184 | 185 | 1. Return a new empty List. 186 | 187 | 188 | AsyncConciseBody : ExpressionBody 189 | 190 | 191 | 1. Return a new empty List. 192 | 193 | ScriptBody : StatementList 194 | 195 | 1. Return TopLevelVarScopedDeclarations of |StatementList|. 196 | 197 | Module : [empty] 198 | 199 | 1. Return a new empty List. 200 | 201 | ModuleItemList : ModuleItemList ModuleItem 202 | 203 | 1. Let _declarations_ be VarScopedDeclarations of |ModuleItemList|. 204 | 1. Append to _declarations_ the elements of the VarScopedDeclarations of |ModuleItem|. 205 | 1. Return _declarations_. 206 | 207 | ModuleItem : ImportDeclaration 208 | 209 | 1. Return a new empty List. 210 | 211 | ModuleItem : ExportDeclaration 212 | 213 | 1. If |ExportDeclaration| is `export` |VariableStatement|, return VarScopedDeclarations of |VariableStatement|. 214 | 1. Return a new empty List. 215 | 216 |
217 | --------------------------------------------------------------------------------