fix(native): skip callback-reference calls for this()/super() call expressions#1548
Conversation
…pressions In handle_call_expr, when the callee node is `this` or `super` (e.g. `this(b)`, `super(a)`), extract_callback_reference_calls was running and emitting identifier arguments as spurious dynamic calls. The pts resolver then matched those names globally, producing false cross-file call edges in the jelly-micro fixture: fun/fun.js:foo → spread/spread.js:b, fun/fun.js:bar → prototypes3/prototypes3.js:c, etc. Fix: add an early return for fn_node.kind() == "this" || fn_node.kind() == "super", mirroring the existing guard in the TypeScript handleCallExpr (javascript.ts:1135). Add two regression tests covering both cases. Closes #1543
Greptile SummaryThis PR addresses a previous review comment about a vacuously true assertion in the
Confidence Score: 5/5Safe to merge — changes are test-only, directly address the prior review comment, and do not touch production logic. The diff is entirely within the test module: one fixture update that turns a vacuously true assertion into a meaningful one, and one corrected issue-reference in a doc comment. The production guard was already in place; these changes only tighten the test coverage around it. No files require special attention. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[handle_call_expr] --> B{fn_node kind}
B -->|import| C[handle_dynamic_import then return]
B -->|this or super| D[early return - no callback-reference calls emitted]
B -->|other| E[extract_call_info - push call record]
E --> F[extract_callback_definition]
F --> G[extract_callback_reference_calls]
H[match_js_pts_bindings walk] -->|call_expression| I[collect_this_call_and_bindings]
I -->|fn is this| J[push Call named this]
I -->|fn is super| K[no call recorded - constructor delegation]
Reviews (3): Last reviewed commit: "test(native): strengthen super-call test..." | Re-trigger Greptile |
| assert!( | ||
| !s.calls.iter().any(|c| c.name == "b"), | ||
| "argument `b` of this.bb = b must not become a callback-reference call; got: {:?}", | ||
| s.calls.iter().map(|c| (&c.name, c.dynamic)).collect::<Vec<_>>() | ||
| ); | ||
| } |
There was a problem hiding this comment.
Second assertion is vacuously true — doesn't exercise the fix
The second assert! checks that b is not emitted as a dynamic call, but b only appears in the assignment this.bb = b, not in any call expression. extract_callback_reference_calls only walks call_expression arguments, so b would never be emitted regardless of this fix. If the intent is to verify that both arguments to a multi-argument super call are suppressed, the fixture should use super(a, b) instead.
Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!
There was a problem hiding this comment.
Fixed — changed the fixture from super(a); this.bb = b; to super(a, b); so that b is a genuine call argument rather than an assignment target. Both assertions now actually exercise the fix by verifying that neither argument of a two-argument super() call is emitted as a dynamic callback-reference call.
Codegraph Impact Analysis1 functions changed → 0 callers affected across 0 files
|
docs check acknowledged: no language support, feature list, or design decision changes
Summary
handle_call_expr(Rust JS extractor), when the callee node isthisorsuperused as a function (this(b),super(a)),extract_callback_reference_callswas running and emitting identifier arguments as spurious dynamic callsfun/fun.js:foo → spread/spread.js:b,classes2/classes2.js:G.constructor → prototypes3/prototypes3.js:a)handle_call_exprforfn_node.kind() == "this" || fn_node.kind() == "super", mirroring the existing guard in the TShandleCallExpr(javascript.ts:1135)this(b)andsuper(a)argument non-emissionRoot cause
The JS extractor (
javascript.ts) has an early return at line 1135 when the function node type isthis:The Rust extractor (
javascript.rs) only checked forfn_node.kind() == "import"before callingextract_callback_reference_calls, sothis(b)/super(a)calls would emitbandaas dynamic calls. The pts resolver then resolved those names globally, finding same-named functions in sibling fixture files.Test plan
this_call_args_do_not_emit_callback_reference_calls,super_call_args_do_not_emit_callback_reference_callsnode scripts/parity-compare.mjs --langs jelly-microeliminates all 6 targeted false-positive edges (13 → 12 divergences; the 6 fixed are the exact ones listed in fix(parity): native emits extra dynamic CHA edges for fun/classes2 fixtures #1543; the remaining 12 are pre-existing issues)Closes #1543