mirror of
https://github.com/danbulant/oxc
synced 2026-05-19 12:19:15 +00:00
fix(semantic): transform checker compare binding symbol IDs (#5057)
This commit is contained in:
parent
f187b71877
commit
05fff16d55
2 changed files with 40 additions and 4 deletions
|
|
@ -328,9 +328,35 @@ impl<'s> PostTransformChecker<'s> {
|
|||
(None, None) => continue,
|
||||
(Some(scope_id_after_transform), Some(scope_id_rebuilt)) => {
|
||||
let scope_ids = Pair::new(scope_id_after_transform, scope_id_rebuilt);
|
||||
let bindings = self.get_pair(scope_ids, get_sorted_bindings);
|
||||
if bindings.is_mismatch() {
|
||||
self.errors.push_mismatch("Bindings mismatch", scope_ids, bindings);
|
||||
let binding_names = self.get_pair(scope_ids, get_sorted_bindings);
|
||||
if binding_names.is_mismatch() {
|
||||
self.errors.push_mismatch("Bindings mismatch", scope_ids, binding_names);
|
||||
} else {
|
||||
let symbol_ids = self.get_pair(scope_ids, |data, scope_id| {
|
||||
data.scopes.get_bindings(scope_id).values().copied().collect::<Vec<_>>()
|
||||
});
|
||||
|
||||
let mut symbol_ids_after_transform = symbol_ids
|
||||
.after_transform
|
||||
.iter()
|
||||
.map(|symbol_id| self.symbol_ids_map.get(symbol_id).copied())
|
||||
.collect::<Vec<_>>();
|
||||
symbol_ids_after_transform.sort_unstable();
|
||||
let mut symbol_ids_rebuilt = symbol_ids
|
||||
.rebuilt
|
||||
.iter()
|
||||
.copied()
|
||||
.map(Option::Some)
|
||||
.collect::<Vec<_>>();
|
||||
symbol_ids_rebuilt.sort_unstable();
|
||||
|
||||
if symbol_ids_after_transform != symbol_ids_rebuilt {
|
||||
self.errors.push_mismatch(
|
||||
"Binding symbols mismatch",
|
||||
scope_ids,
|
||||
symbol_ids,
|
||||
);
|
||||
}
|
||||
}
|
||||
scope_ids
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ commit: 12619ffe
|
|||
|
||||
semantic_babel Summary:
|
||||
AST Parsed : 2101/2101 (100.00%)
|
||||
Positive Passed: 1792/2101 (85.29%)
|
||||
Positive Passed: 1790/2101 (85.20%)
|
||||
tasks/coverage/babel/packages/babel-parser/test/fixtures/annex-b/enabled/3.3-function-in-if-body/input.js
|
||||
semantic error: Scope children mismatch:
|
||||
after transform: ScopeId(0): [ScopeId(1), ScopeId(2)]
|
||||
|
|
@ -27,6 +27,11 @@ semantic error: Scope children mismatch:
|
|||
after transform: ScopeId(3): [ScopeId(4)]
|
||||
rebuilt : ScopeId(3): [ScopeId(4)]
|
||||
|
||||
tasks/coverage/babel/packages/babel-parser/test/fixtures/core/uncategorised/230/input.js
|
||||
semantic error: Binding symbols mismatch:
|
||||
after transform: ScopeId(0): [SymbolId(0)]
|
||||
rebuilt : ScopeId(0): [SymbolId(0)]
|
||||
|
||||
tasks/coverage/babel/packages/babel-parser/test/fixtures/core/uncategorised/327/input.js
|
||||
semantic error: A 'return' statement can only be used within a function body.
|
||||
|
||||
|
|
@ -133,6 +138,11 @@ semantic error: Bindings mismatch:
|
|||
after transform: ScopeId(0): ["nil"]
|
||||
rebuilt : ScopeId(0): []
|
||||
|
||||
tasks/coverage/babel/packages/babel-parser/test/fixtures/esprima/statement-if/migrated_0002/input.js
|
||||
semantic error: Binding symbols mismatch:
|
||||
after transform: ScopeId(0): [SymbolId(0)]
|
||||
rebuilt : ScopeId(0): [SymbolId(0)]
|
||||
|
||||
tasks/coverage/babel/packages/babel-parser/test/fixtures/esprima/statement-if/migrated_0003/input.js
|
||||
semantic error: Scope children mismatch:
|
||||
after transform: ScopeId(0): [ScopeId(1)]
|
||||
|
|
|
|||
Loading…
Reference in a new issue