From 50fb5de92609180c8a8a66260127100cdedd0a48 Mon Sep 17 00:00:00 2001 From: yuyi Date: Sun, 25 Sep 2022 16:21:14 +0800 Subject: [PATCH] checker: fix dumping match expr (#15869) --- vlib/v/checker/checker.v | 1 + vlib/v/tests/inout/dump_match_expr.out | 1 + vlib/v/tests/inout/dump_match_expr.vv | 8 ++++++++ 3 files changed, 10 insertions(+) create mode 100644 vlib/v/tests/inout/dump_match_expr.out create mode 100644 vlib/v/tests/inout/dump_match_expr.vv diff --git a/vlib/v/checker/checker.v b/vlib/v/checker/checker.v index 2eb3d85fe0..36cdf0f89c 100644 --- a/vlib/v/checker/checker.v +++ b/vlib/v/checker/checker.v @@ -2179,6 +2179,7 @@ pub fn (mut c Checker) expr(node_ ast.Expr) ast.Type { return c.concat_expr(mut node) } ast.DumpExpr { + c.expected_type = ast.string_type node.expr_type = c.expr(node.expr) c.check_expr_opt_call(node.expr, node.expr_type) etidx := node.expr_type.idx() diff --git a/vlib/v/tests/inout/dump_match_expr.out b/vlib/v/tests/inout/dump_match_expr.out new file mode 100644 index 0000000000..61d6143983 --- /dev/null +++ b/vlib/v/tests/inout/dump_match_expr.out @@ -0,0 +1 @@ +[vlib/v/tests/inout/dump_match_expr.vv:3] ast.MatchExpr: 1 diff --git a/vlib/v/tests/inout/dump_match_expr.vv b/vlib/v/tests/inout/dump_match_expr.vv new file mode 100644 index 0000000000..359200ef8a --- /dev/null +++ b/vlib/v/tests/inout/dump_match_expr.vv @@ -0,0 +1,8 @@ +fn main() { + i := 1 + dump(match i { + 0 { '0' } + 1 { '1' } + else { '2' } + }) +}