checker: minor cleanup: clear_flag(.optional) in check_expr_opt_call (#9139)

pull/9168/head
zakuro 2021-03-07 03:42:34 +09:00 committed by GitHub
parent b83530e0ed
commit 7333b1706c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 1 additions and 8 deletions

View File

@ -2082,10 +2082,7 @@ pub fn (mut c Checker) check_expr_opt_call(expr ast.Expr, ret_type table.Type) t
} else {
c.check_or_expr(expr.or_block, ret_type, expr.return_type.clear_flag(.optional))
}
// remove optional flag
// return ret_type.clear_flag(.optional)
// TODO: currently unwrapped in assign, would need to refactor assign to unwrap here
return ret_type
return ret_type.clear_flag(.optional)
} else if expr.or_block.kind == .block {
c.error('unexpected `or` block, the function `$expr.name` does not return an optional',
expr.or_block.pos)
@ -2630,10 +2627,6 @@ pub fn (mut c Checker) assign_stmt(mut assign_stmt ast.AssignStmt) {
}
}
}
// we are unwrapping here instead if check_expr_opt_call currently
if left_type.has_flag(.optional) {
left_type = left_type.clear_flag(.optional)
}
} else {
// Make sure the variable is mutable
c.fail_if_immutable(left)