ast: fix call_expr.str() with propagate_option or propagate_result (#14550)

yuyi 2022-05-29 01:47:29 +08:00 committed by Chewing_Bever
parent f02f2e4708
commit 0a81074b1e
Signed by: Jef Roosens
GPG Key ID: B75D4F293C7052DB
2 changed files with 8 additions and 2 deletions

View File

@ -303,7 +303,13 @@ pub fn (x Expr) str() string {
} }
CallExpr { CallExpr {
sargs := args2str(x.args) sargs := args2str(x.args)
propagate_suffix := if x.or_block.kind == .propagate_option { ' ?' } else { '' } propagate_suffix := if x.or_block.kind == .propagate_option {
'?'
} else if x.or_block.kind == .propagate_result {
'!'
} else {
''
}
if x.is_method { if x.is_method {
return '${x.left.str()}.${x.name}($sargs)$propagate_suffix' return '${x.left.str()}.${x.name}($sargs)$propagate_suffix'
} }

View File

@ -1,4 +1,4 @@
vlib/v/checker/tests/fn_call_arg_mismatch_err_c.vv:13:18: error: `os.chdir(files) ?` (no value) used as value in argument 1 to `os.ls` vlib/v/checker/tests/fn_call_arg_mismatch_err_c.vv:13:18: error: `os.chdir(files)?` (no value) used as value in argument 1 to `os.ls`
11 | println(files) 11 | println(files)
12 | } else { 12 | } else {
13 | println(os.ls(os.chdir(files)?)?) 13 | println(os.ls(os.chdir(files)?)?)