From: Rico Tzschichholz Date: Thu, 20 Feb 2020 13:19:10 +0000 (+0100) Subject: vala: Rework ReturnStatement.check to handle "current_return_type == null" X-Git-Tag: 0.47.92~9 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0d1b68487cc1707a719903631327e27a1b5d26b4;p=thirdparty%2Fvala.git vala: Rework ReturnStatement.check to handle "current_return_type == null" Thanks to Daniel Espinosa Ortiz. --- diff --git a/vala/valareturnstatement.vala b/vala/valareturnstatement.vala index 026dd1f28..07eec37c2 100644 --- a/vala/valareturnstatement.vala +++ b/vala/valareturnstatement.vala @@ -83,16 +83,6 @@ public class Vala.ReturnStatement : CodeNode, Statement { checked = true; - if (return_expression != null) { - return_expression.target_type = context.analyzer.current_return_type.copy (); - } - - if (return_expression != null && !return_expression.check (context)) { - // ignore inner error - error = true; - return false; - } - if (context.analyzer.current_return_type == null) { error = true; Report.error (source_reference, "Return not allowed in this context"); @@ -112,6 +102,14 @@ public class Vala.ReturnStatement : CodeNode, Statement { return false; } + return_expression.target_type = context.analyzer.current_return_type.copy (); + + if (!return_expression.check (context)) { + // ignore inner error + error = true; + return false; + } + if (return_expression.value_type == null) { error = true; Report.error (source_reference, "Invalid expression in return value");