1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

fmt: don't prepend mod when cast with selective imported types (#9109)

This commit is contained in:
zakuro 2021-03-04 19:33:52 +09:00 committed by GitHub
parent a64d9b3e12
commit 5b041db442
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 17 additions and 6 deletions

View File

@ -1157,13 +1157,13 @@ pub fn (mut f Fmt) fn_decl(node ast.FnDecl) {
}
pub fn (mut f Fmt) as_cast(node ast.AsCast) {
type_str := f.table.type_to_str(node.typ)
type_str := f.table.type_to_str_using_aliases(node.typ, f.mod2alias)
f.expr(node.expr)
f.write(' as $type_str')
}
pub fn (mut f Fmt) cast_expr(node ast.CastExpr) {
f.write(f.table.type_to_str(node.typ) + '(')
f.write(f.table.type_to_str_using_aliases(node.typ, f.mod2alias) + '(')
f.expr(node.expr)
if node.has_arg {
f.write(', ')

View File

@ -1,8 +1,13 @@
import v.ast
import v.table
fn test_as() {
a := sum_expr() as Bar
_ := a
_ := sum_expr() as InfixExpr
_ := sum_expr() as ast.PrefixExpr
}
fn test_cast() {
_ := f32(0)
_ := Type(0)
_ := ast.Expr(sum_expr())
}

View File

@ -1,8 +1,14 @@
import v.ast { InfixExpr }
import v.table { Type }
fn test_as() {
a := sum_expr() as Bar
_ := a
_ := sum_expr() as ast.InfixExpr
_ := sum_expr() as ast.PrefixExpr
}
fn test_cast() {
_ := f32(0)
_ := table.Type(0)
_ := ast.Expr(sum_expr())
}