Skip to content

lint: W010 (duplicate dict key) never fires inside unobserved: or a match arm #783

Description

@Nitjsefnie

Describe the bug

W010 (duplicate dict key) is never reported for a dict literal inside an unobserved: block or a match arm. check_dup_keys recurses through expressions and the IF/FUNC/RETURN/FOR/LOOP/PROGRAM/TRY/LIST node types, but AST_MATCH (src/lint.c:702) and AST_UNOBSERVED (src/lint.c:704) sit in its break-only group, so the literal is never reached and the emission at src/lint.c:631 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:

w010_d is {"a": 1, "a": 2}
print of w010_d

Silent — inside unobserved::

unobserved:
    w010_d is {"a": 1, "a": 2}
print of w010_d

Silent — inside a match arm:

match 1:
    case 1:
        w010_d is {"a": 1, "a": 2}
    case _:
        x is 0
print of 1

Expected behavior

warning[W010]: duplicate dict key 'a' in all three.

Actual behavior

$ eigenscript --lint w010_control.eigs
w010_control.eigs:1: warning[W010]: duplicate dict key 'a'
$ eigenscript --lint w010_unobs.eigs
w010_unobs.eigs: no issues found
$ eigenscript --lint w010_match.eigs
w010_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