From 0a81074b1ebd8f88772fa4c81464453b383a8235 Mon Sep 17 00:00:00 2001 From: yuyi Date: Sun, 29 May 2022 01:47:29 +0800 Subject: [PATCH] ast: fix call_expr.str() with propagate_option or propagate_result (#14550) --- vlib/v/ast/str.v | 8 +++++++- vlib/v/checker/tests/fn_call_arg_mismatch_err_c.out | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/vlib/v/ast/str.v b/vlib/v/ast/str.v index 9ef7494d07..baae9e6382 100644 --- a/vlib/v/ast/str.v +++ b/vlib/v/ast/str.v @@ -303,7 +303,13 @@ pub fn (x Expr) str() string { } CallExpr { 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 { return '${x.left.str()}.${x.name}($sargs)$propagate_suffix' } diff --git a/vlib/v/checker/tests/fn_call_arg_mismatch_err_c.out b/vlib/v/checker/tests/fn_call_arg_mismatch_err_c.out index b89d84279c..58cff628b8 100644 --- a/vlib/v/checker/tests/fn_call_arg_mismatch_err_c.out +++ b/vlib/v/checker/tests/fn_call_arg_mismatch_err_c.out @@ -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) 12 | } else { 13 | println(os.ls(os.chdir(files)?)?)