v.base_variable_ctx = v.variable_ctx
v.variable_ctx = v.variable_ctx.sub(self)
- var escapable = new EscapableClosure(self, variable.closure, null)
+ var blist: nullable Array[AExpr] = null
+ var t = v.local_property.signature.return_type
+ if t != null then blist = new Array[AExpr]
+ var escapable = new EscapableClosure(self, variable.closure, blist)
_escapable = escapable
v.escapable_ctx.push(escapable, null)
if v.variable_ctx.unreash == false then
if variable.closure.signature.return_type != null then
v.error(self, "Control error: Reached end of block (a 'continue' with a value was expected).")
- else if variable.closure.is_break then
- v.error(self, "Control error: Reached end of break block (an 'abort' was expected).")
+ else if variable.closure.is_break and escapable.break_list != null then
+ v.error(self, "Control error: Reached end of break block (a 'break' with a value was expected).")
end
end
end
+ if blist != null then for x in blist do
+ v.check_conform_expr(x, t)
+ end
old_var_ctx.merge(v.variable_ctx)
v.variable_ctx = old_var_ctx
v.enter_visit(n_expr)
v.check_conform_expr(n_expr, v.type_bool)
+ if n_expr isa ATrueExpr then
+ v.warning(self, "Warning: use 'loop' instead of 'while true do'.")
+ end
+
# Prepare inside context (assert cond)
v.use_if_true_variable_ctx(n_expr)
if v.variable_ctx.unreash == false then
if closure.signature.return_type != null then
v.error(self, "Control error: Reached end of block (a 'continue' with a value was expected).")
- else if closure.is_break then
- v.error(self, "Control error: Reached end of break block (a 'break' was expected).")
+ else if closure.is_break and esc.break_list != null then
+ v.error(self, "Control error: Reached end of break block (a 'break' with a value was expected).")
end
end
v.variable_ctx = old_var_ctx