Repository navigation
fix(csharp): never bind a nameless member-call receiver to a same-named method in the file - #4422
nixvideojuego-ui wants to merge 1 commit into
Conversation
…ed method in the file A C# member call whose receiver has no capturable name — a member chain (`run.Sequence.Apply()`, `s.Items.Count()`), an invocation (`Make().Apply()`) or a `new X(...)` — reached the per-file bare-name map, because the C# defer rule required `member_receiver`. It then bound to the caller's own same-named method as an EXTRACTED edge: a false self-loop (`a.look.LateUpdate()` inside `LateUpdate()`), LINQ `Count()` bound to a local `Count()`, or a typed chain landing on the wrong class instead of reaching `receiver_chain` resolution. Every C# member call now defers. A typed chain still resolves through `receiver_chain`; `new X(...).M()` (Graphify-Labs#1770) is typed from the construction so it keeps its edge; anything untypable gets no edge (fail-closed). Fixes Graphify-Labs#4418. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Thanks for the pull request, @nixvideojuego-ui. A maintainer will review it soon. Want to talk it through while it is in review? Come join us on our Discord server. For longer-form discussion there is also GitHub Discussions. A couple of things that speed up review: make sure the test suite passes on Python 3.10 and 3.13, and that the change keeps extraction deterministic. |
There was a problem hiding this comment.
Graphify reviewed this change.
No issues found by static checks — no coupling regressions or blocking issues in the code graph. That is not the same as safe to merge: see what was not checked.
Not checked: tests were not run; formal verification proved 0 of 1 changed function(s) (1 not verified).
Formal verification. PR-changed functions: 0/1 verified (0 proven, 0 may-equivalent, 0 distinguished) · 1 not verified (1 unsupported).
Not verified on this run: \_extract\_generic (unsupported).
Graphify review — findings
Stops C# member calls whose receiver has no capturable name (run.Sequence.Apply(), Make().Apply(), s.Items.Count()) from falling back to the file's bare-name map, which bound them to the caller's own same-named method as false self-loops or sibling edges. Every C# member call now defers: a typed chain still resolves through receiver_chain, and anything else gets no edge. new X(...).M() is typed from the constructed X, so those calls keep resolving under the stricter rule.
No blocking issues surfaced. 2 lower-confidence candidates did not survive cross-model review.
Analysis details — impact, health, verification
Impact & health
Graphify review
Impact — 920 functions depend on the 341 functions this change touches.
Health — grade A; 10 existing hotspot(s) in the area this change touches (pre-existing, not introduced here):
_extract_generic()— 20 callers, 40 callees (high)extract_js()— 91 callers, 7 callees (high)extract_objc()— 25 callers, 13 callees (high)extract_xaml()— 19 callers, 17 callees (high)extract_php()— 38 callers, 5 callees (high)extract_cpp()— 37 callers, 5 callees (high)extract_julia()— 22 callers, 8 callees (high)extract_svelte()— 14 callers, 8 callees (high)- …and 2 more
Verification — 920 functions in the blast radius were not formally verified this run (proofs are advisory here).
Gate & verification
graphify gate
PASS — objectively clean (no health regressions, tests not run — proofs not run this pass (advisory)). Grounded, not self-assessed.
Advisory (not blocking):
- verification_scope: 809 function(s) in the blast radius were not formally verified this run
Test selection
Test selection
37 of 412 test file(s) selected (9%) via static blast radius.
tests/test_astro_extraction.py— impacttests/test_build.py— impacttests/test_cjs_module_extension.py— impacttests/test_cpp_nested_and_cli.py— impacttests/test_csharp_member_chain_calls.py— impact, changed-testtests/test_csharp_partial_classes.py— impacttests/test_dotnet.py— impacttests/test_ejs_extractor.py— impacttests/test_extract.py— impacttests/test_extract_php_closures.py— impacttests/test_import_extension_resolution.py— impacttests/test_indirect_call_block_scoped_shadow.py— impacttests/test_indirect_dispatch.py— impacttests/test_indirect_dispatch_assign_return.py— impacttests/test_indirect_dispatch_getattr.py— impacttests/test_java_member_calls.py— impacttests/test_js_exported_scalar_bindings.py— impacttests/test_languages.py— impacttests/test_multilang.py— impacttests/test_php_unparsed_casts.py— impacttests/test_python_inherited_method_calls.py— impacttests/test_python_property_reads.py— impacttests/test_python_underscore_resolution.py— impacttests/test_rationale.py— impacttests/test_ruby_resolution.py— impacttests/test_scala_context_bounds.py— impacttests/test_scala_given_instances.py— impacttests/test_scala_self_type.py— impacttests/test_scala_top_level_binding.py— impacttests/test_scala_type_definition.py— impacttests/test_svelte_extraction.py— impacttests/test_swift_computed_properties.py— impacttests/test_swift_protocol_requirements.py— impacttests/test_trailing_newline_not_a_syntax_error.py— impacttests/test_ts_new_expression_calls.py— impacttests/test_typescript_module_extensions.py— impacttests/test_vue_extraction.py— impact
Selection is safe under the controlled-regression assumption; always-run tests + a periodic full run are the backstops. Advisory — it never changes the check verdict.
Formal verification
Could not verify: Could not verify \_extract\_generic.
The verifier did not have enough to check \_extract\_generic, so it is saying so rather than guessing. No false assurance is the whole point.
Guarantee: No guarantee either way, this is an honest abstention, not a pass.
Note: Reason: no capturable inputs from the test suite; property tier: parameter `config` is annotated `LanguageConfig` — outside the synthesizable primitive/collection set
|
Ran the full suite on Python 3.10 and 3.13 as suggested (Windows 11,
The extra passes are this PR's 3 new tests. The 17 failures are the same tests on the branch and on untouched
On determinism: the change only reads the parsed tree and the per-class field tables already built during extraction. It does not depend on the environment, filesystem order or anything nondeterministic. |
C# nameless / `new X()` / `foreach` receiver resolution (#4422, #4428, #4423) and `_`/case-distinct node ids (#4416) change AST extraction output, so warm caches must re-extract. Co-Authored-By: Claude Opus 4.8 <[email protected]>
|
Shipped in v0.9.90, just released to PyPI as |
What does this PR do?
Fixes #4418.
A C# member call whose receiver has no capturable name reached the per-file bare-name map, because the C# defer rule required
member_receiver. This covers a member chain (run.Sequence.Apply(),s.Items.Count()), an invocation (Pick().look.LateUpdate()) and anew X(...).M(). The call then bound to the caller's own same-named method as anEXTRACTEDedge:Count()bound to a localCount();receiver_chainresolution from C#: calls through a member chain, through element access, or inside a constructor produce no edge (follow-up to #3797) #4246.Changes:
_csharp_defernow covers every C# member call, so no member call uses the bare-name map. A typed chain still resolves throughreceiver_chain, and anything untypable gets no edge (fail-closed, the intent of C#: method calls on a typed receiver (field/param/local.Method()) are not emitted ascallsedges #1609).new X(...).M()(C#: calls/references missed when chained directly off a new X(...) expression #1770) used to get its edge from that same bare-name fallback. Its receiver is now typed from the construction (receiver_chain = [X]), sotest_method_chained_off_new_expression_resolveskeeps passing for the right reason.Type of change
Verification & Invariants
Invariant: a C# member call binds by receiver evidence or not at all. A same-file method that only shares the name is never evidence.
tests/test_csharp_member_chain_calls.py. All 3 fail onv8(e8eb76e) and pass here.Limitations (recall trade, like the Python #2586 note): a call that only resolved through the name collision now gets no edge. Typical cases:
component.gameObject.GetAsyncX()landing on a same-named overload in the same static class);new X<T>().M()whose bareXnames both a generic and a non-generic type.On a 1,512-file Unity C# codebase (game code plus vendored UniTask, LeanTween and MsgPack), this branch alone changes the
callsedges as follows:I spot-checked samples of both sides against the source. The removed edges were mis-bindings such as
transform.gameObject.SetActive(),float.Equals()andcompletionSource.TrySetResult()on the wrong class. The added edges were typed chains now reachingreceiver_chain, such ast.Character.ApplyStatusFromHit()andclient.Auth.SignInAnonymously().How was this tested?
All 15 full-suite failures also fail on an untouched
v8checkout on the same machine (Windows 11, Python 3.14), so they come from the environment:test_skillgen×11;test_hooks::test_shebang_parse_requires_leading_hash_bang;*_memoization::test_absolute_path_lookup_skips_getcwd;test_extract::test_c_include_out_of_root_target_id_is_deterministic_across_checkout_paths.Graphify-specific checklist
uv run python -m tools.skillgen --bless) when changing their source fragments. (N/A: no fragments touched)🤖 Generated with Claude Code