vfmt: keep selective imported names used for generic calls
ci/woodpecker/push/vc Pipeline was successful Details
ci/woodpecker/push/docker Pipeline was successful Details
ci/woodpecker/push/arch Pipeline was successful Details

Delyan Angelov 2022-05-19 12:48:37 +03:00 committed by Jef Roosens
parent 7c7d59acee
commit f9079b6700
Signed by: Jef Roosens
GPG Key ID: B75D4F293C7052DB
2 changed files with 5 additions and 0 deletions

View File

@ -1694,6 +1694,7 @@ fn (mut f Fmt) write_generic_call_if_require(node ast.CallExpr) {
name = 'JS.' + name name = 'JS.' + name
} }
f.write(name) f.write(name)
f.mark_import_as_used(name)
if i != node.concrete_types.len - 1 { if i != node.concrete_types.len - 1 {
f.write(', ') f.write(', ')
} }

View File

@ -1,12 +1,16 @@
import math.complex { Complex } import math.complex { Complex }
import gg { MouseButton } import gg { MouseButton }
import time { Duration } import time { Duration }
import modtest { Test }
fn keep_imported_enum_map_key() { fn keep_imported_enum_map_key() {
bm := map[MouseButton]string{} bm := map[MouseButton]string{}
} }
fn generic<T>() {}
fn main() { fn main() {
_ := Duration(10) // keep cast type _ := Duration(10) // keep cast type
assert *(&f64(&byte(&num) + __offsetof(Complex, re))) == 1.0 assert *(&f64(&byte(&num) + __offsetof(Complex, re))) == 1.0
generic<Test>()
} }