From d7728dcc37ae60b50abd9961d79df1cc598b4f1c Mon Sep 17 00:00:00 2001 From: Felipe Pena Date: Mon, 23 Dec 2024 22:45:08 -0300 Subject: [PATCH] fix --- vlib/v/checker/comptime.v | 1 + vlib/v/tests/skip_unused/comptime_for_fields.run.out | 1 + .../comptime_for_fields.skip_unused.run.out | 1 + vlib/v/tests/skip_unused/comptime_for_fields.vv | 11 +++++++++++ 4 files changed, 14 insertions(+) create mode 100644 vlib/v/tests/skip_unused/comptime_for_fields.run.out create mode 100644 vlib/v/tests/skip_unused/comptime_for_fields.skip_unused.run.out create mode 100644 vlib/v/tests/skip_unused/comptime_for_fields.vv diff --git a/vlib/v/checker/comptime.v b/vlib/v/checker/comptime.v index aee7aea3ddfff8..894e4f10c6c146 100644 --- a/vlib/v/checker/comptime.v +++ b/vlib/v/checker/comptime.v @@ -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') } diff --git a/vlib/v/tests/skip_unused/comptime_for_fields.run.out b/vlib/v/tests/skip_unused/comptime_for_fields.run.out new file mode 100644 index 00000000000000..baed14f1276d6a --- /dev/null +++ b/vlib/v/tests/skip_unused/comptime_for_fields.run.out @@ -0,0 +1 @@ +['alias'] diff --git a/vlib/v/tests/skip_unused/comptime_for_fields.skip_unused.run.out b/vlib/v/tests/skip_unused/comptime_for_fields.skip_unused.run.out new file mode 100644 index 00000000000000..baed14f1276d6a --- /dev/null +++ b/vlib/v/tests/skip_unused/comptime_for_fields.skip_unused.run.out @@ -0,0 +1 @@ +['alias'] diff --git a/vlib/v/tests/skip_unused/comptime_for_fields.vv b/vlib/v/tests/skip_unused/comptime_for_fields.vv new file mode 100644 index 00000000000000..52d728c431f06d --- /dev/null +++ b/vlib/v/tests/skip_unused/comptime_for_fields.vv @@ -0,0 +1,11 @@ +module main + +struct Post { + title string @[alias] +} + +fn main() { + $for field in Post.fields { + println(field.attrs) + } +}