1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

fmt: mark imports as used, when types from them are used in struct declarations (#8810)

This commit is contained in:
zakuro 2021-02-18 18:32:45 +09:00 committed by GitHub
parent a34a1ab864
commit 0d69d97143
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 13 additions and 0 deletions

View File

@ -674,6 +674,7 @@ pub fn (mut f Fmt) struct_decl(node ast.StructDecl) {
}
}
for embed in node.embeds {
f.mark_types_import_as_used(embed.typ)
styp := f.table.type_to_str(embed.typ)
f.writeln('\t$styp')
}
@ -728,6 +729,7 @@ pub fn (mut f Fmt) struct_decl(node ast.StructDecl) {
}
f.write(strings.repeat(` `, field_align.max_len - field.name.len - comments_len))
f.write(field_types[i])
f.mark_types_import_as_used(field.typ)
attrs_len := inline_attrs_len(field.attrs)
has_attrs := field.attrs.len > 0
if has_attrs {

View File

@ -1,10 +1,15 @@
import math { max, min }
import cli { Command }
import math.complex { complex, Complex }
import os {
user_os,
file_ext,
}
struct App {
command Command
}
fn imaginary(im f64) Complex {
return complex(0, im)
}

View File

@ -1,10 +1,16 @@
import math { max,
min,
}
import cli { Command }
import math.complex { complex, Complex }
import os {
input, user_os, file_ext }
struct App {
command Command
}
fn imaginary(im f64) Complex {
return complex(0, im)
}