| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent bec053a commit 133d287
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -258,8 +258,7 @@ undefined | |||
| 258 | 258 | ``` | |
| 259 | 259 | ||
| 260 | 260 | One known limitation of using the `await` keyword in the REPL is that | |
| 261 | - it will invalidate the lexical scoping of the `const` and `let` | ||
| 262 | - keywords. | ||
| 261 | + it will invalidate the lexical scoping of the `const` keywords. | ||
| 263 | 262 | ||
| 264 | 263 | For example: | |
| 265 | 264 | ||
@@ -268,10 +267,11 @@ For example: | |||
| 268 | 267 | undefined | |
| 269 | 268 | > m | |
| 270 | 269 | 123 | |
| 271 | - > const m = await Promise.resolve(234) | ||
| 272 | - undefined | ||
| 273 | - > m | ||
| 270 | + > m = await Promise.resolve(234) | ||
| 274 | 271 | 234 | |
| 272 | + // redeclaring the constant does error | ||
| 273 | + > const m = await Promise.resolve(345) | ||
| 274 | + Uncaught SyntaxError: Identifier 'm' has already been declared | ||
| 275 | 275 | ``` | |
| 276 | 276 | ||
| 277 | 277 | [`--no-experimental-repl-await`][] shall disable top-level await in REPL. | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -173,6 +173,12 @@ async function ordinaryTests() { | |||
| 173 | 173 | '3', | |
| 174 | 174 | 'undefined', | |
| 175 | 175 | ]], | |
| 176 | + // Testing documented behavior of `const`s (see: https://github.com/nodejs/node/issues/45918) | ||
| 177 | + ['const k = await Promise.resolve(123)'], | ||
| 178 | + ['k', '123'], | ||
| 179 | + ['k = await Promise.resolve(234)', '234'], | ||
| 180 | + ['k', '234'], | ||
| 181 | + ['const k = await Promise.resolve(345)', "Uncaught SyntaxError: Identifier 'k' has already been declared"], | ||
| 176 | 182 | // Regression test for https://github.com/nodejs/node/issues/43777. | |
| 177 | 183 | ['await Promise.resolve(123), Promise.resolve(456)', 'Promise {', { line: 0 }], | |
| 178 | 184 | ['await Promise.resolve(123), await Promise.resolve(456)', '456'], | |
| Back | FazBrowse Home | New Git URL |
0 commit comments