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
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 2 deletions

View File

@ -35,7 +35,6 @@ const (
'vlib/v/tests/interop_test.v', /* bad comment formatting */
'vlib/v/tests/string_interpolation_test.v' /* TODO byteptr: &byte.str() behaves differently than byteptr.str() */,
'vlib/v/gen/js/tests/js.v', /* local `hello` fn, gets replaced with module `hello` aliased as `hl` */
'vlib/v/tests/map_enum_keys_test.v' /* temporary here, till PR#10235 is merged */,
'examples/c_interop_wkhtmltopdf.v' /* &charptr --> &&char */,
]
vfmt_verify_list = [

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