fix(types): type force-unwrap so opt!.field chains resolve [0101]

ExprTyper.inferType had no `.force_unwrap` arm, so `mk()!` typed as
`.unresolved`. The bind-first form (`v := mk()!; v.field`) worked because
lowerForceUnwrap produces a correctly typed value stored in a slot, but the
chained `mk()!.field` re-derives the receiver type via inferExprType and got
`.unresolved` — the struct-field lookup failed, the field read emitted as
`undef` (garbage), and `mk()!.method()` failed to resolve the method.

Add a `.force_unwrap` arm resolving the operand's optional child type. One
arm fixes every chained form — field, nested `opt!.a.b`, `opt!.method()`
(pointer + value receiver), and `opt![i]` all route receiver typing through
inferExprType.

Regression: examples/0905-optionals-unwrap-field-chain.sx — garbage / compile
error pre-fix, all correct after.
This commit is contained in:
agra
2026-06-06 07:42:17 +03:00
parent 52310b6df1
commit 6f2a1dc3dc
6 changed files with 152 additions and 0 deletions

View File

@@ -0,0 +1 @@
0

View File

@@ -0,0 +1 @@

View File

@@ -0,0 +1,10 @@
chain id: hello
chain n: 42
bind id: hello
bind n: 42
meth ptr: hello
meth val: 50
nest tag: deep
nest k: 7
index 0: 10
index 2: 30