cgen: fix order of comptime reflection fields (#12799)
parent
0d0d7323bb
commit
2ced182816
|
@ -492,13 +492,10 @@ fn (mut g Gen) comptime_for(node ast.ComptimeFor) {
|
||||||
} else if node.kind == .fields {
|
} else if node.kind == .fields {
|
||||||
// TODO add fields
|
// TODO add fields
|
||||||
if sym.info is ast.Struct {
|
if sym.info is ast.Struct {
|
||||||
mut fields := sym.info.fields.filter(it.attrs.len == 0)
|
if sym.info.fields.len > 0 {
|
||||||
fields_with_attrs := sym.info.fields.filter(it.attrs.len > 0)
|
|
||||||
fields << fields_with_attrs
|
|
||||||
if fields.len > 0 {
|
|
||||||
g.writeln('\tFieldData $node.val_var = {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_var = node.val_var
|
||||||
g.comptime_for_field_value = field
|
g.comptime_for_field_value = field
|
||||||
g.writeln('/* field $i */ {')
|
g.writeln('/* field $i */ {')
|
||||||
|
|
|
@ -43,7 +43,7 @@ fn print_field_values<T>(s T) {
|
||||||
|
|
||||||
struct Foo {
|
struct Foo {
|
||||||
name string
|
name string
|
||||||
password string
|
password string [this_will_not_change_the_order]
|
||||||
email string
|
email string
|
||||||
age int
|
age int
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue