Resolve receiver method registration collisions - #10745
Conversation
|
End-to-end RocRay validation is now complete against a locally built nightly-equivalent compiler: source commit The full
This also confirms the published-nightly failure mode: the unpatched The generated RocRay ABI changed as expected for the newer compiler (including the erased-callable ABI), and the existing host changes in that RocRay worktree compile and pass runtime smoke coverage with it. |
Greptile SummaryThe PR moves receiver-method collision handling into canonicalization so receiver-owned declarations consistently take precedence over namespace extensions without producing duplicate finalized keys.
Confidence Score: 5/5The PR appears safe to merge; no concrete blocking or independently actionable non-blocking issue was identified. The collision policy covers both registration orders, paired method-table mutations preserve key alignment before finalization, and the focused regression verifies dispatch and qualified-call behavior.
|
| Filename | Overview |
|---|---|
| src/canonicalize/Can.zig | Introduces construction-time registration provenance and explicit, source-order-independent collision handling for receiver dispatch. |
| src/canonicalize/ModuleEnv.zig | Adds paired append and indexed replacement operations that keep method identity and definition tables synchronized. |
| src/cli/test/parallel_cli_runner.zig | Wires the receiver-method precedence regression into the parallel CLI suite. |
| test/cli/ReceiverMethodDeclarationPrecedence.roc | Verifies qualified functions remain callable and receiver declarations win in both source orders. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[Associated method discovered] --> B[Build receiver-owner and method-name key]
B --> C{Existing registration?}
C -- No --> D[Append identity and definition entries]
C -- Yes --> E{Existing and new kinds}
E -- Declaration then extension --> F[Keep declaration]
E -- Extension then declaration --> G[Replace entry with declaration]
E -- Extension then extension --> H[Emit shadowing diagnostic]
H --> I[Replace entry with later extension]
D --> J[Finalize unique sorted method tables]
F --> J
G --> J
I --> J
Reviews (1): Last reviewed commit: "Resolve receiver method and alias reques..." | Re-trigger Greptile
Problem
A receiver can have both a method declared in its own associated block and a receiver extension declared in an empty nominal namespace. Canonicalization appended both registrations under the same
(receiver owner, method name)key. Unique method-table finalization therefore trapped in release builds and reported this invariant in Debug builds:RocRay reproduces this with
Program.Update.map/map2and the correspondingProgram.map/map2namespace extensions. This prevented RocRay from updating tonightly-2026-08-12-606470f.Fix
Canonicalization now owns construction-time collision policy explicitly:
ModuleEnvappends and replaces the parallel method identity/definition entries atomically, so unique finalization remains a strict invariant rather than silently deduplicating malformed producer output.The focused regression covers both declaration orders and verifies qualified calls plus receiver dispatch.
This extracts the focused method-registration work from #10717. The later
Fix parallel MiniCI failurescommit from that PR was audited but intentionally not included: it also depends on broad evaluator, Boxy, host-effect, and Monotype changes from the rest of #10717, while this focused branch passes MiniCI unchanged.Validation
On the original nightly base (
606470f):zig build minici: 75/75 phases passedzig build run-test-zig-module-cangit diff --checkgatesroc check,roc fmt --check, androc testAfter rebasing onto current
main(446d128at validation time):zig build run-test-zig-module-canpassedgit diff --checkgates passedA full current-main RocRay sweep is independently blocked by
roc-random 0.9.0using APIs/inference that changed after the August 12 nightly (Iter.revand numeric shift inference); the method-registration failure itself remains fixed.