ERR/E2: multi-value failables -> (T1, ..., !)
Generalize the single-value `-> (T, !)` error-channel ABI to any value arity. Retire the five `fields.len == 2` bails (lowerFailableSuccessReturn, lowerTry, lowerCatch, lowerFailableOr, and the inferExprType try/catch/or arms); lowerRaise + emitErrorReturn already looped over N value slots. New helpers centralize "value-part = every slot but the last (error) one": failableSuccessType (lone value type, or a value-tuple), extractSuccessValue, extractErrorSlot. Fix one latent bug the feature surfaced: coerceToType had no tuple->tuple arm, so a value-tuple flowing into a differently-typed success slot (e.g. (s64,s64) catch body into (s32,s32)) fell through unchanged. Add element-wise coercion. No lowerTupleLiteral change is needed: a `return (a, b)` literal against a 3-field failable target already gets target_fields=null via the arity mismatch, so it types as a plain value-tuple that lowerFailableSuccessReturn consumes. examples/235-multi-value-failable.sx exercises producer return/raise, destructure (binding every slot incl. the error tag), multi-value try (success + propagation), catch (bare-expr tuple body), and or-tuple terminator. Match-body tuple arms are left out: `(` after `case PAT:` is parsed as a payload capture (a pre-existing, multi-value-unrelated parser bug). Gates: zig build, zig build test, 273/273 examples.
This commit is contained in:
1
tests/expected/235-multi-value-failable.exit
Normal file
1
tests/expected/235-multi-value-failable.exit
Normal file
@@ -0,0 +1 @@
|
||||
164
|
||||
1
tests/expected/235-multi-value-failable.txt
Normal file
1
tests/expected/235-multi-value-failable.txt
Normal file
@@ -0,0 +1 @@
|
||||
multi-value result: 164
|
||||
Reference in New Issue
Block a user