v8 / v8.dev

The source code of v8.dev, the official website of the V8 project.
https://v8.dev/
Apache License 2.0
953 stars 320 forks source link

I found a standard impementation bug #765

Closed AeolusZane closed 5 months ago

AeolusZane commented 5 months ago

In a new recursion, a variable declared with "let", should be initialized with a new "let", but in below's demo, it didn't. it seems executed like "var" instead of "let". so when it runs, it would be "Maximum call stack size exceeded...".

let cur;
for(let i=5,last=()=>{};i>=0;i--){
    cur = ()=>{
        console.log(i);
        last()
    };
    last = cur;
}
cur()

however, by this way, the result executed as expected.

let cur;
for(let i=5,last=()=>{};i>=0;last = cur,last = cur,i--){
    cur = ()=>{
        console.log(i);
        last()
    };
}
cur()
camillobruni commented 5 months ago

Please report this on the v8 issue tracker. This here is just for the v8.dev website.

AeolusZane commented 5 months ago

ok, I got it. thx for your reply~