From 726fcb5eec3af6bf359d9055e88ce07c73fb4a2b Mon Sep 17 00:00:00 2001 From: Henrixounez Date: Wed, 4 Sep 2019 20:46:25 +0200 Subject: [PATCH] compiler: check if-expressions returning only one type --- compiler/parser.v | 2 ++ 1 file changed, 2 insertions(+) diff --git a/compiler/parser.v b/compiler/parser.v index d9ceac5a72..abc2b58780 100644 --- a/compiler/parser.v +++ b/compiler/parser.v @@ -3073,9 +3073,11 @@ fn (p mut Parser) if_st(is_expr bool, elif_depth int) string { } p.check(.lcbr) // statements() returns the type of the last statement + first_typ := typ typ = p.statements() p.inside_if_expr = false if is_expr { + p.check_types(first_typ, typ) p.gen(strings.repeat(`)`, elif_depth + 1)) } else_returns := p.returns