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

ast: fix dumping sumtype of fntype (#15734)

This commit is contained in:
yuyi 2022-09-12 18:45:29 +08:00 committed by GitHub
parent 550b27b014
commit b4494f921a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 15 additions and 5 deletions

View File

@ -230,11 +230,9 @@ pub fn (t &Table) fn_type_signature(f &Fn) string {
if f.return_type != 0 && f.return_type != void_type { if f.return_type != 0 && f.return_type != void_type {
sym := t.sym(f.return_type) sym := t.sym(f.return_type)
opt := if f.return_type.has_flag(.optional) { 'option_' } else { '' } opt := if f.return_type.has_flag(.optional) { 'option_' } else { '' }
if sym.kind == .alias { res := if f.return_type.has_flag(.result) { 'result_' } else { '' }
sig += '__$opt$sym.cname'
} else { sig += '__$opt$res$sym.cname'
sig += '__$opt$sym.kind'
}
} }
return sig return sig
} }

View File

@ -0,0 +1 @@
[vlib/v/tests/inout/dump_sumtype_of_fntype.vv:10] main.MyFnSumtype(main.f): MyFnSumtype(fn (int) v.ast.Expr)

View File

@ -0,0 +1,11 @@
import v.ast
type MyFnSumtype = fn () | fn (int) ast.Expr
fn f(z int) ast.Expr {
return ast.empty_expr
}
fn main() {
dump(MyFnSumtype(f))
}