Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

checker: fix generate dump code for array fixed struct field #19886

Merged
merged 2 commits into from
Nov 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 8 additions & 0 deletions vlib/v/checker/comptime.v
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
@@ -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
}