Skip to content

Commit 94a91c2

Browse files
authored
cgen: fix codegen for comptime multiline attr (fix #23964) (#24087)
1 parent a3180e5 commit 94a91c2

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

vlib/v/gen/c/comptime.v

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -987,7 +987,8 @@ fn (mut g Gen) comptime_for(node ast.ComptimeFor) {
987987
g.writeln('/* attribute ${i} */ {')
988988
g.writeln('\t${node.val_var}.name = _SLIT("${attr.name}");')
989989
g.writeln('\t${node.val_var}.has_arg = ${attr.has_arg};')
990-
g.writeln('\t${node.val_var}.arg = _SLIT("${attr.arg}");')
990+
g.writeln('\t${node.val_var}.arg = _SLIT("${util.smart_quote(attr.arg,
991+
false)}");')
991992
g.writeln('\t${node.val_var}.kind = AttributeKind__${attr.kind};')
992993
g.stmts(node.stmts)
993994
g.writeln('}')
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
module main
2+
3+
@[footer: 'Hello
4+
World']
5+
pub struct Config {}
6+
7+
fn test_main() {
8+
$for a in Config.attributes {
9+
assert a.arg == 'Hello\nWorld'
10+
}
11+
}

0 commit comments

Comments
 (0)