New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(semantic): connect test
expression of for
statements to the cfg.
#3122
fix(semantic): connect test
expression of for
statements to the cfg.
#3122
Conversation
CodSpeed Performance ReportMerging #3122 will improve performances by 18.42%Comparing Summary
Benchmarks breakdown
|
Given this block of code: function t1() {
const res = [];
const additionalCond = true;
for (let i = 0; i !== 10 && additionalCond; ++i ) {
res.push(i);
}
React.useLayoutEffect(() => {});
} the cfg used to look like this:
With this change, it would look like this:
I'm unsure if this is illegal, Or would break anything in the type system, etc. But it would simplify the cfg traversal since every node has a follower node and we can check if any 2 nodes share a subtree by checking both are connected to the same parent, and If they have a connection they are also always on the same subtree. @Boshen Please give it a look I'm not really familiar with what a cfg should look like so it might be just wrong. What I'm looking for is simplifying checks but I can always find another way to solve it. Right now I'm implementing #3071 with off-the-shelf algorithms so if this PR doesn't work I can just write a specialized one. |
Please don't merge it yet, Since if it gets approved there are other places that need the same treatment |
There's also a graphical output from https://github.com/oxc-project/oxc/blob/main/crates/oxc_semantic/examples/cfg.rs Your change seems to be more correct than the previous one. This can be verifed with the biome cfg, There's a loop and a exit edge, which is your graph after the change. |
Oh, I didn't know about either of these visualization tools, They sure would've come in handy last day when I was trying to figure out this. I'll check the biome control flow and compare it with ours to find other edge cases that can be improved. PS: I might mark this one "ready" a bit sooner than the rest since it is a dependency of the react hooks rule |
fef3ca3
to
d24c226
Compare
test
expression of for
statements to the cfg.test
expression of for
statements to the cfg.
I don't know if it is correct or not, Fixes my issues with dangling cfg nodes created in for statements.
d24c226
to
2a8148a
Compare
I don't know if it is correct or not, Fixes my issues with dangling cfg nodes created in for statements. #3071