-
-
Notifications
You must be signed in to change notification settings - Fork 33k
Closed
Description
- Version: v16.4.1
- Platform: Archlinux
- Subsystem: N/A
What steps will reproduce the bug?
- run node with:
node --use_strict --experimental-repl-await
- enter:
const x = await 1;
- receive:
Uncaught ReferenceError: x is not defined
at REPL1:1:24
at processTicksAndRejections (node:internal/process/task_queues:96:5)
How often does it reproduce? Is there a required condition?
100%
What is the expected behavior?
It shouldn't throw error, or if this is not supported then it should error out before starting repl.
What do you see instead?
Error is thrown
Additional information
This is related to handling in
node/lib/internal/repl/await.js
Lines 53 to 74 in c2e6822
VariableDeclaration(node, state, c) { | |
if (node.kind === 'var' || | |
state.ancestors[state.ancestors.length - 2] === state.body) { | |
if (node.declarations.length === 1) { | |
state.replace(node.start, node.start + node.kind.length, 'void'); | |
} else { | |
state.replace(node.start, node.start + node.kind.length, 'void ('); | |
} | |
ArrayPrototypeForEach(node.declarations, (decl) => { | |
state.prepend(decl, '('); | |
state.append(decl, decl.init ? ')' : '=undefined)'); | |
}); | |
if (node.declarations.length !== 1) { | |
state.append(node.declarations[node.declarations.length - 1], ')'); | |
} | |
} | |
walk.base.VariableDeclaration(node, state, c); | |
} | |
}; |
as it's replacing const
with void ($exp)
without any flag to omit if running in strict mode.
This was noticed when trying to implement TLA in repl for ts-node.
Metadata
Metadata
Assignees
Labels
No labels