mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
fmt: fix removal of Abc
in import mod { Abc }
, where Abc
is used in a x as Abc
expression #10306
This commit is contained in:
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) {
|
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)
|
type_str := f.table.type_to_str_using_aliases(node.typ, f.mod2alias)
|
||||||
f.expr(node.expr)
|
f.expr(node.expr)
|
||||||
f.write(' as $type_str')
|
f.write(' as $type_str')
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
import v.ast
|
import v.ast { InfixExpr }
|
||||||
import v.table
|
import v.table
|
||||||
|
|
||||||
fn test_as() {
|
fn test_as() {
|
||||||
|
@ -11,6 +11,7 @@ import mod {
|
|||||||
InterfaceField,
|
InterfaceField,
|
||||||
InterfaceMethodArg,
|
InterfaceMethodArg,
|
||||||
InterfaceMethodRet,
|
InterfaceMethodRet,
|
||||||
|
RightOfAs,
|
||||||
RightOfIs,
|
RightOfIs,
|
||||||
StructEmbed,
|
StructEmbed,
|
||||||
StructField,
|
StructField,
|
||||||
@ -37,6 +38,7 @@ interface Interface {
|
|||||||
fn f(v FnArg) FnRet {
|
fn f(v FnArg) FnRet {
|
||||||
if v is RightOfIs {
|
if v is RightOfIs {
|
||||||
}
|
}
|
||||||
|
_ = v as RightOfAs
|
||||||
|
|
||||||
return {}
|
return {}
|
||||||
}
|
}
|
||||||
|
@ -21,6 +21,7 @@ import mod {
|
|||||||
FnRet,
|
FnRet,
|
||||||
|
|
||||||
RightOfIs,
|
RightOfIs,
|
||||||
|
RightOfAs,
|
||||||
}
|
}
|
||||||
|
|
||||||
struct Struct {
|
struct Struct {
|
||||||
@ -40,6 +41,7 @@ interface Interface {
|
|||||||
|
|
||||||
fn f(v FnArg) FnRet {
|
fn f(v FnArg) FnRet {
|
||||||
if v is RightOfIs {}
|
if v is RightOfIs {}
|
||||||
|
_ = v as RightOfAs
|
||||||
|
|
||||||
return {}
|
return {}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user