Skip to content

Commit 8c9b7c7

Browse files
committed
feat: make while condition warning muteable
1 parent 00f593b commit 8c9b7c7

1 file changed

Lines changed: 3 additions & 6 deletions

File tree

src/zxbc/zxbparser.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
import src.api.symboltable.symboltable
2929
from src.api.debug import __DEBUG__ # analysis:ignore
3030
from src.api.opcodestemps import OpcodesTemps
31-
from src.api.errmsg import error
31+
from src.api.errmsg import error, warning_condition_is_always
3232
from src.api.errmsg import warning
3333
from src.api.global_ import LoopInfo
3434

@@ -1869,11 +1869,8 @@ def p_while_sentence(p):
18691869
gl.LOOPS.pop()
18701870
q = make_block(p[2], p[3])
18711871

1872-
if is_number(p[1]) and p[1].value:
1873-
if q is None:
1874-
warning(p[1].lineno, "Condition is always true and leads to an infinite loop.")
1875-
else:
1876-
warning(p[1].lineno, "Condition is always true and might lead to an infinite loop.")
1872+
if is_number(p[1]):
1873+
warning_condition_is_always(p.lineno(1), bool(p[1].value))
18771874

18781875
p[0] = make_sentence(p.lineno(1), "WHILE", p[1], q)
18791876

0 commit comments

Comments
 (0)