Commit 6edc17bc

6edc17bcc53eMerged

Yusuke Endoh <[email protected]> · 6 months ago · 2 files · +1 added · ~1 modified

Description

fix(codegen): AndNode wraps poly operand with sp_poly_truthy

a && b lowered to raw C a && b regardless of operand type. When either side is sp_RbVal (poly — e.g. an ivar widened to poly via heterogeneous writes), C rejects && between a struct and an int. Mirror the existing OrNode handling: wrap poly operands with sp_poly_truthy before the boolean combinator.

Co-Authored-By: Claude Opus 4.7 (1M context) [email protected]

Details

Commit
6edc17bcc53e
Parent
300441b5bc36

spinel_codegen.rbmodifiedView file

@@ -16524,7 +16524,13 @@
1652416524 return compile_unless_expr(nid)
1652516525 end
1652616526 if t == "AndNode"
16527- return "(" + compile_expr(@nd_left[nid]) + " && " + compile_expr(@nd_right[nid]) + ")"
16527+ lt = infer_type(@nd_left[nid])
16528+ rt = infer_type(@nd_right[nid])
16529+ le = compile_expr(@nd_left[nid])
16530+ re = compile_expr(@nd_right[nid])
16531+ le_t = lt == "poly" ? "sp_poly_truthy(" + le + ")" : le
16532+ re_t = rt == "poly" ? "sp_poly_truthy(" + re + ")" : re
16533+ return "(" + le_t + " && " + re_t + ")"
1652816534 end
1652916535 if t == "OrNode"
1653016536 left_nid = @nd_left[nid]