[vala/staging] vala: Rework ReturnStatement.check to handle "current_return_type == null"
- From: Rico Tzschichholz <ricotz src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala/staging] vala: Rework ReturnStatement.check to handle "current_return_type == null"
- Date: Thu, 20 Feb 2020 13:26:58 +0000 (UTC)
commit 0d1b68487cc1707a719903631327e27a1b5d26b4
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 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");
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]