cgen: fix error for time struct init with update (#13660)

pull/13661/head
yuyi 2022-03-05 19:28:48 +08:00 committed by GitHub
parent 8136157f87
commit 22fda7c3dd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 1 deletions

View File

@ -245,7 +245,7 @@ fn (mut g Gen) struct_init(node ast.StructInit) {
}
}
}
g.write(field.name)
g.write(c_name(field.name))
} else {
if !g.zero_struct_field(field) {
nr_fields--

View File

@ -0,0 +1,12 @@
import time
fn test_struct_of_time_init_with_update() {
utc := time.utc()
t := time.Time{
...utc
}
println(utc)
println(t)
assert t == utc
}