parser: add error when trying to assign from a function that does not return a value

This commit is contained in:
joe-conigliaro 2019-11-04 22:35:10 +11:00 committed by Alexander Medvednikov
parent b4e8989bd1
commit 5d16f30a3d
4 changed files with 24 additions and 12 deletions

View file

@ -39,7 +39,7 @@ fn (p mut Parser) gen_blank_identifier_assign() {
p.check_name()
p.check_space(.assign)
is_indexer := p.peek() == .lsbr
is_fn_call, next_expr := p.is_next_expr_fn_call()
is_fn_call, next_expr := p.is_expr_fn_call(p.token_idx)
p.bool_expression()
if !is_indexer && !is_fn_call {
p.error_with_token_index('assigning `$next_expr` to `_` is redundant', assign_error_tok_idx)