syntax: warn on 'while true do' and suggests 'loop'
authorJean Privat <jean@pryen.org>
Fri, 28 Aug 2009 15:40:39 +0000 (11:40 -0400)
committerJean Privat <jean@pryen.org>
Fri, 28 Aug 2009 15:40:39 +0000 (11:40 -0400)
Signed-off-by: Jean Privat <jean@pryen.org>

src/syntax/typing.nit

index 70e7d5d..f9fb4a6 100644 (file)
@@ -540,6 +540,10 @@ redef class AWhileExpr
                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)