[vala/wip/issue/911] 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/wip/issue/911] vala: Rework ReturnStatement.check to handle "current_return_type == null"
- Date: Thu, 20 Feb 2020 10:47:13 +0000 (UTC)
commit da1d03003c6b574497b820e35b5925ac5821a210
Author: Rico Tzschichholz <ricotz ubuntu com>
Date: Thu Feb 20 11:37:15 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 2e30bf39f..3c069f4d5 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");
@@ -113,6 +103,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]