mirror of
https://github.com/vlang/v.git
synced 2025-09-22 03:48:34 -04:00
cgen: fix type_default for array init >= 8 items (spotted while building the vhamll project) (#23334)
This commit is contained in:
parent
87c0a9ce28
commit
a366582010
@ -7043,7 +7043,7 @@ fn (mut g Gen) type_default_impl(typ_ ast.Type, decode_sumtype bool) string {
|
||||
}
|
||||
} else {
|
||||
default_str := g.expr_string_opt(field.typ, field.default_expr)
|
||||
if default_str.count('\n') > 1 {
|
||||
if default_str.count(';\n') > 1 {
|
||||
g.type_default_vars.writeln(default_str.all_before_last('\n'))
|
||||
expr_str = default_str.all_after_last('\n')
|
||||
} else {
|
||||
|
15
vlib/v/tests/structs/default_expr_array_init_test.v
Normal file
15
vlib/v/tests/structs/default_expr_array_init_test.v
Normal file
@ -0,0 +1,15 @@
|
||||
struct Foo {
|
||||
pub mut:
|
||||
integer_range_for_discrete []int = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
|
||||
}
|
||||
|
||||
fn foo(a string) Foo {
|
||||
return match a {
|
||||
'a' { Foo{} }
|
||||
else { panic('foo') }
|
||||
}
|
||||
}
|
||||
|
||||
fn test_main() {
|
||||
assert foo('a') == Foo{}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user