nodes: make some obvious dead-code raise a log message (Info)

This commit is contained in:
Antoine Viallon 2024-01-11 00:06:06 +01:00
parent 7106e400aa
commit 46c7907165
Signed by: aviallon
GPG key ID: 186FC35EDEB25716

View file

@ -5,7 +5,7 @@ from abc import abstractmethod, ABC
from typing import Any, Iterable
from . import ir, semantic, lexer
from .errors import SemanticAnalysisError, OverrideMandatoryError
from .errors import SemanticAnalysisError, OverrideMandatoryError, CompilationWarning, Levels
from .logger import Logger
from .source import SourceLocation
from .typechecking import typecheck
@ -291,7 +291,12 @@ class Block(Statement):
def intermediate_representation(self) -> list[ir.IRItem]:
result: list[ir.IRItem] = []
for node in self.nodes:
if not node.pure:
if node.pure:
CompilationWarning(node.location(),
f"{node.__class__.__name__} ignored as it doesn't have any "
f"visible side effect.",
level=Levels.Info).raise_warning()
continue
result += node.intermediate_representation()
return result