Skip to content

lint: W003 (unreachable code) never fires for a function defined inside unobserved: or a match arm #782

Description

@Nitjsefnie

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workinggood first issueGood for newcomers

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions