-
-
Notifications
You must be signed in to change notification settings - Fork 391
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
semantic: check symbols and scopes after transformation #4790
Comments
ProcessI suggest the following process:
i.e. AST v2 and The complicationThe tricky part is what constitutes "matches". For example if this is the input: if (x) enum Foo {}
function f() {} The output of transformer is: if (x) {}
function f() {} The scope IDs are: Before transform: // Scope ID 0
if (x) enum Foo { /* Scope ID 1 */ }
function f() { /* Scope ID 2 */ } After transform: // Scope ID 0
if (x) { /* Scope ID 3 */ } // <-- newly created scope
function f() { /* Scope ID 2 */ } vs fresh semantic run on post-transform AST: // Scope ID 0
if (x) { /* Scope ID 1 */ } // <-- numbered 1 as it's 2nd scope found in visitation order
function f() { /* Scope ID 2 */ } Scope IDs of the But we don't want to throw an error on this because they are equivalent. Likely same kind of thing will happen with Suggested solutionTraverse AST v1 and AST v2 in tandem and:
When comparing v1 Ditto for ConclusionSo this is all a bit of a pain! But, if we can build this test infra, it will give us extremely good test coverage and we can be very confident that transformer is keeping scopes/symbols in sync correctly. Side note: I'd imagine running these checks as part of transformer conformance, so we get instant feedback on PRs if they foul up scopes. |
I would be happy to take this is on if you like, Boshen. |
Just a note, we may need to check duplicate AstNodeId, ScopeId, and SymbolId in |
Borrowing the idea of the mangler, we can check whether symbols are the same in scope visitation order. |
closes #4790 @overlookmotel enjoy ... take a look at the snapshots and probably nothing else. The snapshots are minimal right now, but it's already showing symbols from import specifiers are not being removed. We can iterate on the snapshot representation to aid debugging later. I'll extend this to `transformer_conformance` and `oxc-monitor` in an up coming PR.
cc @overlookmotel how exactly do we want to check symbols and scopes?
The text was updated successfully, but these errors were encountered: