Skip to content
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): remove check_unresolved_references #5301

Closed

Conversation

Dunqing
Copy link
Member

@Dunqing Dunqing commented Aug 28, 2024

As I said in #5298 (comment). The unresolved_references check is incorrect. In the meantime, I found that check_reference contained the unresolved_references check, so I removed it

@Dunqing Dunqing marked this pull request as ready for review August 28, 2024 14:16
Copy link
Member Author

Dunqing commented Aug 28, 2024

This stack of pull requests is managed by Graphite. Learn more about stacking.

Join @Dunqing and the rest of your teammates on Graphite Graphite

@Dunqing Dunqing changed the title fix(semantic): remove check_unresolved_references fix(semantic): remove check_unresolved_references Aug 28, 2024
@github-actions github-actions bot added A-semantic Area - Semantic A-transformer Area - Transformer / Transpiler labels Aug 28, 2024
Copy link

codspeed-hq bot commented Aug 28, 2024

CodSpeed Performance Report

Merging #5301 will not alter performance

Comparing 08-28-fix_semantic_remove_check_unresolved_references (32dc517) with main (7fa2fa3)

Summary

✅ 28 untouched benchmarks

@overlookmotel
Copy link
Collaborator

I'm afraid I disagree with you on this one.

First off, the test failure discussed in #5298 (review) is correct, as far as I can see. We have failed to delete an unresolved reference when we should have, and the checker flags that.

Secondly, check_unresolved_references is covering a different set of cases from check_references. check_references starts from a list of all the IdentifierReferences which are in the AST and checks they have the correct SymbolId. check_unresolved_references comes at it from the opposite direction - it loops through ScopeTree::root_unresolved_references and checks (a) there aren't any keys in that there shouldn't be and (b) they each have the right ReferenceIds recorded against them.

In the case of #5298 (review), the problem is that we've deleted the IdentifierReference from AST, but not deleted the corresponding reference from root_unresolved_references. So check_references could not catch this, as it starts from the AST, and there is nothing in the AST to start from (as it was deleted).

@Dunqing
Copy link
Member Author

Dunqing commented Aug 28, 2024

Yes, I know we should remove them. but since Semantic doesn't provide remove action, this checking is always a mismatch, right? Also, symbol and scope have the same problem. But we haven't checked them what unremoved.

@overlookmotel
Copy link
Collaborator

overlookmotel commented Aug 29, 2024

Sorry I was rushing out of the house yesterday, so just whacked out #5305, but didn't have time to reply here.

since Semantic doesn't provide remove action

It does now! #5305

Also, symbol and scope have the same problem. But we haven't checked them what unremoved.

That is true. I left that out of the transform checker for now as currently we have no way to flag scopes, symbols and references as deleted (#5097). Adding that'll be a bit of work, so I thought best just punt the problem for now - and it only matters if you iterate over ScopeTree / SymbolTable directly, which mostly we don't.

Whereas, for unresolved references, even though we didn't have an API for deleting them, I knew it wouldn't be hard to add one.

So, in summary... in my view we should delete unresolved references, #5305 gives us an API to do that, and the transformer checker should check it's done correctly. So I think we should close this PR.

@Dunqing
Copy link
Member Author

Dunqing commented Aug 29, 2024

So, in summary... in my view we should delete unresolved references, #5305 gives us an API to do that, and the transformer checker should check it's done correctly. So I think we should close this PR.

I agree

@Dunqing Dunqing closed this Aug 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-semantic Area - Semantic A-transformer Area - Transformer / Transpiler
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants