diff --git a/src/semantize/flow.nit b/src/semantize/flow.nit index 3d27623995..cedbfa72b5 100644 --- a/src/semantize/flow.nit +++ b/src/semantize/flow.nit @@ -305,7 +305,7 @@ redef class ABlockExpr v.enter_visit(e) else if not v.current_flow_context.is_already_unreachable then v.current_flow_context.is_already_unreachable = true - v.toolcontext.error(e.hot_location, "Error: unreachable statement.") + v.toolcontext.warning(e.hot_location, "unreachable", "Warning: unreachable statement.") end end end diff --git a/src/semantize/local_var_init.nit b/src/semantize/local_var_init.nit index 27c7ddda9e..613178602c 100644 --- a/src/semantize/local_var_init.nit +++ b/src/semantize/local_var_init.nit @@ -59,8 +59,8 @@ private class LocalVarInitVisitor assert variable != null if not maybe_unset_vars.has(variable) then return - var flow = node.after_flow_context.as(not null) - flow.set_vars.add(variable) + var flow = node.after_flow_context + if flow != null then flow.set_vars.add(variable) end fun check_is_set(node: AExpr, variable: nullable Variable) @@ -68,8 +68,8 @@ private class LocalVarInitVisitor assert variable != null if not maybe_unset_vars.has(variable) then return - var flow = node.after_flow_context.as(not null) - if not flow.is_variable_set(variable) then + var flow = node.after_flow_context + if flow != null and not flow.is_variable_set(variable) then self.toolcontext.error(node.hot_location, "Error: possibly unset variable `{variable}`.") # Remove the variable to avoid repeating errors self.maybe_unset_vars.remove(variable) diff --git a/src/semantize/typing.nit b/src/semantize/typing.nit index 98aba7771c..57424b88b6 100644 --- a/src/semantize/typing.nit +++ b/src/semantize/typing.nit @@ -634,9 +634,7 @@ private class TypeVisitor fun set_variable(node: AExpr, variable: Variable, mtype: nullable MType) do var flow = node.after_flow_context - assert flow != null - - flow.set_var(self, variable, mtype) + if flow != null then flow.set_var(self, variable, mtype) end # Find the exact representable most specific common super-type in `col`.