fmt: fix removal of selective imported Enum (#10729)

pull/10746/head
zakuro 2021-07-10 17:06:01 +09:00 committed by GitHub
parent a1088275b9
commit cb14e42af8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 0 deletions

View File

@ -1804,6 +1804,7 @@ pub fn (mut f Fmt) dump_expr(node ast.DumpExpr) {
pub fn (mut f Fmt) enum_val(node ast.EnumVal) { pub fn (mut f Fmt) enum_val(node ast.EnumVal) {
name := f.short_module(node.enum_name) name := f.short_module(node.enum_name)
f.write(name + '.' + node.val) f.write(name + '.' + node.val)
f.mark_import_as_used(name)
} }
pub fn (mut f Fmt) ident(node ast.Ident) { pub fn (mut f Fmt) ident(node ast.Ident) {

View File

@ -6,6 +6,7 @@ import os {
user_os, user_os,
} }
import mod { import mod {
Enum,
FnArg, FnArg,
FnRet, FnRet,
InterfaceField, InterfaceField,
@ -40,6 +41,8 @@ fn f(v FnArg) FnRet {
} }
_ = v as RightOfAs _ = v as RightOfAs
println(Enum.val)
return {} return {}
} }

View File

@ -22,6 +22,8 @@ import mod {
RightOfIs, RightOfIs,
RightOfAs, RightOfAs,
Enum
} }
struct Struct { struct Struct {
@ -43,6 +45,8 @@ fn f(v FnArg) FnRet {
if v is RightOfIs {} if v is RightOfIs {}
_ = v as RightOfAs _ = v as RightOfAs
println(Enum.val)
return {} return {}
} }