added warning for return x in spawn context (#228)

This commit is contained in:
pali 2020-11-24 16:08:38 +01:00 committed by GitHub
parent 13fd304f04
commit 650daa0eb0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1281,6 +1281,11 @@ impl<'o, 's> AnalyzeProc<'o, 's> {
},
Statement::Return(Some(expr)) => {
// TODO: factor in the previous return type if there was one
if self.inside_newcontext > 0 {
error(location, "returning a value in a spawn has no effect")
.set_severity(Severity::Warning)
.register(self.context);
}
let return_type = self.visit_expression(location, expr, None, local_vars);
local_vars.get_mut(".").unwrap().analysis = return_type;
return ControlFlow { returns: true, continues: false, breaks: false, fuzzy: false }