Describe the bug
W003 (unreachable code after return) is never reported for a function defined inside an unobserved: block or a match arm. check_func_unreachable only scans bodies of AST_FUNC nodes its walker reaches, and both AST_MATCH (src/lint.c:1364) and AST_UNOBSERVED (src/lint.c:1366) sit in its break-only group — so the body is never handed to check_unreachable (src/lint.c:1308) and the emission at src/lint.c:399 never fires.
Surfaced while doing #779, which made these switches enumerable; it neither caused nor fixed this. Line numbers resolved against main @ 23edbc25.
To reproduce
Control — reported correctly:
define w003_ctrl() as:
return 1
dead_stmt is 2
w003_ctrl of null
Silent — inside unobserved::
unobserved:
define w003_u() as:
return 1
dead_stmt is 2
w003_u of null
Silent — inside a match arm:
match 1:
case 1:
define w003_m() as:
return 1
dead_stmt is 2
case _:
x is 0
w003_m of null
Expected behavior
warning[W003]: unreachable code after return in all three.
Actual behavior
$ eigenscript --lint w003_control.eigs
w003_control.eigs:3: warning[W003]: unreachable code after return
$ eigenscript --lint w003_unobs.eigs
w003_unobs.eigs: no issues found
$ eigenscript --lint w003_match.eigs
w003_match.eigs: no issues found
Environment
- OS: Debian 13 (x86_64)
- GCC version: 14
- EigenScript version: 0.34.0 (
main @ 23edbc25)
Describe the bug
W003(unreachable code afterreturn) is never reported for a function defined inside anunobserved:block or amatcharm.check_func_unreachableonly scans bodies ofAST_FUNCnodes its walker reaches, and bothAST_MATCH(src/lint.c:1364) andAST_UNOBSERVED(src/lint.c:1366) sit in its break-only group — so the body is never handed tocheck_unreachable(src/lint.c:1308) and the emission atsrc/lint.c:399never fires.Surfaced while doing #779, which made these switches enumerable; it neither caused nor fixed this. Line numbers resolved against
main@23edbc25.To reproduce
Control — reported correctly:
Silent — inside
unobserved::Silent — inside a
matcharm:Expected behavior
warning[W003]: unreachable code after returnin all three.Actual behavior
Environment
main@23edbc25)