Commit c185dd8f
c185dd8f0a30Merged
Sam Ruby <[email protected]> · 5 months ago · 2 files · ~2 modified
Description
review: rename ret_void -> ret_no_value; make test RBS block optional
Addresses the Copilot review on #1444:
- The flag is now true for both TY_VOID and TY_NIL, so
ret_voidwas misleading; rename toret_no_value("no usable value to return"). around's RBS required a block while its Ruby body guardsif block; make the RBS block optional (?{ ... }) so the signature matches the implementation (and the realyield if blockpattern it models). The extractor drops block annotations either way, so the seeded path and the regression are unchanged.
Co-Authored-By: Claude Opus 4.8 (1M context) [email protected]
Details
- Commit
- c185dd8f0a30
- Parent
- 616df163df80
src/codegen.cmodifiedView file
@@ -1095,10 +1095,10 @@
10951095
emit `return <void-call>;` and fail to compile; a TY_NIL proc returns10961096
nil regardless of the tail expression's value, so emit it as a10971097
statement and fall through to `return 0`. */1098-
int ret_void = (ret == TY_VOID || ret == TY_NIL);1098+
int ret_no_value = (ret == TY_VOID || ret == TY_NIL);10991099
int ret_poly = (ret == TY_POLY);11001100
int ret_fbox = (ret == TY_FLOAT); /* boxed through the poly return slot */1101-
if (!proc_slot_is_direct(ret) && !ret_ptr && !ret_void && !ret_poly && !ret_fbox) {1101+
if (!proc_slot_is_direct(ret) && !ret_ptr && !ret_no_value && !ret_poly && !ret_fbox) {11021102
free(params.v); free(used.v); free(locals.v); free(caps.v);11031103
unsupported(c, create, "proc with range/time return (later slice)");11041104
return;@@ -1222,8 +1222,9 @@
12221222
g_result_var = NULL; g_result_poly = 0;12231223
buf_puts(pb, " return 0;\n");12241224
}1225-
else if (ret_void) {1226-
/* no usable value: run the body as plain statements, return nil (0) */1225+
else if (ret_no_value) {1226+
/* no usable value (TY_VOID or TY_NIL): run the body as plain statements,1227+
return nil (0) */12271228
emit_stmts(c, body, pb, 1);12281229
buf_puts(pb, " return 0;\n");12291230
}test/rbs-seed/sig/void_block_tail.rbsmodifiedView file
Loading diff…