diff --git a/internal/scanner/regexp.go b/internal/scanner/regexp.go index b1e154f9320..af08c8e1811 100644 --- a/internal/scanner/regexp.go +++ b/internal/scanner/regexp.go @@ -681,6 +681,10 @@ func (p *regExpParser) scanClassSetExpression() { operand = p.text()[start:p.pos()] default: operand = p.scanClassSetOperand() + 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 } } p.mayContainStrings = !isCharacterComplement && expressionMayContainStrings diff --git a/testdata/baselines/reference/compiler/negatedUnicodeSetUnionMayContainStrings.errors.txt b/testdata/baselines/reference/compiler/negatedUnicodeSetUnionMayContainStrings.errors.txt new file mode 100644 index 00000000000..77e188a6755 --- /dev/null +++ b/testdata/baselines/reference/compiler/negatedUnicodeSetUnionMayContainStrings.errors.txt @@ -0,0 +1,12 @@ +negatedUnicodeSetUnionMayContainStrings.ts(1,14): error TS1518: Anything that would possibly match more than a single character is invalid inside a negated character class. +negatedUnicodeSetUnionMayContainStrings.ts(2,15): error TS1518: Anything that would possibly match more than a single character is invalid inside a negated character class. + + +==== negatedUnicodeSetUnionMayContainStrings.ts (2 errors) ==== + const a = /[^\q{xy}b]/v; + ~~~~~~ +!!! error TS1518: Anything that would possibly match more than a single character is invalid inside a negated character class. + const b = /[^b\q{xy}]/v; + ~~~~~~ +!!! error TS1518: Anything that would possibly match more than a single character is invalid inside a negated character class. + \ No newline at end of file diff --git a/testdata/baselines/reference/compiler/negatedUnicodeSetUnionMayContainStrings.js b/testdata/baselines/reference/compiler/negatedUnicodeSetUnionMayContainStrings.js new file mode 100644 index 00000000000..2e2fdfd0f23 --- /dev/null +++ b/testdata/baselines/reference/compiler/negatedUnicodeSetUnionMayContainStrings.js @@ -0,0 +1,11 @@ +//// [tests/cases/compiler/negatedUnicodeSetUnionMayContainStrings.ts] //// + +//// [negatedUnicodeSetUnionMayContainStrings.ts] +const a = /[^\q{xy}b]/v; +const b = /[^b\q{xy}]/v; + + +//// [negatedUnicodeSetUnionMayContainStrings.js] +"use strict"; +const a = /[^\q{xy}b]/v; +const b = /[^b\q{xy}]/v; diff --git a/testdata/baselines/reference/compiler/negatedUnicodeSetUnionMayContainStrings.symbols b/testdata/baselines/reference/compiler/negatedUnicodeSetUnionMayContainStrings.symbols new file mode 100644 index 00000000000..ce279cc82d6 --- /dev/null +++ b/testdata/baselines/reference/compiler/negatedUnicodeSetUnionMayContainStrings.symbols @@ -0,0 +1,9 @@ +//// [tests/cases/compiler/negatedUnicodeSetUnionMayContainStrings.ts] //// + +=== negatedUnicodeSetUnionMayContainStrings.ts === +const a = /[^\q{xy}b]/v; +>a : Symbol(a, Decl(negatedUnicodeSetUnionMayContainStrings.ts, 0, 5)) + +const b = /[^b\q{xy}]/v; +>b : Symbol(b, Decl(negatedUnicodeSetUnionMayContainStrings.ts, 1, 5)) + diff --git a/testdata/baselines/reference/compiler/negatedUnicodeSetUnionMayContainStrings.types b/testdata/baselines/reference/compiler/negatedUnicodeSetUnionMayContainStrings.types new file mode 100644 index 00000000000..857fbe8c2a7 --- /dev/null +++ b/testdata/baselines/reference/compiler/negatedUnicodeSetUnionMayContainStrings.types @@ -0,0 +1,11 @@ +//// [tests/cases/compiler/negatedUnicodeSetUnionMayContainStrings.ts] //// + +=== negatedUnicodeSetUnionMayContainStrings.ts === +const a = /[^\q{xy}b]/v; +>a : RegExp +>/[^\q{xy}b]/v : RegExp + +const b = /[^b\q{xy}]/v; +>b : RegExp +>/[^b\q{xy}]/v : RegExp + diff --git a/testdata/baselines/reference/submodule/compiler/regularExpressionScanning(target=es2015).errors.txt b/testdata/baselines/reference/submodule/compiler/regularExpressionScanning(target=es2015).errors.txt index a32fb1567c5..a7108ecc495 100644 --- a/testdata/baselines/reference/submodule/compiler/regularExpressionScanning(target=es2015).errors.txt +++ b/testdata/baselines/reference/submodule/compiler/regularExpressionScanning(target=es2015).errors.txt @@ -195,19 +195,23 @@ regularExpressionScanning.ts(38,87): error TS1501: This regular expression flag regularExpressionScanning.ts(39,56): error TS1519: Operators must not be mixed within a character class. Wrap it in a nested class instead. regularExpressionScanning.ts(39,67): error TS1005: '&&' expected. regularExpressionScanning.ts(39,77): error TS1501: This regular expression flag is only available when targeting 'es2024' or later. +regularExpressionScanning.ts(40,14): error TS1518: Anything that would possibly match more than a single character is invalid inside a negated character class. regularExpressionScanning.ts(40,83): error TS1501: This regular expression flag is only available when targeting 'es2024' or later. regularExpressionScanning.ts(41,5): error TS1518: Anything that would possibly match more than a single character is invalid inside a negated character class. regularExpressionScanning.ts(41,30): error TS1518: Anything that would possibly match more than a single character is invalid inside a negated character class. regularExpressionScanning.ts(41,83): error TS1501: This regular expression flag is only available when targeting 'es2024' or later. regularExpressionScanning.ts(42,5): error TS1518: Anything that would possibly match more than a single character is invalid inside a negated character class. +regularExpressionScanning.ts(42,18): error TS1518: Anything that would possibly match more than a single character is invalid inside a negated character class. regularExpressionScanning.ts(42,28): error TS1518: Anything that would possibly match more than a single character is invalid inside a negated character class. regularExpressionScanning.ts(42,53): error TS1518: Anything that would possibly match more than a single character is invalid inside a negated character class. regularExpressionScanning.ts(42,77): error TS1501: This regular expression flag is only available when targeting 'es2024' or later. +regularExpressionScanning.ts(43,14): error TS1518: Anything that would possibly match more than a single character is invalid inside a negated character class. regularExpressionScanning.ts(43,95): error TS1501: This regular expression flag is only available when targeting 'es2024' or later. regularExpressionScanning.ts(44,5): error TS1518: Anything that would possibly match more than a single character is invalid inside a negated character class. regularExpressionScanning.ts(44,34): error TS1518: Anything that would possibly match more than a single character is invalid inside a negated character class. regularExpressionScanning.ts(44,95): error TS1501: This regular expression flag is only available when targeting 'es2024' or later. regularExpressionScanning.ts(45,5): error TS1518: Anything that would possibly match more than a single character is invalid inside a negated character class. +regularExpressionScanning.ts(45,22): error TS1518: Anything that would possibly match more than a single character is invalid inside a negated character class. regularExpressionScanning.ts(45,32): error TS1518: Anything that would possibly match more than a single character is invalid inside a negated character class. regularExpressionScanning.ts(45,61): error TS1518: Anything that would possibly match more than a single character is invalid inside a negated character class. regularExpressionScanning.ts(45,89): error TS1501: This regular expression flag is only available when targeting 'es2024' or later. @@ -219,7 +223,7 @@ regularExpressionScanning.ts(47,89): error TS1518: Anything that would possibly regularExpressionScanning.ts(47,101): error TS1501: This regular expression flag is only available when targeting 'es2024' or later. -==== regularExpressionScanning.ts (219 errors) ==== +==== regularExpressionScanning.ts (223 errors) ==== const regexes: RegExp[] = [ // Flags /foo/visualstudiocode, @@ -654,6 +658,8 @@ regularExpressionScanning.ts(47,101): error TS1501: This regular expression flag ~ !!! error TS1501: This regular expression flag is only available when targeting 'es2024' or later. /[^\p{Emoji}\p{RGI_Emoji}][^\p{Emoji}--\p{RGI_Emoji}][^\p{Emoji}&&\p{RGI_Emoji}]/v, + ~~~~~~~~~~~~~ +!!! error TS1518: Anything that would possibly match more than a single character is invalid inside a negated character class. ~ !!! error TS1501: This regular expression flag is only available when targeting 'es2024' or later. /[^\p{RGI_Emoji}\p{Emoji}][^\p{RGI_Emoji}--\p{Emoji}][^\p{RGI_Emoji}&&\p{Emoji}]/v, @@ -665,6 +671,8 @@ regularExpressionScanning.ts(47,101): error TS1501: This regular expression flag !!! error TS1501: This regular expression flag is only available when targeting 'es2024' or later. /[^\p{RGI_Emoji}\q{foo}][^\p{RGI_Emoji}--\q{foo}][^\p{RGI_Emoji}&&\q{foo}]/v, ~~~~~~~~~~~~~ +!!! error TS1518: Anything that would possibly match more than a single character is invalid inside a negated character class. + ~~~~~~~ !!! error TS1518: Anything that would possibly match more than a single character is invalid inside a negated character class. ~~~~~~~~~~~~~ !!! error TS1518: Anything that would possibly match more than a single character is invalid inside a negated character class. @@ -673,6 +681,8 @@ regularExpressionScanning.ts(47,101): error TS1501: This regular expression flag ~ !!! error TS1501: This regular expression flag is only available when targeting 'es2024' or later. /[^\p{Emoji}[[\p{RGI_Emoji}]]][^\p{Emoji}--[[\p{RGI_Emoji}]]][^\p{Emoji}&&[[\p{RGI_Emoji}]]]/v, + ~~~~~~~~~~~~~~~~~ +!!! error TS1518: Anything that would possibly match more than a single character is invalid inside a negated character class. ~ !!! error TS1501: This regular expression flag is only available when targeting 'es2024' or later. /[^[[\p{RGI_Emoji}]]\p{Emoji}][^[[\p{RGI_Emoji}]]--\p{Emoji}][^[[\p{RGI_Emoji}]]&&\p{Emoji}]/v, @@ -684,6 +694,8 @@ regularExpressionScanning.ts(47,101): error TS1501: This regular expression flag !!! error TS1501: This regular expression flag is only available when targeting 'es2024' or later. /[^[[\p{RGI_Emoji}]]\q{foo}][^[[\p{RGI_Emoji}]]--\q{foo}][^[[\p{RGI_Emoji}]]&&\q{foo}]/v, ~~~~~~~~~~~~~~~~~ +!!! error TS1518: Anything that would possibly match more than a single character is invalid inside a negated character class. + ~~~~~~~ !!! error TS1518: Anything that would possibly match more than a single character is invalid inside a negated character class. ~~~~~~~~~~~~~~~~~ !!! error TS1518: Anything that would possibly match more than a single character is invalid inside a negated character class. diff --git a/testdata/baselines/reference/submodule/compiler/regularExpressionScanning(target=esnext).errors.txt b/testdata/baselines/reference/submodule/compiler/regularExpressionScanning(target=esnext).errors.txt index c2d144d42c5..34327cfed96 100644 --- a/testdata/baselines/reference/submodule/compiler/regularExpressionScanning(target=esnext).errors.txt +++ b/testdata/baselines/reference/submodule/compiler/regularExpressionScanning(target=esnext).errors.txt @@ -177,14 +177,18 @@ regularExpressionScanning.ts(38,75): error TS1508: Unexpected '&'. Did you mean regularExpressionScanning.ts(38,85): error TS1520: Expected a class set operand. regularExpressionScanning.ts(39,56): error TS1519: Operators must not be mixed within a character class. Wrap it in a nested class instead. regularExpressionScanning.ts(39,67): error TS1005: '&&' expected. +regularExpressionScanning.ts(40,14): error TS1518: Anything that would possibly match more than a single character is invalid inside a negated character class. regularExpressionScanning.ts(41,5): error TS1518: Anything that would possibly match more than a single character is invalid inside a negated character class. regularExpressionScanning.ts(41,30): error TS1518: Anything that would possibly match more than a single character is invalid inside a negated character class. regularExpressionScanning.ts(42,5): error TS1518: Anything that would possibly match more than a single character is invalid inside a negated character class. +regularExpressionScanning.ts(42,18): error TS1518: Anything that would possibly match more than a single character is invalid inside a negated character class. regularExpressionScanning.ts(42,28): error TS1518: Anything that would possibly match more than a single character is invalid inside a negated character class. regularExpressionScanning.ts(42,53): error TS1518: Anything that would possibly match more than a single character is invalid inside a negated character class. +regularExpressionScanning.ts(43,14): error TS1518: Anything that would possibly match more than a single character is invalid inside a negated character class. regularExpressionScanning.ts(44,5): error TS1518: Anything that would possibly match more than a single character is invalid inside a negated character class. regularExpressionScanning.ts(44,34): error TS1518: Anything that would possibly match more than a single character is invalid inside a negated character class. regularExpressionScanning.ts(45,5): error TS1518: Anything that would possibly match more than a single character is invalid inside a negated character class. +regularExpressionScanning.ts(45,22): error TS1518: Anything that would possibly match more than a single character is invalid inside a negated character class. regularExpressionScanning.ts(45,32): error TS1518: Anything that would possibly match more than a single character is invalid inside a negated character class. regularExpressionScanning.ts(45,61): error TS1518: Anything that would possibly match more than a single character is invalid inside a negated character class. regularExpressionScanning.ts(46,5): error TS1518: Anything that would possibly match more than a single character is invalid inside a negated character class. @@ -193,7 +197,7 @@ regularExpressionScanning.ts(47,5): error TS1518: Anything that would possibly m regularExpressionScanning.ts(47,89): error TS1518: Anything that would possibly match more than a single character is invalid inside a negated character class. -==== regularExpressionScanning.ts (193 errors) ==== +==== regularExpressionScanning.ts (197 errors) ==== const regexes: RegExp[] = [ // Flags /foo/visualstudiocode, @@ -592,6 +596,8 @@ regularExpressionScanning.ts(47,89): error TS1518: Anything that would possibly !!! error TS1005: '&&' expected. /[^\p{Emoji}\p{RGI_Emoji}][^\p{Emoji}--\p{RGI_Emoji}][^\p{Emoji}&&\p{RGI_Emoji}]/v, + ~~~~~~~~~~~~~ +!!! error TS1518: Anything that would possibly match more than a single character is invalid inside a negated character class. /[^\p{RGI_Emoji}\p{Emoji}][^\p{RGI_Emoji}--\p{Emoji}][^\p{RGI_Emoji}&&\p{Emoji}]/v, ~~~~~~~~~~~~~ !!! error TS1518: Anything that would possibly match more than a single character is invalid inside a negated character class. @@ -599,12 +605,16 @@ regularExpressionScanning.ts(47,89): error TS1518: Anything that would possibly !!! error TS1518: Anything that would possibly match more than a single character is invalid inside a negated character class. /[^\p{RGI_Emoji}\q{foo}][^\p{RGI_Emoji}--\q{foo}][^\p{RGI_Emoji}&&\q{foo}]/v, ~~~~~~~~~~~~~ +!!! error TS1518: Anything that would possibly match more than a single character is invalid inside a negated character class. + ~~~~~~~ !!! error TS1518: Anything that would possibly match more than a single character is invalid inside a negated character class. ~~~~~~~~~~~~~ !!! error TS1518: Anything that would possibly match more than a single character is invalid inside a negated character class. ~~~~~~~~~~~~~~~~~~~~~~ !!! error TS1518: Anything that would possibly match more than a single character is invalid inside a negated character class. /[^\p{Emoji}[[\p{RGI_Emoji}]]][^\p{Emoji}--[[\p{RGI_Emoji}]]][^\p{Emoji}&&[[\p{RGI_Emoji}]]]/v, + ~~~~~~~~~~~~~~~~~ +!!! error TS1518: Anything that would possibly match more than a single character is invalid inside a negated character class. /[^[[\p{RGI_Emoji}]]\p{Emoji}][^[[\p{RGI_Emoji}]]--\p{Emoji}][^[[\p{RGI_Emoji}]]&&\p{Emoji}]/v, ~~~~~~~~~~~~~~~~~ !!! error TS1518: Anything that would possibly match more than a single character is invalid inside a negated character class. @@ -612,6 +622,8 @@ regularExpressionScanning.ts(47,89): error TS1518: Anything that would possibly !!! error TS1518: Anything that would possibly match more than a single character is invalid inside a negated character class. /[^[[\p{RGI_Emoji}]]\q{foo}][^[[\p{RGI_Emoji}]]--\q{foo}][^[[\p{RGI_Emoji}]]&&\q{foo}]/v, ~~~~~~~~~~~~~~~~~ +!!! error TS1518: Anything that would possibly match more than a single character is invalid inside a negated character class. + ~~~~~~~ !!! error TS1518: Anything that would possibly match more than a single character is invalid inside a negated character class. ~~~~~~~~~~~~~~~~~ !!! error TS1518: Anything that would possibly match more than a single character is invalid inside a negated character class. diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/regularExpressionScanning(target=es2015).errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/regularExpressionScanning(target=es2015).errors.txt.diff new file mode 100644 index 00000000000..0ec99ef1a2c --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/compiler/regularExpressionScanning(target=es2015).errors.txt.diff @@ -0,0 +1,71 @@ +--- old.regularExpressionScanning(target=es2015).errors.txt ++++ new.regularExpressionScanning(target=es2015).errors.txt +@@= skipped -194, +194 lines =@@ + regularExpressionScanning.ts(39,56): error TS1519: Operators must not be mixed within a character class. Wrap it in a nested class instead. + regularExpressionScanning.ts(39,67): error TS1005: '&&' expected. + regularExpressionScanning.ts(39,77): error TS1501: This regular expression flag is only available when targeting 'es2024' or later. ++regularExpressionScanning.ts(40,14): error TS1518: Anything that would possibly match more than a single character is invalid inside a negated character class. + regularExpressionScanning.ts(40,83): error TS1501: This regular expression flag is only available when targeting 'es2024' or later. + regularExpressionScanning.ts(41,5): error TS1518: Anything that would possibly match more than a single character is invalid inside a negated character class. + regularExpressionScanning.ts(41,30): error TS1518: Anything that would possibly match more than a single character is invalid inside a negated character class. + regularExpressionScanning.ts(41,83): error TS1501: This regular expression flag is only available when targeting 'es2024' or later. + regularExpressionScanning.ts(42,5): error TS1518: Anything that would possibly match more than a single character is invalid inside a negated character class. ++regularExpressionScanning.ts(42,18): error TS1518: Anything that would possibly match more than a single character is invalid inside a negated character class. + regularExpressionScanning.ts(42,28): error TS1518: Anything that would possibly match more than a single character is invalid inside a negated character class. + regularExpressionScanning.ts(42,53): error TS1518: Anything that would possibly match more than a single character is invalid inside a negated character class. + regularExpressionScanning.ts(42,77): error TS1501: This regular expression flag is only available when targeting 'es2024' or later. ++regularExpressionScanning.ts(43,14): error TS1518: Anything that would possibly match more than a single character is invalid inside a negated character class. + regularExpressionScanning.ts(43,95): error TS1501: This regular expression flag is only available when targeting 'es2024' or later. + regularExpressionScanning.ts(44,5): error TS1518: Anything that would possibly match more than a single character is invalid inside a negated character class. + regularExpressionScanning.ts(44,34): error TS1518: Anything that would possibly match more than a single character is invalid inside a negated character class. + regularExpressionScanning.ts(44,95): error TS1501: This regular expression flag is only available when targeting 'es2024' or later. + regularExpressionScanning.ts(45,5): error TS1518: Anything that would possibly match more than a single character is invalid inside a negated character class. ++regularExpressionScanning.ts(45,22): error TS1518: Anything that would possibly match more than a single character is invalid inside a negated character class. + regularExpressionScanning.ts(45,32): error TS1518: Anything that would possibly match more than a single character is invalid inside a negated character class. + regularExpressionScanning.ts(45,61): error TS1518: Anything that would possibly match more than a single character is invalid inside a negated character class. + regularExpressionScanning.ts(45,89): error TS1501: This regular expression flag is only available when targeting 'es2024' or later. +@@= skipped -24, +28 lines =@@ + regularExpressionScanning.ts(47,101): error TS1501: This regular expression flag is only available when targeting 'es2024' or later. + + +-==== regularExpressionScanning.ts (219 errors) ==== ++==== regularExpressionScanning.ts (223 errors) ==== + const regexes: RegExp[] = [ + // Flags + /foo/visualstudiocode, +@@= skipped -435, +435 lines =@@ + ~ + !!! error TS1501: This regular expression flag is only available when targeting 'es2024' or later. + /[^\p{Emoji}\p{RGI_Emoji}][^\p{Emoji}--\p{RGI_Emoji}][^\p{Emoji}&&\p{RGI_Emoji}]/v, ++ ~~~~~~~~~~~~~ ++!!! error TS1518: Anything that would possibly match more than a single character is invalid inside a negated character class. + ~ + !!! error TS1501: This regular expression flag is only available when targeting 'es2024' or later. + /[^\p{RGI_Emoji}\p{Emoji}][^\p{RGI_Emoji}--\p{Emoji}][^\p{RGI_Emoji}&&\p{Emoji}]/v, +@@= skipped -12, +14 lines =@@ + /[^\p{RGI_Emoji}\q{foo}][^\p{RGI_Emoji}--\q{foo}][^\p{RGI_Emoji}&&\q{foo}]/v, + ~~~~~~~~~~~~~ + !!! error TS1518: Anything that would possibly match more than a single character is invalid inside a negated character class. ++ ~~~~~~~ ++!!! error TS1518: Anything that would possibly match more than a single character is invalid inside a negated character class. + ~~~~~~~~~~~~~ + !!! error TS1518: Anything that would possibly match more than a single character is invalid inside a negated character class. + ~~~~~~~~~~~~~~~~~~~~~~ +@@= skipped -7, +9 lines =@@ + ~ + !!! error TS1501: This regular expression flag is only available when targeting 'es2024' or later. + /[^\p{Emoji}[[\p{RGI_Emoji}]]][^\p{Emoji}--[[\p{RGI_Emoji}]]][^\p{Emoji}&&[[\p{RGI_Emoji}]]]/v, ++ ~~~~~~~~~~~~~~~~~ ++!!! error TS1518: Anything that would possibly match more than a single character is invalid inside a negated character class. + ~ + !!! error TS1501: This regular expression flag is only available when targeting 'es2024' or later. + /[^[[\p{RGI_Emoji}]]\p{Emoji}][^[[\p{RGI_Emoji}]]--\p{Emoji}][^[[\p{RGI_Emoji}]]&&\p{Emoji}]/v, +@@= skipped -11, +13 lines =@@ + !!! error TS1501: This regular expression flag is only available when targeting 'es2024' or later. + /[^[[\p{RGI_Emoji}]]\q{foo}][^[[\p{RGI_Emoji}]]--\q{foo}][^[[\p{RGI_Emoji}]]&&\q{foo}]/v, + ~~~~~~~~~~~~~~~~~ ++!!! error TS1518: Anything that would possibly match more than a single character is invalid inside a negated character class. ++ ~~~~~~~ + !!! error TS1518: Anything that would possibly match more than a single character is invalid inside a negated character class. + ~~~~~~~~~~~~~~~~~ + !!! error TS1518: Anything that would possibly match more than a single character is invalid inside a negated character class. \ No newline at end of file diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/regularExpressionScanning(target=esnext).errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/regularExpressionScanning(target=esnext).errors.txt.diff new file mode 100644 index 00000000000..857148f762f --- /dev/null +++ b/testdata/baselines/reference/submoduleAccepted/compiler/regularExpressionScanning(target=esnext).errors.txt.diff @@ -0,0 +1,64 @@ +--- old.regularExpressionScanning(target=esnext).errors.txt ++++ new.regularExpressionScanning(target=esnext).errors.txt +@@= skipped -176, +176 lines =@@ + regularExpressionScanning.ts(38,85): error TS1520: Expected a class set operand. + regularExpressionScanning.ts(39,56): error TS1519: Operators must not be mixed within a character class. Wrap it in a nested class instead. + regularExpressionScanning.ts(39,67): error TS1005: '&&' expected. ++regularExpressionScanning.ts(40,14): error TS1518: Anything that would possibly match more than a single character is invalid inside a negated character class. + regularExpressionScanning.ts(41,5): error TS1518: Anything that would possibly match more than a single character is invalid inside a negated character class. + regularExpressionScanning.ts(41,30): error TS1518: Anything that would possibly match more than a single character is invalid inside a negated character class. + regularExpressionScanning.ts(42,5): error TS1518: Anything that would possibly match more than a single character is invalid inside a negated character class. ++regularExpressionScanning.ts(42,18): error TS1518: Anything that would possibly match more than a single character is invalid inside a negated character class. + regularExpressionScanning.ts(42,28): error TS1518: Anything that would possibly match more than a single character is invalid inside a negated character class. + regularExpressionScanning.ts(42,53): error TS1518: Anything that would possibly match more than a single character is invalid inside a negated character class. ++regularExpressionScanning.ts(43,14): error TS1518: Anything that would possibly match more than a single character is invalid inside a negated character class. + regularExpressionScanning.ts(44,5): error TS1518: Anything that would possibly match more than a single character is invalid inside a negated character class. + regularExpressionScanning.ts(44,34): error TS1518: Anything that would possibly match more than a single character is invalid inside a negated character class. + regularExpressionScanning.ts(45,5): error TS1518: Anything that would possibly match more than a single character is invalid inside a negated character class. ++regularExpressionScanning.ts(45,22): error TS1518: Anything that would possibly match more than a single character is invalid inside a negated character class. + regularExpressionScanning.ts(45,32): error TS1518: Anything that would possibly match more than a single character is invalid inside a negated character class. + regularExpressionScanning.ts(45,61): error TS1518: Anything that would possibly match more than a single character is invalid inside a negated character class. + regularExpressionScanning.ts(46,5): error TS1518: Anything that would possibly match more than a single character is invalid inside a negated character class. +@@= skipped -16, +20 lines =@@ + regularExpressionScanning.ts(47,89): error TS1518: Anything that would possibly match more than a single character is invalid inside a negated character class. + + +-==== regularExpressionScanning.ts (193 errors) ==== ++==== regularExpressionScanning.ts (197 errors) ==== + const regexes: RegExp[] = [ + // Flags + /foo/visualstudiocode, +@@= skipped -399, +399 lines =@@ + + !!! error TS1005: '&&' expected. + /[^\p{Emoji}\p{RGI_Emoji}][^\p{Emoji}--\p{RGI_Emoji}][^\p{Emoji}&&\p{RGI_Emoji}]/v, ++ ~~~~~~~~~~~~~ ++!!! error TS1518: Anything that would possibly match more than a single character is invalid inside a negated character class. + /[^\p{RGI_Emoji}\p{Emoji}][^\p{RGI_Emoji}--\p{Emoji}][^\p{RGI_Emoji}&&\p{Emoji}]/v, + ~~~~~~~~~~~~~ + !!! error TS1518: Anything that would possibly match more than a single character is invalid inside a negated character class. +@@= skipped -8, +10 lines =@@ + /[^\p{RGI_Emoji}\q{foo}][^\p{RGI_Emoji}--\q{foo}][^\p{RGI_Emoji}&&\q{foo}]/v, + ~~~~~~~~~~~~~ + !!! error TS1518: Anything that would possibly match more than a single character is invalid inside a negated character class. ++ ~~~~~~~ ++!!! error TS1518: Anything that would possibly match more than a single character is invalid inside a negated character class. + ~~~~~~~~~~~~~ + !!! error TS1518: Anything that would possibly match more than a single character is invalid inside a negated character class. + ~~~~~~~~~~~~~~~~~~~~~~ + !!! error TS1518: Anything that would possibly match more than a single character is invalid inside a negated character class. + /[^\p{Emoji}[[\p{RGI_Emoji}]]][^\p{Emoji}--[[\p{RGI_Emoji}]]][^\p{Emoji}&&[[\p{RGI_Emoji}]]]/v, ++ ~~~~~~~~~~~~~~~~~ ++!!! error TS1518: Anything that would possibly match more than a single character is invalid inside a negated character class. + /[^[[\p{RGI_Emoji}]]\p{Emoji}][^[[\p{RGI_Emoji}]]--\p{Emoji}][^[[\p{RGI_Emoji}]]&&\p{Emoji}]/v, + ~~~~~~~~~~~~~~~~~ + !!! error TS1518: Anything that would possibly match more than a single character is invalid inside a negated character class. +@@= skipped -12, +16 lines =@@ + !!! error TS1518: Anything that would possibly match more than a single character is invalid inside a negated character class. + /[^[[\p{RGI_Emoji}]]\q{foo}][^[[\p{RGI_Emoji}]]--\q{foo}][^[[\p{RGI_Emoji}]]&&\q{foo}]/v, + ~~~~~~~~~~~~~~~~~ ++!!! error TS1518: Anything that would possibly match more than a single character is invalid inside a negated character class. ++ ~~~~~~~ + !!! error TS1518: Anything that would possibly match more than a single character is invalid inside a negated character class. + ~~~~~~~~~~~~~~~~~ + !!! error TS1518: Anything that would possibly match more than a single character is invalid inside a negated character class. \ No newline at end of file diff --git a/testdata/submoduleAccepted.txt b/testdata/submoduleAccepted.txt index 25f814b6ae9..6962ec683a4 100644 --- a/testdata/submoduleAccepted.txt +++ b/testdata/submoduleAccepted.txt @@ -666,6 +666,8 @@ conformance/types.asyncGenerators.es2018.2.errors.txt.diff ## Error spans for non-BMP characters (surrogate pairs) are measured by code points instead of UTF-16 code units, causing span widths and positions to shift compiler/regularExpressionCharacterClassRangeOrder.errors.txt.diff +compiler/regularExpressionScanning(target=es2015).errors.txt.diff +compiler/regularExpressionScanning(target=esnext).errors.txt.diff compiler/regularExpressionWithNonBMPFlags.errors.txt.diff compiler/unicodeEscapesInNames02(target=es2015).errors.txt.diff diff --git a/testdata/tests/cases/compiler/negatedUnicodeSetUnionMayContainStrings.ts b/testdata/tests/cases/compiler/negatedUnicodeSetUnionMayContainStrings.ts new file mode 100644 index 00000000000..35bef25b15d --- /dev/null +++ b/testdata/tests/cases/compiler/negatedUnicodeSetUnionMayContainStrings.ts @@ -0,0 +1,4 @@ +// @target: es2024 + +const a = /[^\q{xy}b]/v; +const b = /[^b\q{xy}]/v;