Commit d2578fe
fix(typecheck): auto-deref ref/own/mut for struct field access (Refs #122)
`fn(c: ref Point) = c.x` failed with "Field 'x' not found in type
ref {x: Int, ...}": ExprField unified the receiver type directly with
the expected record, so a TRef/TMut/TOwn wrapper made projection fail.
Strip TRef/TMut/TOwn (via repr) before record projection — Rust-like
auto-deref for field access. The borrow checker still governs aliasing
separately; this only affects the *type* of the projected field, which
is identical through a reference. Trait-method fallback path unchanged.
This unblocks receiver-first methods that take `ref/own/mut self|recv`
(the idiomatic, allocation-free form) under the Deno-ESM class synth.
Regression: tests/codegen-deno/ref_fields.{affine,harness.mjs} —
ref/own/mut receivers synthesised as Point methods, field access
verified. `dune runtest` unchanged (same 2 pre-existing E2E Node-CJS
vscode failures, 214 tests, zero new regressions). Deno-ESM suite green.
Refs #122.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>1 parent 3f39c3f commit d2578fe
3 files changed
Lines changed: 43 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
749 | 749 | | |
750 | 750 | | |
751 | 751 | | |
| 752 | + | |
| 753 | + | |
| 754 | + | |
| 755 | + | |
| 756 | + | |
| 757 | + | |
| 758 | + | |
| 759 | + | |
| 760 | + | |
| 761 | + | |
| 762 | + | |
752 | 763 | | |
753 | 764 | | |
754 | 765 | | |
755 | | - | |
| 766 | + | |
756 | 767 | | |
757 | 768 | | |
758 | 769 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
0 commit comments