X-Git-Url: http://nitlanguage.org diff --git a/src/frontend/div_by_zero.nit b/src/frontend/div_by_zero.nit index 4a8cfb4..16802c0 100644 --- a/src/frontend/div_by_zero.nit +++ b/src/frontend/div_by_zero.nit @@ -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) @@ -65,9 +66,9 @@ private class DivByZeroVisitor # 1. We need a `/` operation if not node isa ASlashExpr then return - # 2. The second operand must be a integer literal + # 2. The second operand must be an integer literal var op2 = node.n_expr2 - if not op2 isa AIntExpr then return + if not op2 isa AIntegerExpr then return # 3. Its value must be 0 # Note: because of `literal_phase` the `value` method exists @@ -79,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