Signed-off-by: Jean Privat <jean@pryen.org>
# Some variables where type-adapted during the visit
var dirty = false
# Some variables where type-adapted during the visit
var dirty = false
+ # Some loops had been visited during the visit
+ var has_loop = false
+
fun set_variable(node: AExpr, variable: Variable, mtype: nullable MType)
do
var flow = node.after_flow_context
fun set_variable(node: AExpr, variable: Variable, mtype: nullable MType)
do
var flow = node.after_flow_context
assert variable != null
variable.declared_type = mtype
end
assert variable != null
variable.declared_type = mtype
end
+
+ loop
+ v.dirty = false
+ v.visit_stmt(nblock)
+ if not v.has_loop or not v.dirty then break
+ end
if not nblock.after_flow_context.is_unreachable and msignature.return_mtype != null then
# We reach the end of the function without having a return, it is bad
if not nblock.after_flow_context.is_unreachable and msignature.return_mtype != null then
# We reach the end of the function without having a return, it is bad
redef class AWhileExpr
redef fun accept_typing(v)
do
redef class AWhileExpr
redef fun accept_typing(v)
do
v.visit_expr_bool(n_expr)
v.visit_expr_bool(n_expr)
v.visit_stmt(n_block)
self.is_typed = true
end
v.visit_stmt(n_block)
self.is_typed = true
end
redef class ALoopExpr
redef fun accept_typing(v)
do
redef class ALoopExpr
redef fun accept_typing(v)
do
v.visit_stmt(n_block)
self.is_typed = true
end
v.visit_stmt(n_block)
self.is_typed = true
end
redef fun accept_typing(v)
do
redef fun accept_typing(v)
do
var mtype = v.visit_expr(n_expr)
if mtype == null then return
self.do_type_iterator(v, mtype)
v.visit_stmt(n_block)
var mtype = v.visit_expr(n_expr)
if mtype == null then return
self.do_type_iterator(v, mtype)
v.visit_stmt(n_block)
self.mtype = n_block.mtype
self.is_typed = true
end
self.mtype = n_block.mtype
self.is_typed = true
end