Skip to content

lint: W002 (unused parameter) never fires for a function defined inside unobserved: or a match arm #781

Description

@Nitjsefnie

Describe the bug

W002 (unused parameter) is never reported for a function defined inside an unobserved: block or a match arm. check_unused_params recurses only through IF/FUNC/FOR/PROGRAM, and lists both AST_MATCH (src/lint.c:1530) and AST_UNOBSERVED (src/lint.c:1532) in its break-only group, so a nested define is never visited and the emission at src/lint.c:1475 is never reached.

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 w002_ctrl(unusedparam) as:
    return 1
w002_ctrl of 9

Silent — inside unobserved::

unobserved:
    define w002_u(unusedparam) as:
        return 1
w002_u of 9

Silent — inside a match arm:

match 1:
    case 1:
        define w002_m(unusedparam) as:
            return 1
    case _:
        x is 0
w002_m of 9

Expected behavior

warning[W002]: unused parameter 'unusedparam' in function '...' in all three, as the control already produces.

Actual behavior

$ eigenscript --lint w002_control.eigs
w002_control.eigs:1: warning[W002]: unused parameter 'unusedparam' in function 'w002_ctrl'
$ eigenscript --lint w002_unobs.eigs
w002_unobs.eigs: no issues found
$ eigenscript --lint w002_match.eigs
w002_match.eigs: no issues found

Both silent programs run (exit 0) and call the nested function, so these are reachable definitions.

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