Fix find_var_htab to skip entries with scope_level != 0#1471
Conversation
When a `var` shadows a block-scoped `let` of the same name, find_var_htab returned the block-scoped entry. find_var rejected it (scope_level != 0) and fell through to an O(n) linear scan. Add scope_level == 0 check to the htab probe loop so non-scope-0 entries are skipped. This lets find_var treat htab miss as definitive.
ffadecc to
6bec763
Compare
|
Can you add a test for this? |
b27f19b to
bf52efb
Compare
|
Hum, the test passes in master without your fix, can you rebase and double check? |
The original implementation is functionally correct. The issue is that So the test does not fail on master; it mainly ensures that the fix preserves the expected behavior in this shadowing scenario. |
|
Sorry, not sure I follow. If the PR does fix something then the test needs to fail without the fix, or the test is wrong. |
|
I think @jiang1997 may be saying it's a performance issue rather than a correctness issue? |
When a
varshadows a block-scopedletof the same name, find_var_htab returned the block-scoped entry. find_var rejected it (scope_level != 0) and fell through to an O(n) linear scan.Add scope_level == 0 check to the htab probe loop so non-scope-0 entries are skipped. This lets find_var treat htab miss as definitive.