Skip to content

Commit 7386e90

Browse files
enghitaloclaude
andcommitted
tests: assert the json2 payload decoder, not a helper name, in skip-unused test
`test_skip_unused_keeps_json2_embedded_struct_decode_helpers` hard-coded the generated symbol `x__json2__create_value_from_optional_T_time__Time`. That helper is a json2 implementation detail removed by this PR (the option payload is now built inline with `$zero(field.typ.payload_type)`), after which the symbol no longer exists and the test would fail. Assert `x__json2__Decoder_decode_value_T_time__Time` instead -- the generic instantiation that actually decodes the `?time.Time` payload of the embedded `Meta` struct, reachable only through comptime `$for field` codegen. It is the symbol skip-unused must keep (the point of issue #26928), is present whether or not the json2 helpers exist, and so the test no longer breaks when they are refactored. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 0880487 commit 7386e90

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

vlib/v/tests/skip_unused/generic_fn_instantiation_pruning_test.v

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,11 @@ fn test_skip_unused_keeps_json2_embedded_struct_decode_helpers() {
155155
}
156156
assert res.output.contains('x__json2__decode_struct_key_T_main__Req')
157157
assert res.output.contains('x__json2__check_required_struct_fields_T_main__Req')
158-
assert res.output.contains('x__json2__create_value_from_optional_T_time__Time')
158+
// the `?time.Time` payload of the embedded `Meta` is decoded through a generic
159+
// instantiation reachable only via comptime `$for field` codegen; skip-unused
160+
// must keep it. Assert the payload decoder itself rather than a specific json2
161+
// helper name, so the test does not break when those helpers are refactored.
162+
assert res.output.contains('x__json2__Decoder_decode_value_T_time__Time')
159163
}
160164

161165
fn test_skip_unused_marks_dependencies_inside_generic_anon_fns() {

0 commit comments

Comments
 (0)