vfmt: remove empty __global() (#20004)

This commit is contained in:
Jose Mendoza 2023-11-27 06:59:27 -04:00 committed by GitHub
parent 52e41f8879
commit f0e4438e08
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 1 additions and 6 deletions

View file

@ -1221,12 +1221,11 @@ pub fn (mut f Fmt) for_stmt(node ast.ForStmt) {
pub fn (mut f Fmt) global_decl(node ast.GlobalDecl) { pub fn (mut f Fmt) global_decl(node ast.GlobalDecl) {
f.attrs(node.attrs) f.attrs(node.attrs)
if node.fields.len == 0 && node.pos.line_nr == node.pos.last_line { if node.fields.len == 0 && node.pos.line_nr == node.pos.last_line {
f.writeln('__global ()') // remove "__global()"
return return
} }
f.write('__global ') f.write('__global ')
mut max := 0 mut max := 0
// mut has_assign := false
if node.is_block { if node.is_block {
f.writeln('(') f.writeln('(')
f.indent++ f.indent++
@ -1234,9 +1233,6 @@ pub fn (mut f Fmt) global_decl(node ast.GlobalDecl) {
if field.name.len > max { if field.name.len > max {
max = field.name.len max = field.name.len
} }
// if field.has_expr {
// has_assign = true
//}
} }
} }
for field in node.fields { for field in node.fields {

View file

@ -4,7 +4,6 @@ struct TestInt {
__global x = bool(true) __global x = bool(true)
__global y f32 __global y f32
__global ()
__global ( __global (
spam string spam string
foo = int(5) foo = int(5)