end
end
+redef class AClosureDecl
+ redef meth accept_control_flow(v)
+ do
+ if n_expr != null then
+ var old_control_flow_ctx = v.control_flow_ctx
+ v.control_flow_ctx = v.control_flow_ctx.sub
+ # Register the block
+ v.control_flow_ctx.base_block = n_expr
+
+ super
+
+ if v.control_flow_ctx.unreash == false then
+ if variable.closure.signature.return_type != null then
+ v.error(self, "Control error: Reached end of bloc (a 'continue' with a value was expected).")
+ else if variable.closure.is_break then
+ v.error(self, "Control error: Reached end of break bloc (an 'abort' was expected).")
+ end
+ end
+
+ v.control_flow_ctx = old_control_flow_ctx
+ end
+ end
+end
+
redef class AClosureDef
special AControlableBlock
redef meth accept_control_flow(v)
end
redef class AClosureDecl
- redef meth after_typing(v)
+ redef meth accept_typing(v)
do
+ # Register the closure for ClosureCallExpr
v.variable_ctx.add(variable)
+
+ var old_var_ctx = v.variable_ctx
+ v.variable_ctx = v.variable_ctx.sub
+ v.closure = variable.closure
+
+ super
+
+ v.variable_ctx = old_var_ctx
+ v.closure = null
end
end