diff --git a/vlib/v/fmt/fmt.v b/vlib/v/fmt/fmt.v index 865f4243b8..f45d7419ec 100644 --- a/vlib/v/fmt/fmt.v +++ b/vlib/v/fmt/fmt.v @@ -1103,6 +1103,9 @@ pub fn (mut f Fmt) global_decl(node ast.GlobalDecl) { } for field in node.fields { f.comments(field.comments, inline: true) + if field.is_volatile { + f.write('volatile ') + } f.write('$field.name ') f.write(strings.repeat(` `, max - field.name.len)) if field.has_expr { diff --git a/vlib/v/fmt/tests/global_keep.vv b/vlib/v/fmt/tests/global_keep.vv index e809f3d2fe..a16bcb3db4 100644 --- a/vlib/v/fmt/tests/global_keep.vv +++ b/vlib/v/fmt/tests/global_keep.vv @@ -1,3 +1,7 @@ +struct TestInt { + i int +} + __global x = bool(true) __global y f32 __global () @@ -6,5 +10,8 @@ __global ( foo = int(5) ) __global ( - a int + a int + volatile test_int = TestInt{ + i: 0 + } )