Haiyang-Sun / nodeprof.js

Instrumentation framework for Node.js compliant to ECMAScript 2020 based on GraalVM.
Apache License 2.0
53 stars 22 forks source link

declare doesn't work with await and block scope #95

Open Soulike opened 3 years ago

Soulike commented 3 years ago

I want to use declare to get all variable declarations but encounter a problem.

Analysis Code

this.declare = (iid, name) =>
{
    console.log(`declare: ${iid} ${name}`);
}

Analyzed Code

async function test()
{
    {   // some block scope
        let a = await 1;    // or const
    }
}

test();

And the output is like:

declare: 1 exports
declare: 1 require
declare: 1 module
declare: 1 __filename
declare: 1 __dirname
declare: 2 test

declare is never called for a. The combination of let/const and await does not emit declare. If I use var or remove await, declare will be called.