Skip to content

Commit 7fcd40b

Browse files
authored
Merge pull request #442 from boriel/feature/refactorize_function_never_called_warning
Refactorice Func is never called
2 parents 1ad7650 + e2521f9 commit 7fcd40b

2 files changed

Lines changed: 9 additions & 4 deletions

File tree

src/api/errmsg.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -171,6 +171,11 @@ def warning_fastcall_with_N_parameters(lineno: int, kind: str, id_: str, num_par
171171
"""
172172
warning(lineno, f"{kind} '{id_}' declared as FASTCALL with {num_params} parameters")
173173

174+
175+
@register_warning('170')
176+
def warning_func_is_never_called(lineno: int, func_name: str, fname: Optional[str] = None):
177+
warning(lineno, f"Function '{func_name}' is never called and has been ignored", fname=fname)
178+
174179
# endregion
175180

176181
# region [Syntax Errors]

src/api/optimize.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313

1414
from src import symbols
1515
from src.ast import NodeVisitor
16-
from src.api.errmsg import warning
16+
from src.api import errmsg
17+
1718
from src.api.constants import TYPE, SCOPE, CLASS
1819
from src.api.debug import __DEBUG__
1920
from src.api.errmsg import warning_not_used
@@ -144,8 +145,7 @@ def visit_CALL(self, node):
144145

145146
def visit_FUNCDECL(self, node):
146147
if self.O_LEVEL > 1 and not node.entry.accessed:
147-
warning(node.entry.lineno, "Function '%s' is never called and has been ignored" % node.entry.name,
148-
fname=node.entry.filename)
148+
errmsg.warning_func_is_never_called(node.entry.lineno, node.entry.name, fname=node.entry.filename)
149149
yield self.NOP
150150
else:
151151
node.children[1] = (yield ToVisit(node.entry))
@@ -174,7 +174,7 @@ def visit_LET(self, node):
174174

175175
def visit_LETSUBSTR(self, node):
176176
if self.O_LEVEL > 1 and not node.children[0].accessed:
177-
warning_not_used(node.children[0].lineno, node.children[0].name)
177+
errmsg.warning_not_used(node.children[0].lineno, node.children[0].name)
178178
yield self.NOP
179179
else:
180180
yield (yield self.generic_visit(node))

0 commit comments

Comments
 (0)