Skip to content

Commit

Permalink
markused: fix codegen for comptime $for (fix vlang#23252) (vlang#23254
Browse files Browse the repository at this point in the history
)
  • Loading branch information
felipensp authored Dec 24, 2024
1 parent e6c1637 commit 61097a0
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 0 deletions.
1 change: 1 addition & 0 deletions vlib/v/checker/comptime.v
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,7 @@ fn (mut c Checker) comptime_for(mut node ast.ComptimeFor) {
for field in fields {
c.push_new_comptime_info()
c.comptime.inside_comptime_for = true
c.table.used_features.comptime_for = true
if c.field_data_type == 0 {
c.field_data_type = c.table.find_type('FieldData')
}
Expand Down
1 change: 1 addition & 0 deletions vlib/v/tests/skip_unused/comptime_for_fields.run.out
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
['alias']
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
['alias']
11 changes: 11 additions & 0 deletions vlib/v/tests/skip_unused/comptime_for_fields.vv
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module main

struct Post {
title string @[alias]
}

fn main() {
$for field in Post.fields {
println(field.attrs)
}
}

0 comments on commit 61097a0

Please sign in to comment.