[vala/0.46] vala: Add local-variables to current scope regardless its error state
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/0.46] vala: Add local-variables to current scope regardless its error state
- Date: Thu, 5 Mar 2020 18:46:50 +0000 (UTC)
commit e852ed76e3efb9276f43c425e79873f49fd6a2b7
Author: Rico Tzschichholz <ricotz ubuntu com>
Date: Sat Feb 22 16:00:22 2020 +0100
vala: Add local-variables to current scope regardless its error state
This avoids subsequent errors which are not useful to report when the user
actually defined it.
vala/valalocalvariable.vala | 17 +++++++++--------
vala/valamemberaccess.vala | 4 ++++
2 files changed, 13 insertions(+), 8 deletions(-)
---
diff --git a/vala/valalocalvariable.vala b/vala/valalocalvariable.vala
index aa4bb3a91..3f7685ccc 100644
--- a/vala/valalocalvariable.vala
+++ b/vala/valalocalvariable.vala
@@ -96,11 +96,8 @@ public class Vala.LocalVariable : Variable {
if (variable_type is VoidType) {
error = true;
Report.error (source_reference, "'void' not supported as variable type");
- return false;
- }
- if (!variable_type.check (context)) {
+ } else if (!variable_type.check (context)) {
error = true;
- return false;
}
}
@@ -108,7 +105,7 @@ public class Vala.LocalVariable : Variable {
bool is_initializer_list = false;
int initializer_size = -1;
- if (initializer != null) {
+ if (initializer != null && !error) {
initializer.target_type = variable_type;
if (initializer is InitializerList) {
@@ -118,10 +115,16 @@ public class Vala.LocalVariable : Variable {
if (!initializer.check (context)) {
error = true;
- return false;
}
}
+ // local variables are defined even on errors
+ context.analyzer.current_symbol.scope.add (name, this);
+
+ if (error) {
+ return false;
+ }
+
if (variable_type == null) {
/* var type */
@@ -220,8 +223,6 @@ public class Vala.LocalVariable : Variable {
}
}
- context.analyzer.current_symbol.scope.add (name, this);
-
// current_symbol is a Method if this is the `result'
// variable used for postconditions
var block = context.analyzer.current_symbol as Block;
diff --git a/vala/valamemberaccess.vala b/vala/valamemberaccess.vala
index ec3f74183..7022c31fb 100644
--- a/vala/valamemberaccess.vala
+++ b/vala/valamemberaccess.vala
@@ -485,6 +485,10 @@ public class Vala.MemberAccess : Expression {
Report.error (source_reference, "The name `%s' does not exist in the context of
`%s'".printf (member_name, base_type_name));
return false;
+ } else if (symbol_reference.error) {
+ //ignore previous error
+ error = true;
+ return false;
}
var member = symbol_reference;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]