mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
compiler: check if-expressions returning only one type
This commit is contained in:
parent
818bea34a4
commit
726fcb5eec
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user