diff --git a/vlib/v/fmt/fmt.v b/vlib/v/fmt/fmt.v index ebebd5333e..dc1063989e 100644 --- a/vlib/v/fmt/fmt.v +++ b/vlib/v/fmt/fmt.v @@ -1561,6 +1561,7 @@ fn should_decrease_arr_penalty(e ast.Expr) bool { } pub fn (mut f Fmt) as_cast(node ast.AsCast) { + f.mark_types_import_as_used(node.typ) type_str := f.table.type_to_str_using_aliases(node.typ, f.mod2alias) f.expr(node.expr) f.write(' as $type_str') diff --git a/vlib/v/fmt/tests/cast_expected.vv b/vlib/v/fmt/tests/cast_expected.vv index 7f6a15ecdf..e6768dc00e 100644 --- a/vlib/v/fmt/tests/cast_expected.vv +++ b/vlib/v/fmt/tests/cast_expected.vv @@ -1,4 +1,4 @@ -import v.ast +import v.ast { InfixExpr } import v.table fn test_as() { diff --git a/vlib/v/fmt/tests/import_selective_expected.vv b/vlib/v/fmt/tests/import_selective_expected.vv index 5854ab504e..a4bb43f935 100644 --- a/vlib/v/fmt/tests/import_selective_expected.vv +++ b/vlib/v/fmt/tests/import_selective_expected.vv @@ -11,6 +11,7 @@ import mod { InterfaceField, InterfaceMethodArg, InterfaceMethodRet, + RightOfAs, RightOfIs, StructEmbed, StructField, @@ -37,6 +38,7 @@ interface Interface { fn f(v FnArg) FnRet { if v is RightOfIs { } + _ = v as RightOfAs return {} } diff --git a/vlib/v/fmt/tests/import_selective_input.vv b/vlib/v/fmt/tests/import_selective_input.vv index 3ddb69b661..8a542fe0ea 100644 --- a/vlib/v/fmt/tests/import_selective_input.vv +++ b/vlib/v/fmt/tests/import_selective_input.vv @@ -21,6 +21,7 @@ import mod { FnRet, RightOfIs, + RightOfAs, } struct Struct { @@ -40,6 +41,7 @@ interface Interface { fn f(v FnArg) FnRet { if v is RightOfIs {} + _ = v as RightOfAs return {} }