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 Enum (#10729)

This commit is contained in:
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) {
name := f.short_module(node.enum_name)
f.write(name + '.' + node.val)
f.mark_import_as_used(name)
}
pub fn (mut f Fmt) ident(node ast.Ident) {

View File

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

View File

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