Commit 483fd088
483fd088b459Merged
Yukihiro "Matz" Matsumoto <[email protected]> · 6 months ago · 3 files · +2 added · ~1 modified
Description
fix(codegen): File.write at expression level mirrors File.binwrite
The statement-context lowering at compile_control_call_stmt already routed File.write to sp_file_write. The expression- level path at compile_expr only recognized File.binwrite; File.write as the tail expression of a method body fell through to compile_expr (the route compile_body_return_inner takes for arbitrary CallNodes outside the small hardcoded side-effect list) and emitted the unresolved-call warning plus a literal 0, silently dropping the write.
Alias write to binwrite in the same arm so both call shapes lower identically. File.write in CRuby returns the byte count written; we return 0 to match the statement-context lowering (which also discards the count). The unresolved-call warning on Ori Pekelman's #549 repro disappears with this change.
Refs #549
Co-Authored-By: Claude Opus 4.7 (1M context) [email protected]
Details
- Commit
- 483fd088b459
- Parent
- d5413c7f577d
spinel_codegen.rbmodifiedView file
if mname == "delete" return "(sp_file_delete(" + compile_arg0(nid) + "), 0)" end if mname == "binwrite" if mname == "binwrite" || mname == "write" # NOTE: `sp_file_write` uses fputs, so an embedded NUL # in the payload truncates the write — fine for the # in the payload truncates the write; fine for the # optcarrot save-RAM dead-code path that surfaced # this, not safe for general binary use. # this, not safe for general binary use. File.write # in CRuby returns the number of bytes written; we # return 0 to match the statement-context lowering at # compile_control_call_stmt (which also discards the # byte count). args_id_bw = @nd_arguments[nid] if args_id_bw >= 0 a_bw = get_args(args_id_bw)test/file_write_at_tail_position.rbaddedView file
Loading diff…
test/file_write_at_tail_position.rb.expectedaddedView file
Loading diff…