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

vfmt: keep selective imported names used for generic calls

This commit is contained in:
Delyan Angelov 2022-05-19 12:48:37 +03:00
parent 15c62bc8e8
commit 634e8c3624
No known key found for this signature in database
GPG Key ID: 66886C0F12D595ED
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>()
} }