syntax: do not nest variable context in ABlockExpr
[nit.git] / src / syntax / typing.nit
index 980eba8..adc5736 100644 (file)
@@ -380,9 +380,6 @@ end
 redef class ABlockExpr
        redef fun accept_typing(v)
        do
-               var old_var_ctx = v.variable_ctx
-               v.variable_ctx = v.variable_ctx.sub(self)
-
                for e in n_expr do
                        if not v.variable_ctx.unreash then
                                v.enter_visit(e)
@@ -392,7 +389,6 @@ redef class ABlockExpr
                        end
                end
 
-               v.variable_ctx = old_var_ctx.merge_reash(self, v.variable_ctx, v.variable_ctx, v.base_variable_ctx)
                _is_typed = true
        end
 end
@@ -480,6 +476,7 @@ redef class ADoExpr
                v.escapable_ctx.push(escapable, n_label)
                var old_var_ctx = v.variable_ctx
 
+               v.variable_ctx = old_var_ctx.sub(self)
                super
 
                # Add the end of the block as an exit context
@@ -1269,8 +1266,13 @@ redef class AAbsSendExpr
        private fun get_property(v: TypingVisitor, type_recv: MMType, is_implicit_self: Bool, name: Symbol): nullable MMMethod
        do
                if type_recv isa MMTypeNone then
-                       v.error(self, "Error: Method '{name}' call on 'null'.")
-                       return null
+                       if name == (once "==".to_symbol) or name == (once "!=".to_symbol) then
+                               # Special case on != and == that are allowed for 'null'
+                               type_recv = v.type_object.as_nullable
+                       else
+                               v.error(self, "Error: Method '{name}' call on 'null'.")
+                               return null
+                       end
                end
                var lc = type_recv.local_class
                var prop: nullable MMMethod = null