fmt: fix removal of `Abc` in `import mod { Abc }`, where `Abc` is used in a `x as Abc` expression #10306
parent
672bb6ca7f
commit
4089aa38c5
|
@ -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')
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import v.ast
|
||||
import v.ast { InfixExpr }
|
||||
import v.table
|
||||
|
||||
fn test_as() {
|
||||
|
|
|
@ -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 {}
|
||||
}
|
||||
|
|
|
@ -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 {}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue