syntax: fix OR if_false_var_ctx passing.
[nit.git] / src / syntax / typing.nit
index e7aa1a5..421b433 100644 (file)
@@ -477,9 +477,19 @@ redef class AWhileExpr
                v.base_variable_ctx = v.variable_ctx
                v.variable_ctx = v.variable_ctx.sub(self)
 
-               super
-
+               # Process condition
+               v.visit(n_expr)
                v.check_conform_expr(n_expr, v.type_bool)
+
+               # Prepare inside context (assert cond)
+               v.use_if_true_variable_ctx(n_expr)
+
+               # Process inside
+               if n_block != null then
+                       v.variable_ctx = v.variable_ctx.sub(n_block)
+                       v.visit(n_block)
+               end
+
                v.variable_ctx = old_var_ctx
                v.base_variable_ctx = old_base_var_ctx
                v.escapable_ctx.pop
@@ -577,8 +587,8 @@ redef class AVarAssignExpr
                var btype = v.base_variable_ctx.stype(variable)
                if not v.check_conform_expr(n_value, btype) then return
 
-               # Bypasse cast if then current type does not match
-               if not n_value.stype < t then v.variable_ctx.stype(variable) = btype
+               # Always cast
+               v.variable_ctx.stype(variable) = n_value.stype
 
                _is_typed = true
        end
@@ -624,8 +634,8 @@ redef class AVarReassignExpr
                var btype = v.base_variable_ctx.stype(variable)
                if not v.check_conform(n_value, t2, btype) then return
 
-               # Bypasse cast if then current type does not match
-               if not t2 < t then v.variable_ctx.stype(variable) = btype
+               # Always cast
+               v.variable_ctx.stype(variable) = t2
 
                _is_typed = true
        end
@@ -686,7 +696,7 @@ redef class ABoolExpr
 end
 
 redef class AOrExpr
-       redef meth after_typing(v)
+       redef meth accept_typing(v)
        do
                var old_var_ctx = v.variable_ctx