[vala/staging] vala: Properly set CodeNode.error when reporting an error (2)



commit 1f51967fa5290bce6cd05ae0306bb98c46b59543
Author: Rico Tzschichholz <ricotz ubuntu com>
Date:   Thu Feb 20 15:24:36 2020 +0100

    vala: Properly set CodeNode.error when reporting an error (2)

 vala/valalocalvariable.vala   | 5 ++++-
 vala/valamemberaccess.vala    | 1 +
 vala/valamethodcall.vala      | 2 ++
 vala/valareturnstatement.vala | 1 +
 4 files changed, 8 insertions(+), 1 deletion(-)
---
diff --git a/vala/valalocalvariable.vala b/vala/valalocalvariable.vala
index a6a1a8842..ec7b0da87 100644
--- a/vala/valalocalvariable.vala
+++ b/vala/valalocalvariable.vala
@@ -102,7 +102,10 @@ public class Vala.LocalVariable : Variable {
                                Report.error (source_reference, "'void' not supported as variable type");
                                return false;
                        }
-                       variable_type.check (context);
+                       if (!variable_type.check (context)) {
+                               error = true;
+                               return false;
+                       }
                        if (!external_package) {
                                context.analyzer.check_type (variable_type);
                        }
diff --git a/vala/valamemberaccess.vala b/vala/valamemberaccess.vala
index 946bd2b0a..8b199b930 100644
--- a/vala/valamemberaccess.vala
+++ b/vala/valamemberaccess.vala
@@ -825,6 +825,7 @@ public class Vala.MemberAccess : Expression {
                        } else if (symbol_reference is Property) {
                                value_type = new PropertyPrototype ((Property) symbol_reference);
                        } else {
+                               error = true;
                                value_type = new InvalidType ();
                        }
 
diff --git a/vala/valamethodcall.vala b/vala/valamethodcall.vala
index 4a15a6cb4..98a7a878e 100644
--- a/vala/valamethodcall.vala
+++ b/vala/valamethodcall.vala
@@ -466,6 +466,7 @@ public class Vala.MethodCall : Expression {
                        if (format_literal != null) {
                                string format = format_literal.eval ();
                                if (!context.analyzer.check_print_format (format, arg_it, source_reference)) {
+                                       error = true;
                                        return false;
                                }
                        }
@@ -655,6 +656,7 @@ public class Vala.MethodCall : Expression {
                                // simple statements, no side effects after method call
                        } else if (!(context.analyzer.current_symbol is Block)) {
                                // can't handle errors in field initializers
+                               error = true;
                                Report.error (source_reference, "Field initializers must not throw errors");
                        } else {
                                // store parent_node as we need to replace the expression in the old parent 
node later on
diff --git a/vala/valareturnstatement.vala b/vala/valareturnstatement.vala
index 07eec37c2..3c069f4d5 100644
--- a/vala/valareturnstatement.vala
+++ b/vala/valareturnstatement.vala
@@ -98,6 +98,7 @@ public class Vala.ReturnStatement : CodeNode, Statement {
                }
 
                if (context.analyzer.current_return_type is VoidType) {
+                       error = true;
                        Report.error (source_reference, "Return with value in void function");
                        return false;
                }


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