[vala/0.46] vala: Rework ReturnStatement.check to handle "current_return_type == null"



commit f5d23079e864e0715c67c37b226fc83712d34c6f
Author: Rico Tzschichholz <ricotz ubuntu com>
Date:   Thu Feb 20 14:19:10 2020 +0100

    vala: Rework ReturnStatement.check to handle "current_return_type == null"
    
    Thanks to Daniel Espinosa Ortiz.

 vala/valareturnstatement.vala | 18 ++++++++----------
 1 file changed, 8 insertions(+), 10 deletions(-)
---
diff --git a/vala/valareturnstatement.vala b/vala/valareturnstatement.vala
index f51164968..c6254849b 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");


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]