Report TS1518 for all negated Unicode-set union operands - #4832
Open
Ryan Cavanaugh (RyanCavanaugh) with Copilot wants to merge 5 commits into
Open
Report TS1518 for all negated Unicode-set union operands#4832Ryan Cavanaugh (RyanCavanaugh) with Copilot wants to merge 5 commits into
Ryan Cavanaugh (RyanCavanaugh) with Copilot wants to merge 5 commits into
Conversation
Co-authored-by: RyanCavanaugh <6685088+RyanCavanaugh@users.noreply.github.com>
Co-authored-by: RyanCavanaugh <6685088+RyanCavanaugh@users.noreply.github.com>
Co-authored-by: RyanCavanaugh <6685088+RyanCavanaugh@users.noreply.github.com>
Co-authored-by: RyanCavanaugh <6685088+RyanCavanaugh@users.noreply.github.com>
Co-authored-by: RyanCavanaugh <6685088+RyanCavanaugh@users.noreply.github.com>
Copilot started reviewing on behalf of
Ryan Cavanaugh (RyanCavanaugh)
August 5, 2026 18:03
View session
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes Unicode-set scanning so TS1518 is reported regardless of negated union operand order.
Changes:
- Accumulates
MayContainStringsacross union operands. - Reports TS1518 for later string-matching operands.
- Adds regression coverage and updates baselines.
Show a summary per file
| File | Description |
|---|---|
internal/scanner/regexp.go |
Accumulates and diagnoses string-matching operands. |
testdata/tests/cases/compiler/negatedUnicodeSetUnionMayContainStrings.ts |
Tests both operand orders. |
testdata/submoduleAccepted.txt |
Registers accepted baseline divergences. |
testdata/baselines/reference/submoduleAccepted/compiler/regularExpressionScanning(target=es2015).errors.txt.diff |
Records ES2015 diagnostic divergence. |
testdata/baselines/reference/submoduleAccepted/compiler/regularExpressionScanning(target=esnext).errors.txt.diff |
Records ESNext diagnostic divergence. |
testdata/baselines/reference/submodule/compiler/regularExpressionScanning(target=es2015).errors.txt |
Updates ES2015 diagnostics. |
testdata/baselines/reference/submodule/compiler/regularExpressionScanning(target=esnext).errors.txt |
Updates ESNext diagnostics. |
testdata/baselines/reference/compiler/negatedUnicodeSetUnionMayContainStrings.errors.txt |
Captures expected TS1518 errors. |
testdata/baselines/reference/compiler/negatedUnicodeSetUnionMayContainStrings.js |
Captures JavaScript emit. |
testdata/baselines/reference/compiler/negatedUnicodeSetUnionMayContainStrings.symbols |
Captures symbol baseline. |
testdata/baselines/reference/compiler/negatedUnicodeSetUnionMayContainStrings.types |
Captures type baseline. |
Review details
- Files reviewed: 11/11 changed files
- Comments generated: 1
- Review effort level: Balanced
| if isCharacterComplement && p.mayContainStrings { | ||
| p.error(diagnostics.Anything_that_would_possibly_match_more_than_a_single_character_is_invalid_inside_a_negated_character_class, start, p.pos()-start) | ||
| } | ||
| expressionMayContainStrings = expressionMayContainStrings || p.mayContainStrings |
Ryan Cavanaugh (RyanCavanaugh)
approved these changes
Aug 5, 2026
Ryan Cavanaugh (RyanCavanaugh)
left a comment
Member
There was a problem hiding this comment.
Confirmed failing tests do in fact runtime fail
Ryan Cavanaugh (RyanCavanaugh)
marked this pull request as ready for review
August 5, 2026 19:29
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.
Negated
v-mode character classes only checked the first union operand for string matching. Operand order could therefore determine whether invalid regex syntax produced TS1518.MayContainStringsacross each union operand.regularExpressionScanningdivergence baselines.