typing: the static type of a blockexpr is the one of the last expression
authorJean Privat <jean@pryen.org>
Tue, 13 Aug 2013 16:27:04 +0000 (12:27 -0400)
committerJean Privat <jean@pryen.org>
Tue, 13 Aug 2013 18:01:22 +0000 (14:01 -0400)
Signed-off-by: Jean Privat <jean@pryen.org>

src/typing.nit

index 5545008..45866b7 100644 (file)
@@ -559,6 +559,13 @@ redef class ABlockExpr
                for e in self.n_expr do v.visit_stmt(e)
                self.is_typed = true
        end
+
+       # The type of a blockexpr is the one of the last expression (or null if empty)
+       redef fun mtype
+       do
+               if self.n_expr.is_empty then return null
+               return self.n_expr.last.mtype
+       end
 end
 
 redef class AVardeclExpr