Skip to content

Commit

Permalink
fmt: fix removal of Abc in import mod { Abc }, where Abc is used …
Browse files Browse the repository at this point in the history
…in a `x is Abc` expression (#10286)
  • Loading branch information
zakuro9715 authored May 31, 2021
1 parent cb19079 commit 90292ce
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions vlib/v/fmt/fmt.v
Original file line number Diff line number Diff line change
Expand Up @@ -2429,6 +2429,7 @@ pub fn (mut f Fmt) string_inter_literal(node ast.StringInterLiteral) {
}

pub fn (mut f Fmt) type_expr(node ast.TypeNode) {
f.mark_types_import_as_used(node.typ)
f.write(f.table.type_to_str_using_aliases(node.typ, f.mod2alias))
}

Expand Down
4 changes: 4 additions & 0 deletions vlib/v/fmt/tests/import_selective_expected.vv
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import mod {
InterfaceField,
InterfaceMethodArg,
InterfaceMethodRet,
RightOfIs,
StructEmbed,
StructField,
StructMethodArg,
Expand All @@ -34,6 +35,9 @@ interface Interface {
}

fn f(v FnArg) FnRet {
if v is RightOfIs {
}

return {}
}

Expand Down
4 changes: 4 additions & 0 deletions vlib/v/fmt/tests/import_selective_input.vv
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ import mod {

FnArg,
FnRet,

RightOfIs,
}

struct Struct {
Expand All @@ -37,6 +39,8 @@ interface Interface {
}

fn f(v FnArg) FnRet {
if v is RightOfIs {}

return {}
}

Expand Down

0 comments on commit 90292ce

Please sign in to comment.