Repository navigation
Conversation
cdleary
force-pushed
the
cdleary/2026-11-21-warn-non-const-match-pattern
branch
2 times, most recently
from
November 22, 2026 03:48
140e00f to
6e9876f
Compare
cdleary
marked this pull request as ready for review
November 22, 2026 03:48
cdleary
force-pushed
the
cdleary/2026-11-21-warn-non-const-match-pattern
branch
from
November 22, 2026 20:57
6e9876f to
6b15f00
Compare
Flag value comparisons against outer variables before the planned migration to pattern shadowing in google#1909. Keep matching by equality, and use a declared constant for the affected apfloat pattern.
cdleary
force-pushed
the
cdleary/2026-11-21-warn-non-const-match-pattern
branch
from
November 22, 2026 20:59
6b15f00 to
fbae11b
Compare
cdleary
added a commit
to xlsynth/xlsynth
that referenced
this pull request
Nov 23, 2026
… patterns Flag value comparisons against outer variables before the planned migration to pattern shadowing in google#1909. Keep matching by equality, and use a declared constant for the affected apfloat pattern. Upstream-head: fbae11b
This branch has not been deployed
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR introduces a default-on DSLX warning to prepare for the migration to Rust-style match bindings discussed in #1909. The warning,
non_const_match_pattern, flags a bare pattern name that compares the matched value against a non-const outer binding.For example, if
yis a parameter, the first arm ofmatch x { y => y, _ => false }currently tests whetherx == y. Under the proposed rules, that arm would match every value ofxand bind it to a newy. The diagnostic points to the outer declaration so the author can write an explicit equality test or choose a fresh pattern name.Declared constants and value parametrics match by value. In
apfloat::normalize, the comparison value depends only on parametrics, so this PR declares it as aconstto make that intent explicit.The typechecker checks match patterns before lambda rewriting can turn a captured
letinto a parametric binding.All 2,232 selected targets in the optimized
//xls/...sweep passed, including tests for which bindings warn, default warnings-as-errors, and selective suppression.