[vala/wip/issue/911] WIP vala: Improve dealing with errornous nodes
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/wip/issue/911] WIP vala: Improve dealing with errornous nodes
- Date: Wed, 19 Feb 2020 22:02:30 +0000 (UTC)
commit 9faf0e195d3c52dedf74e3014d569b2d99e0413f
Author: Rico Tzschichholz <ricotz ubuntu com>
Date: Wed Feb 19 22:27:22 2020 +0100
WIP vala: Improve dealing with errornous nodes
See https://gitlab.gnome.org/GNOME/vala/issues/911
vala/valaconstant.vala | 4 ++--
vala/valaflowanalyzer.vala | 4 +++-
vala/valalocalvariable.vala | 5 ++++-
vala/valamemberaccess.vala | 8 +++++++-
vala/valamethodcall.vala | 10 ++++++++--
vala/valathrowstatement.vala | 3 +++
6 files changed, 27 insertions(+), 7 deletions(-)
---
diff --git a/vala/valaconstant.vala b/vala/valaconstant.vala
index 809cb883d..b0beddc2b 100644
--- a/vala/valaconstant.vala
+++ b/vala/valaconstant.vala
@@ -190,8 +190,8 @@ public class Vala.Constant : Symbol {
} else if (type is ArrayType) {
unowned ArrayType array_type = (ArrayType) type;
return check_const_type (array_type.element_type, context);
- } else if (type.type_symbol.is_subtype_of (context.analyzer.string_type.type_symbol)) {
- return true;
+ } else if (type.type_symbol != null) {
+ return type.type_symbol.is_subtype_of (context.analyzer.string_type.type_symbol);
} else {
return false;
}
diff --git a/vala/valaflowanalyzer.vala b/vala/valaflowanalyzer.vala
index 978ab94f8..f3f8edf30 100644
--- a/vala/valaflowanalyzer.vala
+++ b/vala/valaflowanalyzer.vala
@@ -987,7 +987,9 @@ public class Vala.FlowAnalyzer : CodeVisitor {
var error_block = new BasicBlock ();
all_basic_blocks.add (error_block);
- if (catch_clause.error_type != null) {
+ if (catch_clause.error) {
+ // skip on previous error
+ } else if (catch_clause.error_type != null) {
if (context.profile == Profile.GOBJECT) {
unowned ErrorType error_type = (ErrorType) catch_clause.error_type;
jump_stack.add (new JumpTarget.error_target (error_block,
catch_clause, catch_clause.error_type.type_symbol as ErrorDomain, error_type.error_code, null));
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..6a0ccb6ff 100644
--- a/vala/valamemberaccess.vala
+++ b/vala/valamemberaccess.vala
@@ -307,7 +307,12 @@ public class Vala.MemberAccess : Expression {
if (symbol_reference == null && source_reference != null) {
foreach (UsingDirective ns in source_reference.using_directives) {
- var local_sym = ns.namespace_symbol.scope.lookup (member_name);
+ unowned Namespace? ns_symbol = ns.namespace_symbol as Namespace;
+ if (ns_symbol == null) {
+ // unresolved
+ continue;
+ }
+ var local_sym = ns_symbol.scope.lookup (member_name);
if (local_sym != null) {
if (symbol_reference != null && symbol_reference !=
local_sym) {
error = true;
@@ -825,6 +830,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..c79334763 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
@@ -670,7 +672,9 @@ public class Vala.MethodCall : Expression {
// don't set initializer earlier as this changes parent_node and
parent_statement
local.initializer = this;
- decl.check (context);
+ if (!decl.check (context)) {
+ error = true;
+ }
// move temp variable to insert block to ensure the
// variable is in the same block as the declaration
@@ -680,7 +684,9 @@ public class Vala.MethodCall : Expression {
context.analyzer.insert_block.add_local_variable (local);
old_parent_node.replace_expression (this, temp_access);
- temp_access.check (context);
+ if (!temp_access.check (context)) {
+ error = true;
+ }
}
}
diff --git a/vala/valathrowstatement.vala b/vala/valathrowstatement.vala
index 9349b1818..4ba347a9b 100644
--- a/vala/valathrowstatement.vala
+++ b/vala/valathrowstatement.vala
@@ -73,6 +73,9 @@ public class Vala.ThrowStatement : CodeNode, Statement {
}
public override void get_error_types (Collection<DataType> collection, SourceReference?
source_reference = null) {
+ if (error) {
+ return;
+ }
if (source_reference == null) {
source_reference = this.source_reference;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]