Thanks to Daniel Espinosa Ortiz.
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");
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");