Commit 0238ed48
0238ed488085Merged
Yukihiro "Matz" Matsumoto <[email protected]> · 5 months ago · 2 files · ~2 modified
Description
Fix UnlessNode else_clause field and empty-array param type coercion
Prism uses else_clause for UnlessNode's else branch (not subsequent
which IfNode uses). Fixed in three sites: analyze.c infer_type, and
codegen.c emit_if + emit_expr ternary form.
Also fix emit_arg_or_default: when passing an empty [] literal to a
function expecting a non-IntArray array type, emit the correct typed
constructor (e.g. sp_StrArray_new()) rather than falling through to
sp_IntArray_new().
Fixes unless_return_path_hash.
Co-Authored-By: Claude Sonnet 4.6 [email protected]
Details
- Commit
- 0238ed488085
- Parent
- 61106976a2a6
src/analyze.cmodifiedView file
@@ -999,8 +999,9 @@
999999
return r;10001000
}10011001
if (!strcmp(ty, "IfNode") || !strcmp(ty, "UnlessNode")) {1002+
int is_unless = !strcmp(ty, "UnlessNode");10021003
int then_b = nt_ref(nt, id, "statements");1003-
int else_b = nt_ref(nt, id, "subsequent");1004+
int else_b = nt_ref(nt, id, is_unless ? "else_clause" : "subsequent");10041005
TyKind tt = then_b >= 0 ? infer_type(c, then_b) : TY_NIL;10051006
TyKind et = else_b >= 0 ? infer_type(c, else_b) : TY_NIL;10061007
return ty_unify(tt, et);src/codegen.cmodifiedView file
Loading diff…