-
-
Notifications
You must be signed in to change notification settings - Fork 34.4k
Open
Labels
replIssues and PRs related to the REPL subsystem.Issues and PRs related to the REPL subsystem.v22.xIssues that can be reproduced on v22.x or PRs targeting the v22.x-staging branch.Issues that can be reproduced on v22.x or PRs targeting the v22.x-staging branch.
Description
Version
v22.19.0
Platform
Microsoft Windows NT 10.0.26100.0 x64
Subsystem
REPL
What steps will reproduce the bug?
In REPL, prepare a generator function
function* infinite() {
let i = 0;
while (true) {
i += 1;
yield {
i,
reset: () => {
i = 0;
},
};
}
}Instantiate and get next value
> inf = infinite()
Object [Generator] {}
> inf.next().value
{ i: 7, reset: [Function: reset] }
> inf.next().value
{ i: 12, reset: [Function: reset] }
> inf.next().value
{ i: 15, reset: [Function: reset] }
> inf.next().value
{ i: 18, reset: [Function: reset] }
> inf.next().value
{ i: 21, reset: [Function: reset] }
> inf.next().value.reset()
undefined
> inf.next().value
{ i: 3, reset: [Function: reset] }
> inf.next().value
{ i: 6, reset: [Function: reset] }How often does it reproduce? Is there a required condition?
Always. The statement should be executed one by one.
However, if multiple .next statements are called in a single line, the numbers are generated in the correct incrementation.
> inf = infinite(); Array.from({ length: 10 }).map(e => inf.next().value.i)
[
1, 2, 3, 4, 5,
6, 7, 8, 9, 10
]What is the expected behavior? Why is that the expected behavior?
When executing inf.next().value, REPL should return 1, 2, 3, 4...
When calling the reset function, the iteration should reset to 1, 2, 3, 4...
What do you see instead?
Iteration did not start from 1. The next number was incremented by 3 instead of 1.
Additional information
(AI said the REPL is advancing the generator to get the preview value, of which) When I press the UP button to get the last executed command and then DOWN and then UP once more, the generator was advanced further than just incremental of 3
Metadata
Metadata
Assignees
Labels
replIssues and PRs related to the REPL subsystem.Issues and PRs related to the REPL subsystem.v22.xIssues that can be reproduced on v22.x or PRs targeting the v22.x-staging branch.Issues that can be reproduced on v22.x or PRs targeting the v22.x-staging branch.