Skip to content

Check normalized identifier names for duplicate arguments - #258

Open
rudycelekli wants to merge 1 commit into
davidhalter:masterfrom
rudycelekli:fix/nfkc-duplicate-arguments-20261101
Open

rudycelekli wants to merge 1 commit into
davidhalter:masterfrom
rudycelekli:fix/nfkc-duplicate-arguments-20261101

Conversation

@rudycelekli

Copy link
Copy Markdown

Python normalizes identifiers with NFKC, so def f(K, K): pass has a duplicate parameter and f(K=1, K=2) repeats a keyword argument. CPython rejects both, but grammar.iter_errors currently returns no errors because the duplicate trackers compare the original spellings.

Normalize the names when checking duplicate parameters and keyword arguments, and use that normalized spelling in the diagnostic. Source spelling and positions in the parse tree remain unchanged. This also covers lambda and keyword-only parameters; it does not case-fold identifiers.

Validation on Python 3.13.5:

  • Nine collision regressions fail against unchanged master; four distinct-name controls pass.
  • All 13 pass with the change, comparing the diagnostics with Python's compile and checking source round trips.
  • All 424 tests in test_python_errors.py pass.
  • The complete test suite, including doctests: 2,001 passed.
  • git diff --check passed.

Added the contributor entry requested by CONTRIBUTING.md. AI assistance: Codex prepared the change and tests; a separate agent inspected the diff and independently ran the 13 focused regressions. No human review or maintainer acceptance is claimed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant