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

fmt: fix removal of selective imported map key type (#10235)

This commit is contained in:
Lukas Neubert
2021-05-28 21:29:03 +02:00
committed by GitHub
parent 6b683d31ac
commit ddcc22a778
3 changed files with 8 additions and 2 deletions

View File

@@ -2078,7 +2078,9 @@ pub fn (mut f Fmt) lock_expr(node ast.LockExpr) {
pub fn (mut f Fmt) map_init(node ast.MapInit) {
if node.keys.len == 0 {
if node.typ > ast.void_type {
f.mark_types_import_as_used(node.typ)
sym := f.table.get_type_symbol(node.typ)
info := sym.info as ast.Map
f.mark_types_import_as_used(info.key_type)
f.write(f.table.type_to_str_using_aliases(node.typ, f.mod2alias))
} else {
// m = map{}

View File

@@ -1,4 +1,9 @@
import math.complex { Complex }
import gg { MouseButton }
fn keep_imported_enum_map_key() {
bm := map[MouseButton]string{}
}
fn main() {
assert *(&f64(&byte(&num) + __offsetof(Complex, re))) == 1.0