From 650daa0eb058cac439b34072ad44ec8645489743 Mon Sep 17 00:00:00 2001 From: pali <6pali6@gmail.com> Date: Tue, 24 Nov 2020 16:08:38 +0100 Subject: [PATCH] added warning for `return x` in spawn context (#228) --- src/dreamchecker/lib.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/dreamchecker/lib.rs b/src/dreamchecker/lib.rs index e3477c66..49cc3ae1 100644 --- a/src/dreamchecker/lib.rs +++ b/src/dreamchecker/lib.rs @@ -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 }