1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

cgen: fix order of comptime reflection fields (#12799)

This commit is contained in:
Leo Developer 2021-12-11 21:09:47 +01:00 committed by GitHub
parent 0d0d7323bb
commit 2ced182816
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 6 deletions

View File

@ -492,13 +492,10 @@ fn (mut g Gen) comptime_for(node ast.ComptimeFor) {
} else if node.kind == .fields {
// TODO add fields
if sym.info is ast.Struct {
mut fields := sym.info.fields.filter(it.attrs.len == 0)
fields_with_attrs := sym.info.fields.filter(it.attrs.len > 0)
fields << fields_with_attrs
if fields.len > 0 {
if sym.info.fields.len > 0 {
g.writeln('\tFieldData $node.val_var = {0};')
}
for field in fields {
for field in sym.info.fields {
g.comptime_for_field_var = node.val_var
g.comptime_for_field_value = field
g.writeln('/* field $i */ {')

View File

@ -43,7 +43,7 @@ fn print_field_values<T>(s T) {
struct Foo {
name string
password string
password string [this_will_not_change_the_order]
email string
age int
}