Commit 356f32c6

356f32c6672aMerged

Ori Pekelman <[email protected]> · 6 months ago · 2 files · ~2 modified

Description

test(codegen): assert nil return through poly dispatch, not just side effect

Follow-up per gemini-code-assist's review on PR #388: the poly_nil_return_dispatch test verified that the subclass override's side effect (a puts) ran, but didn't verify that the dispatched call's return value was correctly observable as nil.

Add an explicit result == nil check after h.call_hook(\"ok\") to confirm the boxing path threads the nil result through to the caller, not just the side effect.

Co-Authored-By: Claude Opus 4.7 [email protected]

Details

Commit
356f32c6672a
Parent
2bcd25fac325

test/poly_nil_return_dispatch.rbmodifiedView file

@@ -3,6 +3,12 @@
33 # Previously `box_value_to_poly("nil", call_expr)` dropped `call_expr`
44 # and emitted a bare `sp_box_nil()` for that arm, so the body of the
55 # override never ran.
6+#
7+# Two checks:
8+# 1. The override's side effect runs (the `puts` inside Sub#hook).
9+# 2. The dispatched call's *return value* is correctly observable as
10+# nil (i.e. the boxing path threads through, not just the side
11+# effect).
612
713 class Base
814 def hook(arg); end # empty body -> static return "nil"
@@ -23,4 +29,5 @@
2329
2430 h = Holder.new
2531 h.set(Sub.new)
26-h.call_hook("ok")
32+result = h.call_hook("ok")
33+puts result == nil