You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The build-parity.test.ts sample-project (JS) fixture fails because native emits a receiver edge main → Calculator that WASM does not.
Root cause: For a CJS require pattern like const { Calculator } = require('./utils'):
Native extractor adds the CJS require to symbols.imports (with cjs_require = Some(true)), so buildImportedNamesForNative includes Calculator in imported_names. In emit_receiver_edge, is_local_definition = false → global fallback → finds the class in utils.js → emits receiver edge. ✓ Correct.
WASM extractor puts CJS requires into symbols.cjsRequireBindings (NOT symbols.imports). buildImportedNamesMap only iterates symbols.imports, so Calculator is not in importedNames. In resolveReceiverEdge, isLocalDefinition = true (same-file function node exists) → restricted to same-file receiver-kind candidates (empty) → no receiver edge. ✗ Incorrect.
Fix
buildImportedNamesMap (used by WASM path in buildFileCallEdges) should also process symbols.cjsRequireBindings to include CJS-required names. This matches what buildImportArtifactNames does on the PR #1688 branch.
Alternatively, wire buildImportArtifactNames into buildFileCallEdges as the 1683 branch does.
Context
Native receiver-edge test receiver_edge_imported_function_node_falls_through_to_global_class documents the expected behavior.
This divergence was hidden because the TS build was broken (wrong arg count to resolveReceiverEdge) and the dist was stale.
Problem
The
build-parity.test.tssample-project (JS) fixture fails because native emits areceiveredgemain → Calculatorthat WASM does not.Root cause: For a CJS require pattern like
const { Calculator } = require('./utils'):Native extractor adds the CJS require to
symbols.imports(withcjs_require = Some(true)), sobuildImportedNamesForNativeincludesCalculatorinimported_names. Inemit_receiver_edge,is_local_definition = false→ global fallback → finds the class in utils.js → emits receiver edge. ✓ Correct.WASM extractor puts CJS requires into
symbols.cjsRequireBindings(NOTsymbols.imports).buildImportedNamesMaponly iteratessymbols.imports, soCalculatoris not inimportedNames. InresolveReceiverEdge,isLocalDefinition = true(same-file function node exists) → restricted to same-file receiver-kind candidates (empty) → no receiver edge. ✗ Incorrect.Fix
buildImportedNamesMap(used by WASM path inbuildFileCallEdges) should also processsymbols.cjsRequireBindingsto include CJS-required names. This matches whatbuildImportArtifactNamesdoes on the PR #1688 branch.Alternatively, wire
buildImportArtifactNamesintobuildFileCallEdgesas the 1683 branch does.Context
receiver_edge_imported_function_node_falls_through_to_global_classdocuments the expected behavior.resolveReceiverEdge) and the dist was stale.buildImportArtifactNameswhich fixes this for theresolveReceiverEdgecall inbuildFileCallEdges.