Skip to content

Commit

Permalink
checker: fix generate dump code for array fixed struct field (#19886)
Browse files Browse the repository at this point in the history
  • Loading branch information
felipensp committed Nov 16, 2023
1 parent 192d6d2 commit ae98080
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
8 changes: 8 additions & 0 deletions vlib/v/checker/comptime.v
Expand Up @@ -284,6 +284,14 @@ fn (mut c Checker) comptime_for(mut node ast.ComptimeFor) {
unwrapped_expr_type := c.unwrap_generic(field.typ)
tsym := c.table.sym(unwrapped_expr_type)
c.table.dumps[int(unwrapped_expr_type.clear_flags(.option, .result, .atomic_f))] = tsym.cname
if tsym.kind == .array_fixed {
info := tsym.info as ast.ArrayFixed
if !info.is_fn_ret {
// for dumping fixed array we must register the fixed array struct to return from function
c.table.find_or_register_array_fixed(info.elem_type, info.size,
info.size_expr, true)
}
}
}
c.comptime_for_field_var = ''
c.inside_comptime_for_field = false
Expand Down
11 changes: 11 additions & 0 deletions vlib/v/tests/comptime_array_fixed_field_test.v
@@ -0,0 +1,11 @@
struct Another {
a [3]int
b [4]u8
c [2]u32
}

fn test_main() {
$for f in Another.fields {
}
assert true
}

0 comments on commit ae98080

Please sign in to comment.