src/serialization: intro a service to detect the `noserialize` annotation
[nit.git] / src / frontend / div_by_zero.nit
index 5833009..1e187e2 100644 (file)
@@ -37,7 +37,8 @@ private class DivByZeroPhase
        redef fun process_nmodule(nmodule)
        do
                # The AST node is not enough, we need also the associated model element
-               var mmodule = nmodule.mmodule.as(not null)
+               var mmodule = nmodule.mmodule
+               if mmodule == null then return
                # For the specific job we have, the simpler it to launch a visitor on
                # all elements of the AST.
                var visitor = new DivByZeroVisitor(toolcontext, mmodule)
@@ -55,12 +56,6 @@ private class DivByZeroVisitor
        # The mmodule is the current module
        var mmodule: MModule
 
-       init(toolcontext: ToolContext, mmodule: MModule)
-       do
-               self.toolcontext = toolcontext
-               self.mmodule = mmodule
-       end
-
        redef fun visit(node)
        do
                # Recursively visit all sub-nodes
@@ -85,6 +80,6 @@ private class DivByZeroVisitor
                if not op1.mtype.is_subtype(mmodule, null, int_type) then return
 
                # Error detected
-               toolcontext.error(node.location, "Error: Definitely division by zero")
+               toolcontext.warning(node.location, "div-by-zero", "Warning: division by zero.")
        end
 end