Skip to content

Commit

Permalink
Avoid dereferencing a disengaged optional (#865)
Browse files Browse the repository at this point in the history
  • Loading branch information
geoffromer authored Oct 2, 2021
1 parent ef21d05 commit 371c307
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion executable_semantics/interpreter/type_checker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -992,7 +992,9 @@ auto TypeChecker::TypeCheckFunDef(FunctionDefinition* f, TypeEnv types,
&return_type_context);
body_stmt = res.stmt;
// Save the return type in case it changed.
return_type = *return_type_context.deduced_return_type();
if (return_type_context.deduced_return_type().has_value()) {
return_type = *return_type_context.deduced_return_type();
}
}
auto body = CheckOrEnsureReturn(body_stmt, f->is_omitted_return_type(),
f->source_loc());
Expand Down

0 comments on commit 371c307

Please sign in to comment.