fmt: fix pos of added imports (#8931)

pull/8951/head
Lukas Neubert 2021-02-24 19:33:17 +01:00 committed by GitHub
parent 8e9e9b2f89
commit b18d091e18
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 0 deletions

View File

@ -236,6 +236,9 @@ pub fn (mut f Fmt) mod(mod ast.Module) {
}
f.attrs(mod.attrs)
f.writeln('module $mod.short_name\n')
if f.import_pos == 0 {
f.import_pos = f.out.len
}
}
pub fn (mut f Fmt) mark_types_import_as_used(typ table.Type) {

View File

@ -0,0 +1,7 @@
module main
import time
fn main() {
curr_time := time.now()
}

View File

@ -0,0 +1,5 @@
module main
fn main() {
curr_time := time.now()
}