Fix syntax error false positive on alternative match patterns by ntBre · Pull Request #21362 · astral-sh/ruff (original) (raw)

@ntBre

Summary

Fixes #21360 by using the union of names instead of overwriting them, as Micha suggested originally on #21104.

This avoids overwriting the n name in the Subscript by the empty set of names visited in the nested OR pattern before visiting the other arm of the outer OR pattern.

Test Plan

A new inline test case taken from the issue

@ntBre added the bug

Something isn't working

label

Nov 10, 2025

@ntBre ntBre marked this pull request as ready for review

November 10, 2025 13:39

MichaReiser

MichaReiser

@ntBre ntBre deleted the brent/alt-patterns-2 branch

November 10, 2025 15:51

dcreager added a commit that referenced this pull request

Nov 11, 2025

@dcreager

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters

[ Show hidden characters]({{ revealButtonHref }})