handle bad value in `if x := opt() {`

pull/3009/head
Alexander Medvednikov 2019-12-07 23:05:54 +03:00
parent 49f960aea5
commit b79588dc69
1 changed files with 3 additions and 0 deletions

View File

@ -235,6 +235,9 @@ fn (p mut Parser) if_statement(is_expr bool, elif_depth int) string {
p.check(.decl_assign)
p.is_var_decl = true
option_type, expr := p.tmp_expr()// := p.bool_expression()
if !option_type.starts_with('Option_') {
p.error('`if x := opt() {` syntax requires a function that returns an optional value')
}
p.is_var_decl = false
typ := option_type[7..]
// Option_User tmp = get_user(1);