doc: update example of using await in REPL#45939
doc: update example of using await in REPL#45939deokjinkim wants to merge 4 commits intonodejs:mainfrom
Conversation
Invalidating the lexical scoping of the `const` and `let` keywords is fixed. Fixes: nodejs#45918
aduh95
left a comment
There was a problem hiding this comment.
Can we add a test for that?
Okay. I'll try to write test case for that. |
BridgeAR
left a comment
There was a problem hiding this comment.
The scope is still changed, if I am not mistaken:
> const m = await Promise.resolve(123)
undefined
> m
123
> m = 'Lexial scope changed!'
'Lexial scope changed!'
> m
'Lexial scope changed!'
> vs.
> const m = 123
undefined
> m
123
> m = 'Lexial scope changed!'
Uncaught TypeError: Assignment to constant variable.
> Lexical scope of `const` is only invalidated when using top-level `await` in REPL. Fixes: nodejs#45918
31508ee to
2de633c
Compare
await in REPL
BridgeAR
left a comment
There was a problem hiding this comment.
The change is LGTM. I can't reproduce any other behavior anymore.
Ideally we could add a test case that validates the outcome accordingly.
Co-authored-by: Antoine du Hamel <duhamelantoine1995@gmail.com>
| ['const k = await Promise.resolve(123)'], | ||
| ['k', '123'], | ||
| ['k = await Promise.resolve(234)', '234'], | ||
| ['k', '234'], |
There was a problem hiding this comment.
And the drive the point home:
| ['k', '234'], | |
| ['k', '234'], | |
| ['const k = await Promise.resolve(345)'], | |
| ['k', '345'], |
There was a problem hiding this comment.
line 180 causes error like 'Uncaught SyntaxError: Identifier 'k' has already been declared'.
When I tested,
// This is allowed
const k = await Promise.resolve(123)
k = await Promise.resolve(234)
// This is not allowed
const k = await Promise.resolve(123)
const k = await Promise.resolve(234)
|
This issue/PR was marked as stalled, it will be automatically closed in 30 days. If it should remain open, please leave a comment explaining why it should remain open. |
|
The mentioned issue seems to be resolved by another PR. |
Lexical scope of
constis only invalidated whenusing top-level
awaitin REPL.Fixes: #45918