From 40ee30bfe1cdef93d2c2e90e0c107e70e3867a08 Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Tue, 4 Nov 2025 19:10:48 -0800 Subject: [PATCH 01/33] wip --- internal/checker/grammarchecks.go | 39 +- internal/checker/regexpchecks.go | 42 + internal/scanner/regexp.go | 1528 +++++++++++++++++ .../compiler/regexpTestSimple.errors.txt | 12 + .../reference/compiler/regexpTestSimple.js | 10 + .../compiler/regexpTestSimple.symbols | 7 + .../reference/compiler/regexpTestSimple.types | 8 + ...angeYourTargetLibraryES2016Plus.errors.txt | 20 +- ...ourTargetLibraryES2016Plus.errors.txt.diff | 47 - ...acketInCharClass(target=es2015).errors.txt | 15 + ...InCharClass(target=es2015).errors.txt.diff | 19 - ...nBracketInCharClass(target=es5).errors.txt | 15 + ...ketInCharClass(target=es5).errors.txt.diff | 19 - ...acketInCharClass(target=esnext).errors.txt | 12 + ...InCharClass(target=esnext).errors.txt.diff | 16 - .../regularExpressionAnnexB.errors.txt | 269 +++ .../regularExpressionAnnexB.errors.txt.diff | 273 --- ...ressionCharacterClassRangeOrder.errors.txt | 40 + ...onCharacterClassRangeOrder.errors.txt.diff | 74 +- ...xpressionExtendedUnicodeEscapes.errors.txt | 15 + ...sionExtendedUnicodeEscapes.errors.txt.diff | 19 - ...rExpressionGroupNameSuggestions.errors.txt | 12 + ...essionGroupNameSuggestions.errors.txt.diff | 16 - ...pressionScanning(target=es2015).errors.txt | 709 ++++++++ ...ionScanning(target=es2015).errors.txt.diff | 713 -------- ...rExpressionScanning(target=es5).errors.txt | 709 ++++++++ ...essionScanning(target=es5).errors.txt.diff | 713 -------- ...pressionScanning(target=esnext).errors.txt | 631 +++++++ ...ionScanning(target=esnext).errors.txt.diff | 635 ------- ...pertyValueExpressionSuggestions.errors.txt | 25 + ...ValueExpressionSuggestions.errors.txt.diff | 29 - ...egularExpressionWithNonBMPFlags.errors.txt | 29 + ...rExpressionWithNonBMPFlags.errors.txt.diff | 39 +- ...numericSeparators.unicodeEscape.errors.txt | 62 +- ...icSeparators.unicodeEscape.errors.txt.diff | 155 +- .../conformance/parser579071.errors.txt | 7 + .../conformance/parser579071.errors.txt.diff | 11 - ...gularExpressionDivideAmbiguity3.errors.txt | 5 +- ...ExpressionDivideAmbiguity3.errors.txt.diff | 14 - ...egularExpressions14(target=es5).errors.txt | 12 + ...rExpressions14(target=es5).errors.txt.diff | 16 - ...egularExpressions14(target=es6).errors.txt | 12 + ...rExpressions14(target=es6).errors.txt.diff | 16 - ...egularExpressions17(target=es5).errors.txt | 23 + ...rExpressions17(target=es5).errors.txt.diff | 27 - ...egularExpressions17(target=es6).errors.txt | 23 + ...rExpressions17(target=es6).errors.txt.diff | 27 - ...egularExpressions19(target=es5).errors.txt | 8 + ...rExpressions19(target=es5).errors.txt.diff | 12 - ...egularExpressions19(target=es6).errors.txt | 8 + ...rExpressions19(target=es6).errors.txt.diff | 12 - .../tests/cases/compiler/regexpTestSimple.ts | 3 + 52 files changed, 4370 insertions(+), 2842 deletions(-) create mode 100644 internal/checker/regexpchecks.go create mode 100644 internal/scanner/regexp.go create mode 100644 testdata/baselines/reference/compiler/regexpTestSimple.errors.txt create mode 100644 testdata/baselines/reference/compiler/regexpTestSimple.js create mode 100644 testdata/baselines/reference/compiler/regexpTestSimple.symbols create mode 100644 testdata/baselines/reference/compiler/regexpTestSimple.types delete mode 100644 testdata/baselines/reference/submodule/compiler/doYouNeedToChangeYourTargetLibraryES2016Plus.errors.txt.diff create mode 100644 testdata/baselines/reference/submodule/compiler/regExpWithOpenBracketInCharClass(target=es2015).errors.txt delete mode 100644 testdata/baselines/reference/submodule/compiler/regExpWithOpenBracketInCharClass(target=es2015).errors.txt.diff create mode 100644 testdata/baselines/reference/submodule/compiler/regExpWithOpenBracketInCharClass(target=es5).errors.txt delete mode 100644 testdata/baselines/reference/submodule/compiler/regExpWithOpenBracketInCharClass(target=es5).errors.txt.diff create mode 100644 testdata/baselines/reference/submodule/compiler/regExpWithOpenBracketInCharClass(target=esnext).errors.txt delete mode 100644 testdata/baselines/reference/submodule/compiler/regExpWithOpenBracketInCharClass(target=esnext).errors.txt.diff create mode 100644 testdata/baselines/reference/submodule/compiler/regularExpressionAnnexB.errors.txt delete mode 100644 testdata/baselines/reference/submodule/compiler/regularExpressionAnnexB.errors.txt.diff create mode 100644 testdata/baselines/reference/submodule/compiler/regularExpressionCharacterClassRangeOrder.errors.txt create mode 100644 testdata/baselines/reference/submodule/compiler/regularExpressionExtendedUnicodeEscapes.errors.txt delete mode 100644 testdata/baselines/reference/submodule/compiler/regularExpressionExtendedUnicodeEscapes.errors.txt.diff create mode 100644 testdata/baselines/reference/submodule/compiler/regularExpressionGroupNameSuggestions.errors.txt delete mode 100644 testdata/baselines/reference/submodule/compiler/regularExpressionGroupNameSuggestions.errors.txt.diff create mode 100644 testdata/baselines/reference/submodule/compiler/regularExpressionScanning(target=es2015).errors.txt delete mode 100644 testdata/baselines/reference/submodule/compiler/regularExpressionScanning(target=es2015).errors.txt.diff create mode 100644 testdata/baselines/reference/submodule/compiler/regularExpressionScanning(target=es5).errors.txt delete mode 100644 testdata/baselines/reference/submodule/compiler/regularExpressionScanning(target=es5).errors.txt.diff create mode 100644 testdata/baselines/reference/submodule/compiler/regularExpressionScanning(target=esnext).errors.txt delete mode 100644 testdata/baselines/reference/submodule/compiler/regularExpressionScanning(target=esnext).errors.txt.diff create mode 100644 testdata/baselines/reference/submodule/compiler/regularExpressionUnicodePropertyValueExpressionSuggestions.errors.txt delete mode 100644 testdata/baselines/reference/submodule/compiler/regularExpressionUnicodePropertyValueExpressionSuggestions.errors.txt.diff create mode 100644 testdata/baselines/reference/submodule/compiler/regularExpressionWithNonBMPFlags.errors.txt create mode 100644 testdata/baselines/reference/submodule/conformance/parser579071.errors.txt delete mode 100644 testdata/baselines/reference/submodule/conformance/parser579071.errors.txt.diff delete mode 100644 testdata/baselines/reference/submodule/conformance/parserRegularExpressionDivideAmbiguity3.errors.txt.diff create mode 100644 testdata/baselines/reference/submodule/conformance/unicodeExtendedEscapesInRegularExpressions14(target=es5).errors.txt delete mode 100644 testdata/baselines/reference/submodule/conformance/unicodeExtendedEscapesInRegularExpressions14(target=es5).errors.txt.diff create mode 100644 testdata/baselines/reference/submodule/conformance/unicodeExtendedEscapesInRegularExpressions14(target=es6).errors.txt delete mode 100644 testdata/baselines/reference/submodule/conformance/unicodeExtendedEscapesInRegularExpressions14(target=es6).errors.txt.diff create mode 100644 testdata/baselines/reference/submodule/conformance/unicodeExtendedEscapesInRegularExpressions17(target=es5).errors.txt delete mode 100644 testdata/baselines/reference/submodule/conformance/unicodeExtendedEscapesInRegularExpressions17(target=es5).errors.txt.diff create mode 100644 testdata/baselines/reference/submodule/conformance/unicodeExtendedEscapesInRegularExpressions17(target=es6).errors.txt delete mode 100644 testdata/baselines/reference/submodule/conformance/unicodeExtendedEscapesInRegularExpressions17(target=es6).errors.txt.diff create mode 100644 testdata/baselines/reference/submodule/conformance/unicodeExtendedEscapesInRegularExpressions19(target=es5).errors.txt delete mode 100644 testdata/baselines/reference/submodule/conformance/unicodeExtendedEscapesInRegularExpressions19(target=es5).errors.txt.diff create mode 100644 testdata/baselines/reference/submodule/conformance/unicodeExtendedEscapesInRegularExpressions19(target=es6).errors.txt delete mode 100644 testdata/baselines/reference/submodule/conformance/unicodeExtendedEscapesInRegularExpressions19(target=es6).errors.txt.diff create mode 100644 testdata/tests/cases/compiler/regexpTestSimple.ts diff --git a/internal/checker/grammarchecks.go b/internal/checker/grammarchecks.go index ff30650d5d..8500240c2b 100644 --- a/internal/checker/grammarchecks.go +++ b/internal/checker/grammarchecks.go @@ -54,43 +54,10 @@ func (c *Checker) grammarErrorOnNodeSkippedOnNoEmit(node *ast.Node, message *dia return false } -func (c *Checker) checkGrammarRegularExpressionLiteral(_ *ast.RegularExpressionLiteral) bool { - // !!! - // Unclear if this is needed until regular expression parsing is more thoroughly implemented. +func (c *Checker) checkGrammarRegularExpressionLiteral(node *ast.RegularExpressionLiteral) bool { + // Validate the regular expression during semantic analysis + c.validateRegularExpressionLiteralNode(node) return false - // sourceFile := ast.GetSourceFileOfNode(node.AsNode()) - // if !c.hasParseDiagnostics(sourceFile) && !node.IsUnterminated { - // var lastError *ast.Diagnostic - // scanner := NewScanner() - // scanner.skipTrivia = true - // scanner.SetScriptTarget(sourceFile.LanguageVersion) - // scanner.SetLanguageVariant(sourceFile.LanguageVariant) - // scanner.SetOnError(func(message *diagnostics.Message, start int, length int, args ...any) { - // // !!! - // // Original uses `tokenEnd()` - unclear if this is the same as the `start` passed in here. - // // const start = scanner.TokenEnd() - - // // The scanner is operating on a slice of the original source text, so we need to adjust the start - // // for error reporting. - // start = start + node.Pos() - - // // For providing spelling suggestions - // if message.Category() == diagnostics.CategoryMessage && lastError != nil && start == lastError.Pos() && length == lastError.Len() { - // err := ast.NewDiagnostic(sourceFile, core.NewTextRange(start, start+length), message, args) - // lastError.AddRelatedInfo(err) - // } else if !(lastError != nil) || start != lastError.Pos() { - // lastError = ast.NewDiagnostic(sourceFile, core.NewTextRange(start, start+length), message, args) - // c.diagnostics.Add(lastError) - // } - // }) - // scanner.SetText(sourceFile.Text[node.Pos():node.Loc.Len()]) - // scanner.Scan() - // if scanner.ReScanSlashToken() != ast.KindRegularExpressionLiteral { - // panic("Expected to rescan RegularExpressionLiteral") - // } - // return lastError != nil - // } - // return false } func (c *Checker) checkGrammarPrivateIdentifierExpression(privId *ast.PrivateIdentifier) bool { diff --git a/internal/checker/regexpchecks.go b/internal/checker/regexpchecks.go new file mode 100644 index 0000000000..a652452122 --- /dev/null +++ b/internal/checker/regexpchecks.go @@ -0,0 +1,42 @@ +package checker + +import ( + "github.com/microsoft/typescript-go/internal/ast" + "github.com/microsoft/typescript-go/internal/core" + "github.com/microsoft/typescript-go/internal/diagnostics" + "github.com/microsoft/typescript-go/internal/scanner" +) + +// validateRegularExpressionLiteralNode validates a regular expression literal during semantic analysis. +// This function is called from checkGrammarRegularExpressionLiteral and performs deep validation +// of the regexp pattern and flags that would affect code generation based on language version. +func (c *Checker) validateRegularExpressionLiteralNode(node *ast.RegularExpressionLiteral) { + sourceFile := ast.GetSourceFileOfNode(node.AsNode()) + // Check if the token has the Unterminated flag + if c.hasParseDiagnostics(sourceFile) || node.AsNode().LiteralLikeData().TokenFlags&ast.TokenFlagsUnterminated != 0 { + return + } + + var lastError *ast.Diagnostic + + // Create an error callback that collects diagnostics + onError := func(message *diagnostics.Message, start int, length int, args ...any) { + // Adjust start position relative to the node position in the source file (skipping leading trivia) + nodeStart := scanner.GetTokenPosOfNode(node.AsNode(), sourceFile, false) + adjustedStart := nodeStart + start + + // For providing spelling suggestions - if this is a suggestion message, + // add it as related info to the previous error + if message.Category() == diagnostics.CategoryMessage && lastError != nil && + adjustedStart == lastError.Pos() && length == lastError.Len() { + err := ast.NewDiagnostic(nil, core.NewTextRange(adjustedStart, adjustedStart+length), message, args...) + lastError.AddRelatedInfo(err) + } else if lastError == nil || adjustedStart != lastError.Pos() { + lastError = ast.NewDiagnostic(sourceFile, core.NewTextRange(adjustedStart, adjustedStart+length), message, args...) + c.diagnostics.Add(lastError) + } + } + + // Perform regexp validation + scanner.ValidateRegularExpressionLiteral(node, sourceFile, c.languageVersion, sourceFile.LanguageVariant, onError) +} diff --git a/internal/scanner/regexp.go b/internal/scanner/regexp.go new file mode 100644 index 0000000000..8e5f4d2d71 --- /dev/null +++ b/internal/scanner/regexp.go @@ -0,0 +1,1528 @@ +package scanner + +import ( + "fmt" + "strings" + "unicode/utf8" + + "github.com/microsoft/typescript-go/internal/ast" + "github.com/microsoft/typescript-go/internal/core" + "github.com/microsoft/typescript-go/internal/diagnostics" +) + +// RegExpFlags represents regexp flags (e.g., 'g', 'i', 'm', etc.) +type RegExpFlags uint32 + +const ( + RegExpFlagsNone RegExpFlags = 0 + RegExpFlagsGlobal RegExpFlags = 1 << 0 // g + RegExpFlagsIgnoreCase RegExpFlags = 1 << 1 // i + RegExpFlagsMultiline RegExpFlags = 1 << 2 // m + RegExpFlagsDotAll RegExpFlags = 1 << 3 // s + RegExpFlagsUnicode RegExpFlags = 1 << 4 // u + RegExpFlagsSticky RegExpFlags = 1 << 5 // y + RegExpFlagsHasIndices RegExpFlags = 1 << 6 // d + RegExpFlagsUnicodeSets RegExpFlags = 1 << 7 // v + RegExpFlagsModifiers RegExpFlags = RegExpFlagsIgnoreCase | RegExpFlagsMultiline | RegExpFlagsDotAll + RegExpFlagsAnyUnicodeMode RegExpFlags = RegExpFlagsUnicode | RegExpFlagsUnicodeSets +) + +var charCodeToRegExpFlag = map[rune]RegExpFlags{ + 'd': RegExpFlagsHasIndices, + 'g': RegExpFlagsGlobal, + 'i': RegExpFlagsIgnoreCase, + 'm': RegExpFlagsMultiline, + 's': RegExpFlagsDotAll, + 'u': RegExpFlagsUnicode, + 'v': RegExpFlagsUnicodeSets, + 'y': RegExpFlagsSticky, +} + +var regExpFlagToCharCode = map[RegExpFlags]rune{ + RegExpFlagsHasIndices: 'd', + RegExpFlagsGlobal: 'g', + RegExpFlagsIgnoreCase: 'i', + RegExpFlagsMultiline: 'm', + RegExpFlagsDotAll: 's', + RegExpFlagsUnicode: 'u', + RegExpFlagsUnicodeSets: 'v', + RegExpFlagsSticky: 'y', +} + +// CharacterCodeToRegularExpressionFlag converts a character code to a regexp flag +func CharacterCodeToRegularExpressionFlag(ch rune) (RegExpFlags, bool) { + flag, ok := charCodeToRegExpFlag[ch] + return flag, ok +} + +// RegularExpressionFlagToCharacterCode converts a regexp flag to a character code +func RegularExpressionFlagToCharacterCode(f RegExpFlags) (rune, bool) { + ch, ok := regExpFlagToCharCode[f] + return ch, ok +} + +// RegExpValidator is used to validate regular expressions +type RegExpValidator struct { + text string + pos int + end int + languageVersion core.ScriptTarget + languageVariant core.LanguageVariant + onError ErrorCallback + regExpFlags RegExpFlags + annexB bool + unicodeSetsMode bool + anyUnicodeMode bool + anyUnicodeModeOrNonAnnexB bool + namedCaptureGroups bool + numberOfCapturingGroups int + groupSpecifiers map[string]bool + groupNameReferences []namedReference + decimalEscapes []decimalEscape + namedCapturingGroupsScopeStack []map[string]bool + topNamedCapturingGroupsScope map[string]bool + mayContainStrings bool + isCharacterComplement bool + tokenValue string +} + +type namedReference struct { + pos int + end int + name string +} + +type decimalEscape struct { + pos int + end int + value int +} + +// ValidateRegularExpressionLiteral validates a regular expression literal node +// This is called from the checker package during semantic analysis +func ValidateRegularExpressionLiteral( + node *ast.RegularExpressionLiteral, + sourceFile *ast.SourceFile, + languageVersion core.ScriptTarget, + languageVariant core.LanguageVariant, + onError ErrorCallback, +) { + // Check if the token has the Unterminated flag + if node.AsNode().LiteralLikeData().TokenFlags&ast.TokenFlagsUnterminated != 0 { + return + } + + text := node.Text + v := &RegExpValidator{ + text: text, + pos: 1, // Skip initial '/' + end: len(text), + languageVersion: languageVersion, + languageVariant: languageVariant, + onError: onError, + } + + v.validateRegularExpression() +} + +func (v *RegExpValidator) validateRegularExpression() { + // Find the body end (before flags) + bodyEnd := v.findRegExpBodyEnd() + if bodyEnd < 0 { + return // Already unterminated + } + + // Parse flags + flagsStart := bodyEnd + 1 + v.pos = flagsStart + v.regExpFlags = RegExpFlagsNone + + for v.pos < v.end { + ch, size := v.charAndSize() + if !IsIdentifierPart(ch) { + break + } + + flag, ok := CharacterCodeToRegularExpressionFlag(ch) + if !ok { + v.error(diagnostics.Unknown_regular_expression_flag, v.pos, size) + } else if v.regExpFlags&flag != 0 { + v.error(diagnostics.Duplicate_regular_expression_flag, v.pos, size) + } else if (v.regExpFlags|flag)&RegExpFlagsAnyUnicodeMode == RegExpFlagsAnyUnicodeMode { + v.error(diagnostics.The_Unicode_u_flag_and_the_Unicode_Sets_v_flag_cannot_be_set_simultaneously, v.pos, size) + } else { + v.regExpFlags |= flag + v.checkRegularExpressionFlagAvailability(flag, size) + } + v.pos += size + } + + // Set up validation parameters + v.unicodeSetsMode = v.regExpFlags&RegExpFlagsUnicodeSets != 0 + v.anyUnicodeMode = v.regExpFlags&RegExpFlagsAnyUnicodeMode != 0 + // TypeScript always uses Annex B mode for regexp validation + v.annexB = true + v.anyUnicodeModeOrNonAnnexB = v.anyUnicodeMode || !v.annexB + + // Validate the pattern body + v.pos = 1 // Reset to start of pattern (after initial '/') + v.end = bodyEnd + v.scanDisjunction(false) + + // Post-validation checks + v.validateGroupReferences() + v.validateDecimalEscapes() +} + +func (v *RegExpValidator) findRegExpBodyEnd() int { + pos := 1 // Skip initial '/' + inEscape := false + inCharacterClass := false + + for pos < len(v.text) { + ch := v.text[pos] + if ch == '\\' && !inEscape { + inEscape = true + pos++ + continue + } + + if inEscape { + inEscape = false + pos++ + continue + } + + if ch == '/' && !inCharacterClass { + return pos + } + + if ch == '[' { + inCharacterClass = true + } else if ch == ']' { + inCharacterClass = false + } + + pos++ + } + + return -1 // Unterminated +} + +func (v *RegExpValidator) textStart() int { + return 1 // Offset from node start (which includes the '/') +} + +func (v *RegExpValidator) charAndSize() (rune, int) { + if v.pos >= v.end { + return 0, 0 + } + // Simple ASCII fast path + if ch := v.text[v.pos]; ch < 0x80 { + return rune(ch), 1 + } + // Decode multi-byte UTF-8 character + r, size := utf8.DecodeRuneInString(v.text[v.pos:]) + return r, size +} + +func (v *RegExpValidator) charAtOffset(offset int) rune { + if v.pos+offset >= v.end { + return 0 + } + // Simple ASCII fast path + if ch := v.text[v.pos+offset]; ch < 0x80 { + return rune(ch) + } + // Decode multi-byte UTF-8 character + r, _ := utf8.DecodeRuneInString(v.text[v.pos+offset:]) + return r +} + +func (v *RegExpValidator) error(message *diagnostics.Message, start, length int, args ...any) { + if v.onError != nil { + v.onError(message, start, length, args...) + } +} + +func (v *RegExpValidator) checkRegularExpressionFlagAvailability(flag RegExpFlags, size int) { + var availableFrom core.ScriptTarget + switch flag { + case RegExpFlagsHasIndices: + availableFrom = core.ScriptTargetES2022 + case RegExpFlagsDotAll: + availableFrom = core.ScriptTargetES2018 + case RegExpFlagsUnicodeSets: + availableFrom = core.ScriptTargetES2024 + default: + return + } + + if v.languageVersion < availableFrom { + // Workaround: TypeScript uses lowercase ES version names in error messages (e.g., "es2024" not "ES2024") + v.error(diagnostics.This_regular_expression_flag_is_only_available_when_targeting_0_or_later, v.pos, size, strings.ToLower(availableFrom.String())) + } +} + +func (v *RegExpValidator) scanDisjunction(isInGroup bool) { + for { + v.namedCapturingGroupsScopeStack = append(v.namedCapturingGroupsScopeStack, v.topNamedCapturingGroupsScope) + v.topNamedCapturingGroupsScope = nil + v.scanAlternative(isInGroup) + v.topNamedCapturingGroupsScope = v.namedCapturingGroupsScopeStack[len(v.namedCapturingGroupsScopeStack)-1] + v.namedCapturingGroupsScopeStack = v.namedCapturingGroupsScopeStack[:len(v.namedCapturingGroupsScopeStack)-1] + + if v.charAtOffset(0) != '|' { + return + } + v.pos++ + } +} + +func (v *RegExpValidator) scanAlternative(isInGroup bool) { + isPreviousTermQuantifiable := false + for { + start := v.pos + ch := v.charAtOffset(0) + switch ch { + case 0: + return + case '^', '$': + v.pos++ + isPreviousTermQuantifiable = false + case '\\': + v.pos++ + switch v.charAtOffset(0) { + case 'b', 'B': + v.pos++ + isPreviousTermQuantifiable = false + default: + v.scanAtomEscape() + isPreviousTermQuantifiable = true + } + case '(': + v.pos++ + if v.charAtOffset(0) == '?' { + v.pos++ + switch v.charAtOffset(0) { + case '=', '!': + v.pos++ + isPreviousTermQuantifiable = !v.anyUnicodeModeOrNonAnnexB + case '<': + groupNameStart := v.pos + v.pos++ + switch v.charAtOffset(0) { + case '=', '!': + v.pos++ + isPreviousTermQuantifiable = false + default: + v.scanGroupName(false) + v.scanExpectedChar('>') + if v.languageVersion < core.ScriptTargetES2018 { + v.error(diagnostics.Named_capturing_groups_are_only_available_when_targeting_ES2018_or_later, groupNameStart, v.pos-groupNameStart) + } + v.numberOfCapturingGroups++ + isPreviousTermQuantifiable = true + } + default: + start := v.pos + setFlags := v.scanPatternModifiers(RegExpFlagsNone) + if v.charAtOffset(0) == '-' { + v.pos++ + v.scanPatternModifiers(setFlags) + if v.pos == start+1 { + v.error(diagnostics.Subpattern_flags_must_be_present_when_there_is_a_minus_sign, start, v.pos-start) + } + } + v.scanExpectedChar(':') + isPreviousTermQuantifiable = true + } + } else { + v.numberOfCapturingGroups++ + isPreviousTermQuantifiable = true + } + v.scanDisjunction(true) + v.scanExpectedChar(')') + case '{': + v.pos++ + digitsStart := v.pos + v.scanDigits() + minVal := v.tokenValue + if !v.anyUnicodeModeOrNonAnnexB && minVal == "" { + isPreviousTermQuantifiable = true + break + } + if v.charAtOffset(0) == ',' { + v.pos++ + v.scanDigits() + maxVal := v.tokenValue + if minVal == "" { + if maxVal != "" || v.charAtOffset(0) == '}' { + v.error(diagnostics.Incomplete_quantifier_Digit_expected, digitsStart, 0) + } else { + v.error(diagnostics.Unexpected_0_Did_you_mean_to_escape_it_with_backslash, start, 1, string(ch)) + isPreviousTermQuantifiable = true + break + } + } else if maxVal != "" { + minInt := 0 + maxInt := 0 + for _, c := range minVal { + minInt = minInt*10 + int(c-'0') + } + for _, c := range maxVal { + maxInt = maxInt*10 + int(c-'0') + } + if minInt > maxInt && (v.anyUnicodeModeOrNonAnnexB || v.charAtOffset(0) == '}') { + v.error(diagnostics.Numbers_out_of_order_in_quantifier, digitsStart, v.pos-digitsStart) + } + } + } else if minVal == "" { + if v.anyUnicodeModeOrNonAnnexB { + v.error(diagnostics.Unexpected_0_Did_you_mean_to_escape_it_with_backslash, start, 1, string(ch)) + } + isPreviousTermQuantifiable = true + break + } + if v.charAtOffset(0) != '}' { + if v.anyUnicodeModeOrNonAnnexB { + v.error(diagnostics.X_0_expected, v.pos, 0, "}") + v.pos-- + } else { + isPreviousTermQuantifiable = true + break + } + } + fallthrough + case '*', '+', '?': + v.pos++ + if v.charAtOffset(0) == '?' { + v.pos++ + } + if !isPreviousTermQuantifiable { + v.error(diagnostics.There_is_nothing_available_for_repetition, start, v.pos-start) + } + isPreviousTermQuantifiable = false + case '.': + v.pos++ + isPreviousTermQuantifiable = true + case '[': + v.pos++ + if v.unicodeSetsMode { + v.scanClassSetExpression() + } else { + v.scanClassRanges() + } + v.scanExpectedChar(']') + isPreviousTermQuantifiable = true + case ')': + if isInGroup { + return + } + fallthrough + case ']', '}': + if v.anyUnicodeModeOrNonAnnexB || ch == ')' { + v.error(diagnostics.Unexpected_0_Did_you_mean_to_escape_it_with_backslash, v.pos, 1, string(ch)) + } + v.pos++ + isPreviousTermQuantifiable = true + case '/', '|': + return + default: + v.scanSourceCharacter() + isPreviousTermQuantifiable = true + } + } +} + +func (v *RegExpValidator) validateGroupReferences() { + for _, ref := range v.groupNameReferences { + if !v.groupSpecifiers[ref.name] { + v.error(diagnostics.There_is_no_capturing_group_named_0_in_this_regular_expression, ref.pos, ref.end-ref.pos, ref.name) + // Provide spelling suggestions + if len(v.groupSpecifiers) > 0 { + // Convert map keys to slice + candidates := make([]string, 0, len(v.groupSpecifiers)) + for name := range v.groupSpecifiers { + candidates = append(candidates, name) + } + suggestion := core.GetSpellingSuggestion(ref.name, candidates, core.Identity[string]) + if suggestion != "" { + v.error(diagnostics.Did_you_mean_0, ref.pos, ref.end-ref.pos, suggestion) + } + } + } + } +} + +func (v *RegExpValidator) validateDecimalEscapes() { + for _, escape := range v.decimalEscapes { + if escape.value > v.numberOfCapturingGroups { + if v.numberOfCapturingGroups > 0 { + v.error(diagnostics.This_backreference_refers_to_a_group_that_does_not_exist_There_are_only_0_capturing_groups_in_this_regular_expression, escape.pos, escape.end-escape.pos, v.numberOfCapturingGroups) + } else { + v.error(diagnostics.This_backreference_refers_to_a_group_that_does_not_exist_There_are_no_capturing_groups_in_this_regular_expression, escape.pos, escape.end-escape.pos) + } + } + } +} + +func (v *RegExpValidator) scanDigits() { + start := v.pos + for v.pos < v.end && v.charAtOffset(0) >= '0' && v.charAtOffset(0) <= '9' { + v.pos++ + } + v.tokenValue = v.text[start:v.pos] +} + +func (v *RegExpValidator) scanExpectedChar(expected rune) { + if v.charAtOffset(0) == expected { + v.pos++ + } else { + v.error(diagnostics.X_0_expected, v.pos, 0, string(expected)) + } +} + +func (v *RegExpValidator) scanPatternModifiers(currFlags RegExpFlags) RegExpFlags { + for { + ch, size := v.charAndSize() + if ch == 0 || !IsIdentifierPart(ch) { + break + } + flag, ok := CharacterCodeToRegularExpressionFlag(ch) + if !ok { + v.error(diagnostics.Unknown_regular_expression_flag, v.pos, size) + } else if currFlags&flag != 0 { + v.error(diagnostics.Duplicate_regular_expression_flag, v.pos, size) + } else if flag&RegExpFlagsModifiers == 0 { + v.error(diagnostics.This_regular_expression_flag_cannot_be_toggled_within_a_subpattern, v.pos, size) + } else { + currFlags |= flag + v.checkRegularExpressionFlagAvailability(flag, size) + } + v.pos += size + } + return currFlags +} + +func (v *RegExpValidator) scanAtomEscape() { + switch v.charAtOffset(0) { + case 'k': + v.pos++ + if v.charAtOffset(0) == '<' { + v.pos++ + v.scanGroupName(true) + v.scanExpectedChar('>') + } else if v.anyUnicodeModeOrNonAnnexB || v.namedCaptureGroups { + v.error(diagnostics.X_k_must_be_followed_by_a_capturing_group_name_enclosed_in_angle_brackets, v.pos-2, 2) + } + case 'q': + if v.unicodeSetsMode { + v.pos++ + v.error(diagnostics.X_q_is_only_available_inside_character_class, v.pos-2, 2) + break + } + fallthrough + default: + if !v.scanCharacterClassEscape() && !v.scanDecimalEscape() { + v.scanCharacterEscape(true) + } + } +} + +func (v *RegExpValidator) scanDecimalEscape() bool { + ch := v.charAtOffset(0) + if ch >= '1' && ch <= '9' { + start := v.pos + v.scanDigits() + value := 0 + for _, c := range v.tokenValue { + value = value*10 + int(c-'0') + } + v.decimalEscapes = append(v.decimalEscapes, decimalEscape{pos: start, end: v.pos, value: value}) + return true + } + return false +} + +func (v *RegExpValidator) scanCharacterClassEscape() bool { + ch := v.charAtOffset(0) + isCharacterComplement := false + switch ch { + case 'd', 'D', 's', 'S', 'w', 'W': + v.pos++ + return true + case 'P': + isCharacterComplement = true + fallthrough + case 'p': + v.pos++ + if v.charAtOffset(0) == '{' { + v.pos++ + v.scanUnicodePropertyValueExpression(isCharacterComplement) + } else { + if v.anyUnicodeModeOrNonAnnexB { + v.error(diagnostics.X_0_must_be_followed_by_a_Unicode_property_value_expression_enclosed_in_braces, v.pos-2, 2, string(ch)) + } else { + v.pos-- + } + } + return true + } + return false +} + +func (v *RegExpValidator) scanUnicodePropertyValueExpression(isCharacterComplement bool) { + // start is at the first character after '{', so start-3 points to '\' before 'p' or 'P' + start := v.pos - 3 + + propertyNameOrValueStart := v.pos + v.scanIdentifier(v.charAtOffset(0)) + propertyNameOrValue := v.tokenValue + + if v.charAtOffset(0) == '=' { + // property=value syntax + propertyNameValid := true + if v.pos == propertyNameOrValueStart { + v.error(diagnostics.Expected_a_Unicode_property_name, propertyNameOrValueStart, 0) + propertyNameValid = false + } else if !v.isValidNonBinaryUnicodePropertyName(propertyNameOrValue) { + v.error(diagnostics.Unknown_Unicode_property_name, propertyNameOrValueStart, v.pos-propertyNameOrValueStart) + // Provide spelling suggestion + candidates := make([]string, 0, len(nonBinaryUnicodePropertyNames)) + for key := range nonBinaryUnicodePropertyNames { + candidates = append(candidates, key) + } + suggestion := core.GetSpellingSuggestion(propertyNameOrValue, candidates, core.Identity[string]) + if suggestion != "" { + v.error(diagnostics.Did_you_mean_0, propertyNameOrValueStart, v.pos-propertyNameOrValueStart, suggestion) + } + propertyNameValid = false + } + v.pos++ + propertyValueStart := v.pos + v.scanIdentifier(v.charAtOffset(0)) + propertyValue := v.tokenValue + if v.pos == propertyValueStart { + v.error(diagnostics.Expected_a_Unicode_property_value, propertyValueStart, 0) + } else if propertyNameValid && !v.isValidUnicodeProperty(propertyNameOrValue, propertyValue) { + v.error(diagnostics.Unknown_Unicode_property_value, propertyValueStart, v.pos-propertyValueStart) + // Provide spelling suggestion based on the property name + canonicalName := nonBinaryUnicodePropertyNames[propertyNameOrValue] + var candidates []string + if canonicalName == "General_Category" { + candidates = make([]string, 0, len(generalCategoryValues)) + for key := range generalCategoryValues { + candidates = append(candidates, key) + } + } else if canonicalName == "Script" || canonicalName == "Script_Extensions" { + candidates = make([]string, 0, len(scriptValues)) + for key := range scriptValues { + candidates = append(candidates, key) + } + } + if len(candidates) > 0 { + suggestion := core.GetSpellingSuggestion(propertyValue, candidates, core.Identity[string]) + if suggestion != "" { + v.error(diagnostics.Did_you_mean_0, propertyValueStart, v.pos-propertyValueStart, suggestion) + } + } + } + } else { + // property name alone + if v.pos == propertyNameOrValueStart { + v.error(diagnostics.Expected_a_Unicode_property_name_or_value, propertyNameOrValueStart, 0) + } else if binaryUnicodePropertiesOfStrings[propertyNameOrValue] { + // Properties that match more than one character (strings) + if !v.unicodeSetsMode { + v.error(diagnostics.Any_Unicode_property_that_would_possibly_match_more_than_a_single_character_is_only_available_when_the_Unicode_Sets_v_flag_is_set, propertyNameOrValueStart, v.pos-propertyNameOrValueStart) + } else if isCharacterComplement { + v.error(diagnostics.Anything_that_would_possibly_match_more_than_a_single_character_is_invalid_inside_a_negated_character_class, propertyNameOrValueStart, v.pos-propertyNameOrValueStart) + } else { + v.mayContainStrings = true + } + } else if !v.isValidUnicodePropertyName(propertyNameOrValue) { + v.error(diagnostics.Unknown_Unicode_property_name_or_value, propertyNameOrValueStart, v.pos-propertyNameOrValueStart) + // Provide spelling suggestion from general category values, binary properties, and binary properties of strings + candidates := make([]string, 0, len(generalCategoryValues)+len(binaryUnicodeProperties)+len(binaryUnicodePropertiesOfStrings)) + for key := range generalCategoryValues { + candidates = append(candidates, key) + } + for key := range binaryUnicodeProperties { + candidates = append(candidates, key) + } + for key := range binaryUnicodePropertiesOfStrings { + candidates = append(candidates, key) + } + suggestion := core.GetSpellingSuggestion(propertyNameOrValue, candidates, core.Identity[string]) + if suggestion != "" { + v.error(diagnostics.Did_you_mean_0, propertyNameOrValueStart, v.pos-propertyNameOrValueStart, suggestion) + } + } + } + + // Scan the expected closing brace + v.scanExpectedChar('}') + + // Report the "only available when unicode mode" error AFTER validation + if !v.anyUnicodeMode { + v.error(diagnostics.Unicode_property_value_expressions_are_only_available_when_the_Unicode_u_flag_or_the_Unicode_Sets_v_flag_is_set, start, v.pos-start) + } +} + +// Table 67: Binary Unicode property aliases and their canonical property names +// https://tc39.es/ecma262/#table-binary-unicode-properties +var binaryUnicodeProperties = map[string]bool{ + "ASCII": true, "ASCII_Hex_Digit": true, "AHex": true, "Alphabetic": true, "Alpha": true, "Any": true, "Assigned": true, "Bidi_Control": true, "Bidi_C": true, "Bidi_Mirrored": true, "Bidi_M": true, "Case_Ignorable": true, "CI": true, "Cased": true, "Changes_When_Casefolded": true, "CWCF": true, "Changes_When_Casemapped": true, "CWCM": true, "Changes_When_Lowercased": true, "CWL": true, "Changes_When_NFKC_Casefolded": true, "CWKCF": true, "Changes_When_Titlecased": true, "CWT": true, "Changes_When_Uppercased": true, "CWU": true, "Dash": true, "Default_Ignorable_Code_Point": true, "DI": true, "Deprecated": true, "Dep": true, "Diacritic": true, "Dia": true, "Emoji": true, "Emoji_Component": true, "EComp": true, "Emoji_Modifier": true, "EMod": true, "Emoji_Modifier_Base": true, "EBase": true, "Emoji_Presentation": true, "EPres": true, "Extended_Pictographic": true, "ExtPict": true, "Extender": true, "Ext": true, "Grapheme_Base": true, "Gr_Base": true, "Grapheme_Extend": true, "Gr_Ext": true, "Hex_Digit": true, "Hex": true, "IDS_Binary_Operator": true, "IDSB": true, "IDS_Trinary_Operator": true, "IDST": true, "ID_Continue": true, "IDC": true, "ID_Start": true, "IDS": true, "Ideographic": true, "Ideo": true, "Join_Control": true, "Join_C": true, "Logical_Order_Exception": true, "LOE": true, "Lowercase": true, "Lower": true, "Math": true, "Noncharacter_Code_Point": true, "NChar": true, "Pattern_Syntax": true, "Pat_Syn": true, "Pattern_White_Space": true, "Pat_WS": true, "Quotation_Mark": true, "QMark": true, "Radical": true, "Regional_Indicator": true, "RI": true, "Sentence_Terminal": true, "STerm": true, "Soft_Dotted": true, "SD": true, "Terminal_Punctuation": true, "Term": true, "Unified_Ideograph": true, "UIdeo": true, "Uppercase": true, "Upper": true, "Variation_Selector": true, "VS": true, "White_Space": true, "space": true, "XID_Continue": true, "XIDC": true, "XID_Start": true, "XIDS": true, +} + +// Table 68: Binary Unicode properties of strings +// https://tc39.es/ecma262/#table-binary-unicode-properties-of-strings +var binaryUnicodePropertiesOfStrings = map[string]bool{ + "Basic_Emoji": true, "Emoji_Keycap_Sequence": true, "RGI_Emoji_Modifier_Sequence": true, "RGI_Emoji_Flag_Sequence": true, "RGI_Emoji_Tag_Sequence": true, "RGI_Emoji_ZWJ_Sequence": true, "RGI_Emoji": true, +} + +// Unicode 15.1 - General_Category values +var generalCategoryValues = map[string]bool{ + "C": true, "Other": true, "Cc": true, "Control": true, "cntrl": true, "Cf": true, "Format": true, "Cn": true, "Unassigned": true, "Co": true, "Private_Use": true, "Cs": true, "Surrogate": true, "L": true, "Letter": true, "LC": true, "Cased_Letter": true, "Ll": true, "Lowercase_Letter": true, "Lm": true, "Modifier_Letter": true, "Lo": true, "Other_Letter": true, "Lt": true, "Titlecase_Letter": true, "Lu": true, "Uppercase_Letter": true, "M": true, "Mark": true, "Combining_Mark": true, "Mc": true, "Spacing_Mark": true, "Me": true, "Enclosing_Mark": true, "Mn": true, "Nonspacing_Mark": true, "N": true, "Number": true, "Nd": true, "Decimal_Number": true, "digit": true, "Nl": true, "Letter_Number": true, "No": true, "Other_Number": true, "P": true, "Punctuation": true, "punct": true, "Pc": true, "Connector_Punctuation": true, "Pd": true, "Dash_Punctuation": true, "Pe": true, "Close_Punctuation": true, "Pf": true, "Final_Punctuation": true, "Pi": true, "Initial_Punctuation": true, "Po": true, "Other_Punctuation": true, "Ps": true, "Open_Punctuation": true, "S": true, "Symbol": true, "Sc": true, "Currency_Symbol": true, "Sk": true, "Modifier_Symbol": true, "Sm": true, "Math_Symbol": true, "So": true, "Other_Symbol": true, "Z": true, "Separator": true, "Zl": true, "Line_Separator": true, "Zp": true, "Paragraph_Separator": true, "Zs": true, "Space_Separator": true, +} + +// Unicode 15.1 - Script values +var scriptValues = map[string]bool{ + "Adlm": true, "Adlam": true, "Aghb": true, "Caucasian_Albanian": true, "Ahom": true, "Arab": true, "Arabic": true, "Armi": true, "Imperial_Aramaic": true, "Armn": true, "Armenian": true, "Avst": true, "Avestan": true, "Bali": true, "Balinese": true, "Bamu": true, "Bamum": true, "Bass": true, "Bassa_Vah": true, "Batk": true, "Batak": true, "Beng": true, "Bengali": true, "Bhks": true, "Bhaiksuki": true, "Bopo": true, "Bopomofo": true, "Brah": true, "Brahmi": true, "Brai": true, "Braille": true, "Bugi": true, "Buginese": true, "Buhd": true, "Buhid": true, "Cakm": true, "Chakma": true, "Cans": true, "Canadian_Aboriginal": true, "Cari": true, "Carian": true, "Cham": true, "Cher": true, "Cherokee": true, "Chrs": true, "Chorasmian": true, "Copt": true, "Coptic": true, "Qaac": true, "Cpmn": true, "Cypro_Minoan": true, "Cprt": true, "Cypriot": true, "Cyrl": true, "Cyrillic": true, "Deva": true, "Devanagari": true, "Diak": true, "Dives_Akuru": true, "Dogr": true, "Dogra": true, "Dsrt": true, "Deseret": true, "Dupl": true, "Duployan": true, "Egyp": true, "Egyptian_Hieroglyphs": true, "Elba": true, "Elbasan": true, "Elym": true, "Elymaic": true, "Ethi": true, "Ethiopic": true, "Geor": true, "Georgian": true, "Glag": true, "Glagolitic": true, "Gong": true, "Gunjala_Gondi": true, "Gonm": true, "Masaram_Gondi": true, "Goth": true, "Gothic": true, "Gran": true, "Grantha": true, "Grek": true, "Greek": true, "Gujr": true, "Gujarati": true, "Guru": true, "Gurmukhi": true, "Hang": true, "Hangul": true, "Hani": true, "Han": true, "Hano": true, "Hanunoo": true, "Hatr": true, "Hatran": true, "Hebr": true, "Hebrew": true, "Hira": true, "Hiragana": true, "Hluw": true, "Anatolian_Hieroglyphs": true, "Hmng": true, "Pahawh_Hmong": true, "Hmnp": true, "Nyiakeng_Puachue_Hmong": true, "Hrkt": true, "Katakana_Or_Hiragana": true, "Hung": true, "Old_Hungarian": true, "Ital": true, "Old_Italic": true, "Java": true, "Javanese": true, "Kali": true, "Kayah_Li": true, "Kana": true, "Katakana": true, "Kawi": true, "Khar": true, "Kharoshthi": true, "Khmr": true, "Khmer": true, "Khoj": true, "Khojki": true, "Kits": true, "Khitan_Small_Script": true, "Knda": true, "Kannada": true, "Kthi": true, "Kaithi": true, "Lana": true, "Tai_Tham": true, "Laoo": true, "Lao": true, "Latn": true, "Latin": true, "Lepc": true, "Lepcha": true, "Limb": true, "Limbu": true, "Lina": true, "Linear_A": true, "Linb": true, "Linear_B": true, "Lisu": true, "Lyci": true, "Lycian": true, "Lydi": true, "Lydian": true, "Mahj": true, "Mahajani": true, "Maka": true, "Makasar": true, "Mand": true, "Mandaic": true, "Mani": true, "Manichaean": true, "Marc": true, "Marchen": true, "Medf": true, "Medefaidrin": true, "Mend": true, "Mende_Kikakui": true, "Merc": true, "Meroitic_Cursive": true, "Mero": true, "Meroitic_Hieroglyphs": true, "Mlym": true, "Malayalam": true, "Modi": true, "Mong": true, "Mongolian": true, "Mroo": true, "Mro": true, "Mtei": true, "Meetei_Mayek": true, "Mult": true, "Multani": true, "Mymr": true, "Myanmar": true, "Nagm": true, "Nag_Mundari": true, "Nand": true, "Nandinagari": true, "Narb": true, "Old_North_Arabian": true, "Nbat": true, "Nabataean": true, "Newa": true, "Nkoo": true, "Nko": true, "Nshu": true, "Nushu": true, "Ogam": true, "Ogham": true, "Olck": true, "Ol_Chiki": true, "Orkh": true, "Old_Turkic": true, "Orya": true, "Oriya": true, "Osge": true, "Osage": true, "Osma": true, "Osmanya": true, "Ougr": true, "Old_Uyghur": true, "Palm": true, "Palmyrene": true, "Pauc": true, "Pau_Cin_Hau": true, "Perm": true, "Old_Permic": true, "Phag": true, "Phags_Pa": true, "Phli": true, "Inscriptional_Pahlavi": true, "Phlp": true, "Psalter_Pahlavi": true, "Phnx": true, "Phoenician": true, "Plrd": true, "Miao": true, "Prti": true, "Inscriptional_Parthian": true, "Rjng": true, "Rejang": true, "Rohg": true, "Hanifi_Rohingya": true, "Runr": true, "Runic": true, "Samr": true, "Samaritan": true, "Sarb": true, "Old_South_Arabian": true, "Saur": true, "Saurashtra": true, "Sgnw": true, "SignWriting": true, "Shaw": true, "Shavian": true, "Shrd": true, "Sharada": true, "Sidd": true, "Siddham": true, "Sind": true, "Khudawadi": true, "Sinh": true, "Sinhala": true, "Sogd": true, "Sogdian": true, "Sogo": true, "Old_Sogdian": true, "Sora": true, "Sora_Sompeng": true, "Soyo": true, "Soyombo": true, "Sund": true, "Sundanese": true, "Sylo": true, "Syloti_Nagri": true, "Syrc": true, "Syriac": true, "Tagb": true, "Tagbanwa": true, "Takr": true, "Takri": true, "Tale": true, "Tai_Le": true, "Talu": true, "New_Tai_Lue": true, "Taml": true, "Tamil": true, "Tang": true, "Tangut": true, "Tavt": true, "Tai_Viet": true, "Telu": true, "Telugu": true, "Tfng": true, "Tifinagh": true, "Tglg": true, "Tagalog": true, "Thaa": true, "Thaana": true, "Thai": true, "Tibt": true, "Tibetan": true, "Tirh": true, "Tirhuta": true, "Tnsa": true, "Tangsa": true, "Toto": true, "Ugar": true, "Ugaritic": true, "Vaii": true, "Vai": true, "Vith": true, "Vithkuqi": true, "Wara": true, "Warang_Citi": true, "Wcho": true, "Wancho": true, "Xpeo": true, "Old_Persian": true, "Xsux": true, "Cuneiform": true, "Yezi": true, "Yezidi": true, "Yiii": true, "Yi": true, "Zanb": true, "Zanabazar_Square": true, "Zinh": true, "Inherited": true, "Qaai": true, "Zyyy": true, "Common": true, "Zzzz": true, "Unknown": true, +} + +// Map of non-binary property names to their canonical names +var nonBinaryUnicodePropertyNames = map[string]string{ + "General_Category": "General_Category", + "gc": "General_Category", + "Script": "Script", + "sc": "Script", + "Script_Extensions": "Script_Extensions", + "scx": "Script_Extensions", +} + +func (v *RegExpValidator) isValidUnicodePropertyName(name string) bool { + return generalCategoryValues[name] || binaryUnicodeProperties[name] +} + +func (v *RegExpValidator) isValidNonBinaryUnicodePropertyName(name string) bool { + _, ok := nonBinaryUnicodePropertyNames[name] + return ok +} + +func (v *RegExpValidator) isValidUnicodeProperty(name, value string) bool { + // Get canonical name + canonicalName := nonBinaryUnicodePropertyNames[name] + if canonicalName == "General_Category" { + return generalCategoryValues[value] + } + if canonicalName == "Script" || canonicalName == "Script_Extensions" { + return scriptValues[value] + } + return false +} + +func (v *RegExpValidator) scanIdentifier(ch rune) { + start := v.pos + if ch != 0 && (IsIdentifierStart(ch) || ch == '_' || ch == '$') { + v.pos++ + for v.pos < v.end { + ch = v.charAtOffset(0) + if IsIdentifierPart(ch) || ch == '_' || ch == '$' { + v.pos++ + } else { + break + } + } + } + v.tokenValue = v.text[start:v.pos] +} + +func (v *RegExpValidator) scanCharacterEscape(atomEscape bool) string { + ch := v.charAtOffset(0) + switch ch { + case 0: + v.error(diagnostics.Undetermined_character_escape, v.pos-1, 1) + return "\\" + case 'c': + v.pos++ + ch = v.charAtOffset(0) + if isASCIILetter(ch) { + v.pos++ + return string(ch & 0x1f) + } + if v.anyUnicodeModeOrNonAnnexB { + v.error(diagnostics.X_c_must_be_followed_by_an_ASCII_letter, v.pos-2, 2) + } else if atomEscape { + v.pos-- + return "\\" + } + return string(ch) + case '^', '$', '/', '\\', '.', '*', '+', '?', '(', ')', '[', ']', '{', '}', '|': + v.pos++ + return string(ch) + default: + return v.scanEscapeSequence(atomEscape) + } +} + +func isASCIILetter(ch rune) bool { + return (ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z') +} + +func (v *RegExpValidator) scanEscapeSequence(atomEscape bool) string { + // start points to the backslash (before the escape character) + start := v.pos - 1 + ch := v.charAtOffset(0) + if ch == 0 { + v.error(diagnostics.Unexpected_end_of_text, start, 1) + return "" + } + v.pos++ + + switch ch { + case '0': + // '\0' - null character, but check if followed by digit + if v.pos >= v.end || !(v.charAtOffset(0) >= '0' && v.charAtOffset(0) <= '9') { + return "\x00" + } + // This is an octal escape starting with \0 + // falls through to handle as octal + if v.charAtOffset(0) >= '0' && v.charAtOffset(0) <= '7' { + v.pos++ + } + fallthrough + + case '1', '2', '3': + // Can be up to 3 octal digits + if v.pos < v.end && v.charAtOffset(0) >= '0' && v.charAtOffset(0) <= '7' { + v.pos++ + } + fallthrough + + case '4', '5', '6', '7': + // Can be 1 or 2 octal digits (already consumed one above for 1-3) + if v.pos < v.end && v.charAtOffset(0) >= '0' && v.charAtOffset(0) <= '7' { + v.pos++ + } + // Always report errors for octal escapes in regexp mode + code := 0 + for i := start + 1; i < v.pos; i++ { + code = code*8 + int(v.text[i]-'0') + } + hexCode := fmt.Sprintf("\\x%02x", code) + if !atomEscape && ch != '0' { + v.error(diagnostics.Octal_escape_sequences_and_backreferences_are_not_allowed_in_a_character_class_If_this_was_intended_as_an_escape_sequence_use_the_syntax_0_instead, start, v.pos-start, hexCode) + } else { + v.error(diagnostics.Octal_escape_sequences_are_not_allowed_Use_the_syntax_0, start, v.pos-start, hexCode) + } + return string(ch) + + case '8', '9': + // Invalid decimal escapes - always report in regexp mode + if !atomEscape { + v.error(diagnostics.Decimal_escape_sequences_and_backreferences_are_not_allowed_in_a_character_class, start, v.pos-start) + } else { + v.error(diagnostics.Escape_sequence_0_is_not_allowed, start, v.pos-start, v.text[start:v.pos]) + } + return string(ch) + + case 'b', 't', 'n', 'v', 'f', 'r': + // Standard escape sequences + return string(ch) + + case 'x': + // Hex escape '\xDD' + hexStart := v.pos + validHex := true + for range 2 { + if v.pos >= v.end || !isHexDigit(v.charAtOffset(0)) { + validHex = false + break + } + v.pos++ + } + if !validHex { + v.error(diagnostics.Hexadecimal_digit_expected, hexStart, v.pos-hexStart) + return v.text[start:v.pos] + } + // Parse hex value and return the character + code := 0 + for i := hexStart; i < v.pos; i++ { + digit := v.text[i] + if digit >= '0' && digit <= '9' { + code = code*16 + int(digit-'0') + } else if digit >= 'a' && digit <= 'f' { + code = code*16 + int(digit-'a'+10) + } else if digit >= 'A' && digit <= 'F' { + code = code*16 + int(digit-'A'+10) + } + } + return string(rune(code)) + + case 'u': + // Unicode escape '\uDDDD' or '\u{DDDDDD}' + if v.charAtOffset(0) == '{' { + // Extended unicode escape \u{DDDDDD} + v.pos++ + hexStart := v.pos + hasDigits := false + for v.pos < v.end && isHexDigit(v.charAtOffset(0)) { + hasDigits = true + v.pos++ + } + if !hasDigits { + v.error(diagnostics.Hexadecimal_digit_expected, hexStart, 0) + return v.text[start:v.pos] + } + if v.charAtOffset(0) == '}' { + v.pos++ + } else if hasDigits { + v.error(diagnostics.Unterminated_Unicode_escape_sequence, start, v.pos-start) + return v.text[start:v.pos] + } + if !v.anyUnicodeMode { + v.error(diagnostics.Unicode_escape_sequences_are_only_available_when_the_Unicode_u_flag_or_the_Unicode_Sets_v_flag_is_set, start, v.pos-start) + } + // Parse hex value + code := 0 + for i := hexStart; i < v.pos-1; i++ { // -1 to skip closing brace + digit := v.text[i] + if digit >= '0' && digit <= '9' { + code = code*16 + int(digit-'0') + } else if digit >= 'a' && digit <= 'f' { + code = code*16 + int(digit-'a'+10) + } else if digit >= 'A' && digit <= 'F' { + code = code*16 + int(digit-'A'+10) + } + } + return string(rune(code)) + } else { + // Standard unicode escape '\uDDDD' + hexStart := v.pos + validHex := true + for range 4 { + if v.pos >= v.end || !isHexDigit(v.charAtOffset(0)) { + validHex = false + break + } + v.pos++ + } + if !validHex { + v.error(diagnostics.Hexadecimal_digit_expected, hexStart, v.pos-hexStart) + return v.text[start:v.pos] + } + // Parse hex value + code := 0 + for i := hexStart; i < v.pos; i++ { + digit := v.text[i] + if digit >= '0' && digit <= '9' { + code = code*16 + int(digit-'0') + } else if digit >= 'a' && digit <= 'f' { + code = code*16 + int(digit-'a'+10) + } else if digit >= 'A' && digit <= 'F' { + code = code*16 + int(digit-'A'+10) + } + } + escapedValueString := string(rune(code)) + // In Unicode mode, check for surrogate pairs + if v.anyUnicodeMode && code >= 0xD800 && code <= 0xDBFF && + v.pos+6 <= v.end && v.text[v.pos:v.pos+2] == "\\u" { + // High surrogate followed by potential low surrogate + nextStart := v.pos + nextPos := v.pos + 2 + validNext := true + for range 4 { + if nextPos >= v.end || !isHexDigit(rune(v.text[nextPos])) { + validNext = false + break + } + nextPos++ + } + if validNext { + // Parse the next escape + nextCode := 0 + for i := nextStart + 2; i < nextPos; i++ { + digit := v.text[i] + if digit >= '0' && digit <= '9' { + nextCode = nextCode*16 + int(digit-'0') + } else if digit >= 'a' && digit <= 'f' { + nextCode = nextCode*16 + int(digit-'a'+10) + } else if digit >= 'A' && digit <= 'F' { + nextCode = nextCode*16 + int(digit-'A'+10) + } + } + // Check if it's a low surrogate + if nextCode >= 0xDC00 && nextCode <= 0xDFFF { + // Combine surrogates + v.pos = nextPos + return escapedValueString + string(rune(nextCode)) + } + } + } + return escapedValueString + } + + default: + // Identity escape or invalid escape + // Report error if: + // - In any Unicode mode, OR + // - In regexp mode, not Annex B, and ch is an identifier part + if v.anyUnicodeMode || (v.anyUnicodeModeOrNonAnnexB && IsIdentifierPart(ch)) { + v.error(diagnostics.This_character_cannot_be_escaped_in_a_regular_expression, start, v.pos-start) + } + return string(ch) + } +} + +func isHexDigit(ch rune) bool { + return (ch >= '0' && ch <= '9') || (ch >= 'a' && ch <= 'f') || (ch >= 'A' && ch <= 'F') +} + +// codePointAt returns the code point value at the start of the string +// If the string starts with a high surrogate followed by a low surrogate, they are combined +func codePointAt(s string) rune { + if len(s) == 0 { + return 0 + } + first, size := utf8.DecodeRuneInString(s) + // Check if it's a high surrogate (0xD800-0xDBFF) + if first >= 0xD800 && first <= 0xDBFF && len(s) > size { + second, _ := utf8.DecodeRuneInString(s[size:]) + // Check if it's a low surrogate (0xDC00-0xDFFF) + if second >= 0xDC00 && second <= 0xDFFF { + // Combine surrogates to get the code point + // CodePoint = 0x10000 + ((high & 0x3FF) << 10) | (low & 0x3FF) + return 0x10000 + ((first & 0x3FF) << 10) | (second & 0x3FF) + } + } + return first +} + +// charSize returns the number of UTF-16 code units needed to represent a code point +// This matches TypeScript's charSize function +func charSize(ch rune) int { + if ch >= 0x10000 { + // Code points >= 0x10000 require surrogate pairs in UTF-16 (2 code units) + return 2 + } + if ch == 0 { + return 0 + } + return 1 +} + +// stringCharSize returns the expected string length for a code point in our representation +// Surrogate pairs are represented as 2-rune strings, each rune encoded as UTF-8 +func stringCharSize(ch rune) int { + if ch >= 0x10000 { + // High surrogate (0xD800-0xDBFF): 3 bytes in UTF-8 + // Low surrogate (0xDC00-0xDFFF): 3 bytes in UTF-8 + // Total: 6 bytes + return 6 + } + if ch >= 0x800 { + return 3 + } + if ch >= 0x80 { + return 2 + } + if ch == 0 { + return 0 + } + return 1 +} + +func (v *RegExpValidator) scanGroupName(isReference bool) { + tokenStart := v.pos + v.scanIdentifier(v.charAtOffset(0)) + if v.pos == tokenStart { + v.error(diagnostics.Expected_a_capturing_group_name, v.pos, 0) + } else if isReference { + v.groupNameReferences = append(v.groupNameReferences, namedReference{pos: tokenStart, end: v.pos, name: v.tokenValue}) + } else { + // Check for duplicate names in scope + if v.topNamedCapturingGroupsScope != nil && v.topNamedCapturingGroupsScope[v.tokenValue] { + v.error(diagnostics.Named_capturing_groups_with_the_same_name_must_be_mutually_exclusive_to_each_other, tokenStart, v.pos-tokenStart) + } else { + for _, scope := range v.namedCapturingGroupsScopeStack { + if scope != nil && scope[v.tokenValue] { + v.error(diagnostics.Named_capturing_groups_with_the_same_name_must_be_mutually_exclusive_to_each_other, tokenStart, v.pos-tokenStart) + break + } + } + } + if v.topNamedCapturingGroupsScope == nil { + v.topNamedCapturingGroupsScope = make(map[string]bool) + } + v.topNamedCapturingGroupsScope[v.tokenValue] = true + if v.groupSpecifiers == nil { + v.groupSpecifiers = make(map[string]bool) + } + v.groupSpecifiers[v.tokenValue] = true + } +} + +func (v *RegExpValidator) scanSourceCharacter() string { + if v.anyUnicodeMode { + // In Unicode mode, consume the full character + r, s := utf8.DecodeRuneInString(v.text[v.pos:]) + if r != utf8.RuneError { + v.pos += s + return v.text[v.pos-s : v.pos] + } + v.pos++ + return v.text[v.pos-1 : v.pos] + } + // In non-Unicode mode, emulate UTF-16 behavior + // + // JavaScript strings are UTF-16, so a character like š˜ˆ (U+1D608) is stored as two 16-bit code units: + // - High surrogate: 0xD835 + // - Low surrogate: 0xDE08 + // + // When the JavaScript regex scanner processes `/[š˜ˆ-š˜”]/` in non-Unicode mode, it reads: + // 1. `[` - Start of character class + // 2. `\uD835` - High surrogate of š˜ˆ (first UTF-16 unit) + // 3. `\uDE08` - Low surrogate of š˜ˆ (second UTF-16 unit) + // 4. `-` - Hyphen (range operator) + // 5. `\uD835` - High surrogate of š˜” + // 6. `\uDE21` - Low surrogate of š˜” + // 7. `]` - End of character class + // + // So each call to scanSourceCharacter() returns a single UTF-16 code unit. + // + // In Go with UTF-8, the same string is: + // `/[<4-byte-š˜ˆ>-<4-byte-š˜”>]/` + // + // To emulate JavaScript, when we see a UTF-8 sequence for a code point >= 0x10000, + // we advance by 1 byte only and return a string representing the appropriate surrogate. + // The pendingLowSurrogate tracks when we're "inside" a multi-byte UTF-8 sequence. + + // Try to decode a full rune starting at current position + r, _ := utf8.DecodeRuneInString(v.text[v.pos:]) + + if r < 0x10000 || r == utf8.RuneError { + // Single UTF-16 code unit: ASCII, BMP character, or error + v.pos++ + if v.pos <= len(v.text) { + return string(r) + } + return "" + } + + // Multi-byte character (code point >= 0x10000) + // This would be a surrogate pair in UTF-16. + // + // Check if we're at the start of this character or in the middle. + // We do this by checking if we can decode a valid rune at our current position. + // If we're in the middle of a UTF-8 sequence, decoding would fail or give a different rune. + + // Check if we're at the start of the UTF-8 sequence + startPos := v.pos + for startPos > 0 && (v.text[startPos]&0xC0) == 0x80 { + // We're at a continuation byte, back up to find the start + startPos-- + } + + if startPos < v.pos { + // We're in the middle of a multi-byte sequence + // This means we already returned the high surrogate + // Now return the low surrogate and advance to the end of the sequence + testRune, testSize := utf8.DecodeRuneInString(v.text[startPos:]) + if testRune >= 0x10000 && testRune == r { + // Same character, return low surrogate + v.pos = startPos + testSize + low := int(0xDC00 + ((testRune - 0x10000) & 0x3FF)) + return string(rune(low)) + } + } + + // We're at the start of a multi-byte sequence + // Return high surrogate and advance by 1 byte + high := int(0xD800 + ((r - 0x10000) >> 10)) + v.pos++ + return string(rune(high)) +} + +func (v *RegExpValidator) scanClassRanges() { + isNegated := v.charAtOffset(0) == '^' + if isNegated { + v.pos++ + } + oldIsCharacterComplement := v.isCharacterComplement + v.isCharacterComplement = isNegated + defer func() { + v.isCharacterComplement = oldIsCharacterComplement + }() + for { + ch := v.charAtOffset(0) + if v.isClassContentExit(ch) { + return + } + atomStart := v.pos + atom := v.scanClassAtom() + if v.charAtOffset(0) == '-' && v.charAtOffset(1) != ']' { + v.pos++ + if v.isClassContentExit(v.charAtOffset(0)) { + return + } + // Check if min side of range is a character class escape + if atom == "" && v.anyUnicodeModeOrNonAnnexB { + v.error(diagnostics.A_character_class_range_must_not_be_bounded_by_another_character_class, atomStart, v.pos-1-atomStart) + } + rangeEndStart := v.pos + rangeEnd := v.scanClassAtom() + // Check if max side of range is a character class escape + if rangeEnd == "" && v.anyUnicodeModeOrNonAnnexB { + v.error(diagnostics.A_character_class_range_must_not_be_bounded_by_another_character_class, rangeEndStart, v.pos-rangeEndStart) + } + // Check range order + if atom != "" && rangeEnd != "" { + // Get the code point values, combining surrogate pairs if present + minCodePoint := codePointAt(atom) + maxCodePoint := codePointAt(rangeEnd) + + // Calculate the expected string size for each code point in our representation + minExpectedSize := stringCharSize(minCodePoint) + maxExpectedSize := stringCharSize(maxCodePoint) + + // Only check if both strings are complete characters (not partial) + // A character is complete if its string length matches the expected size for its code point + if len(atom) == minExpectedSize && len(rangeEnd) == maxExpectedSize && minCodePoint > maxCodePoint { + v.error(diagnostics.Range_out_of_order_in_character_class, atomStart, v.pos-atomStart) + } + } + } + } +} + +func (v *RegExpValidator) isClassContentExit(ch rune) bool { + return ch == ']' || ch == 0 || v.pos >= v.end +} + +func (v *RegExpValidator) scanClassAtom() string { + if v.charAtOffset(0) == '\\' { + v.pos++ + return v.scanClassEscape() + } + return v.scanSourceCharacter() +} + +func (v *RegExpValidator) scanClassEscape() string { + if v.scanCharacterClassEscape() { + return "" + } + return v.scanCharacterEscape(false) +} + +type classSetExpressionType int + +const ( + classSetExpressionNone classSetExpressionType = iota + classSetExpressionSubtraction + classSetExpressionIntersection +) + +func (v *RegExpValidator) scanClassSetExpression() { + isCharacterComplement := false + if v.charAtOffset(0) == '^' { + v.pos++ + isCharacterComplement = true + } + + oldIsCharacterComplement := v.isCharacterComplement + v.isCharacterComplement = isCharacterComplement + defer func() { + v.isCharacterComplement = oldIsCharacterComplement + }() + + expressionMayContainStrings := false + ch := v.charAtOffset(0) + if v.isClassContentExit(ch) { + return + } + + start := v.pos + var operand string + + // Check for operators at the start + slice := v.text[v.pos:min(v.pos+2, v.end)] + if slice == "--" || slice == "&&" { + v.error(diagnostics.Expected_a_class_set_operand, v.pos, 0) + v.mayContainStrings = false + } else { + operand = v.scanClassSetOperand() + } + + // Check what follows the first operand + switch v.charAtOffset(0) { + case '-': + if v.charAtOffset(1) == '-' { + if isCharacterComplement && v.mayContainStrings { + v.error(diagnostics.Anything_that_would_possibly_match_more_than_a_single_character_is_invalid_inside_a_negated_character_class, start, v.pos-start) + } + expressionMayContainStrings = v.mayContainStrings + v.scanClassSetSubExpression(classSetExpressionSubtraction) + v.mayContainStrings = !isCharacterComplement && expressionMayContainStrings + return + } + case '&': + if v.charAtOffset(1) == '&' { + v.scanClassSetSubExpression(classSetExpressionIntersection) + if isCharacterComplement && v.mayContainStrings { + v.error(diagnostics.Anything_that_would_possibly_match_more_than_a_single_character_is_invalid_inside_a_negated_character_class, start, v.pos-start) + } + expressionMayContainStrings = v.mayContainStrings + v.mayContainStrings = !isCharacterComplement && expressionMayContainStrings + return + } else { + v.error(diagnostics.Unexpected_0_Did_you_mean_to_escape_it_with_backslash, v.pos, 1, string(ch)) + } + default: + if isCharacterComplement && v.mayContainStrings { + v.error(diagnostics.Anything_that_would_possibly_match_more_than_a_single_character_is_invalid_inside_a_negated_character_class, start, v.pos-start) + } + expressionMayContainStrings = v.mayContainStrings + } + + // Continue scanning operands + for { + ch = v.charAtOffset(0) + if ch == 0 { + break + } + + switch ch { + case '-': + v.pos++ + ch = v.charAtOffset(0) + if v.isClassContentExit(ch) { + v.mayContainStrings = !isCharacterComplement && expressionMayContainStrings + return + } + if ch == '-' { + v.pos++ + v.error(diagnostics.Operators_must_not_be_mixed_within_a_character_class_Wrap_it_in_a_nested_class_instead, v.pos-2, 2) + start = v.pos - 2 + operand = v.text[start:v.pos] + continue + } else { + if operand == "" { + v.error(diagnostics.A_character_class_range_must_not_be_bounded_by_another_character_class, start, v.pos-1-start) + } + secondStart := v.pos + secondOperand := v.scanClassSetOperand() + // Don't report TS1518 for the second operand of a range + // expressionMayContainStrings tracking is still needed + expressionMayContainStrings = expressionMayContainStrings || v.mayContainStrings + if secondOperand == "" { + v.error(diagnostics.A_character_class_range_must_not_be_bounded_by_another_character_class, secondStart, v.pos-secondStart) + break + } + if operand == "" { + break + } + // Check range order + minRune, minSize := utf8.DecodeRuneInString(operand) + maxRune, maxSize := utf8.DecodeRuneInString(secondOperand) + if len(operand) == minSize && len(secondOperand) == maxSize && minRune > maxRune { + v.error(diagnostics.Range_out_of_order_in_character_class, start, v.pos-start) + } + } + + case '&': + start = v.pos + v.pos++ + if v.charAtOffset(0) == '&' { + v.pos++ + v.error(diagnostics.Operators_must_not_be_mixed_within_a_character_class_Wrap_it_in_a_nested_class_instead, v.pos-2, 2) + if v.charAtOffset(0) == '&' { + v.error(diagnostics.Unexpected_0_Did_you_mean_to_escape_it_with_backslash, v.pos, 1, string(ch)) + v.pos++ + } + } else { + v.error(diagnostics.Unexpected_0_Did_you_mean_to_escape_it_with_backslash, v.pos-1, 1, string(ch)) + } + operand = v.text[start:v.pos] + continue + } + + if v.isClassContentExit(v.charAtOffset(0)) { + break + } + + start = v.pos + slice = v.text[v.pos:min(v.pos+2, v.end)] + if slice == "--" || slice == "&&" { + v.error(diagnostics.Operators_must_not_be_mixed_within_a_character_class_Wrap_it_in_a_nested_class_instead, v.pos, 2) + v.pos += 2 + operand = v.text[start:v.pos] + } else { + operand = v.scanClassSetOperand() + } + } + v.mayContainStrings = !isCharacterComplement && expressionMayContainStrings +} + +func (v *RegExpValidator) scanClassSetSubExpression(expressionType classSetExpressionType) { + expressionMayContainStrings := v.mayContainStrings + for { + ch := v.charAtOffset(0) + if v.isClassContentExit(ch) { + break + } + + // Provide user-friendly diagnostic messages + switch ch { + case '-': + v.pos++ + if v.charAtOffset(0) == '-' { + v.pos++ + if expressionType != classSetExpressionSubtraction { + v.error(diagnostics.Operators_must_not_be_mixed_within_a_character_class_Wrap_it_in_a_nested_class_instead, v.pos-2, 2) + } + } else { + v.error(diagnostics.Operators_must_not_be_mixed_within_a_character_class_Wrap_it_in_a_nested_class_instead, v.pos-1, 1) + } + case '&': + v.pos++ + if v.charAtOffset(0) == '&' { + v.pos++ + if expressionType != classSetExpressionIntersection { + v.error(diagnostics.Operators_must_not_be_mixed_within_a_character_class_Wrap_it_in_a_nested_class_instead, v.pos-2, 2) + } + if v.charAtOffset(0) == '&' { + v.error(diagnostics.Unexpected_0_Did_you_mean_to_escape_it_with_backslash, v.pos, 1, string(ch)) + v.pos++ + } + } else { + v.error(diagnostics.Unexpected_0_Did_you_mean_to_escape_it_with_backslash, v.pos-1, 1, string(ch)) + } + default: + switch expressionType { + case classSetExpressionSubtraction: + v.error(diagnostics.X_0_expected, v.pos, 0, "--") + case classSetExpressionIntersection: + v.error(diagnostics.X_0_expected, v.pos, 0, "&&") + } + } + + ch = v.charAtOffset(0) + if v.isClassContentExit(ch) { + v.error(diagnostics.Expected_a_class_set_operand, v.pos, 0) + break + } + v.scanClassSetOperand() + // Used only if expressionType is Intersection + expressionMayContainStrings = expressionMayContainStrings && v.mayContainStrings + } + v.mayContainStrings = expressionMayContainStrings +} + +// ClassSetOperand ::= +// +// | '[' ClassSetExpression ']' +// | '\' CharacterClassEscape +// | '\q{' ClassStringDisjunctionContents '}' +// | ClassSetCharacter +func (v *RegExpValidator) scanClassSetOperand() string { + v.mayContainStrings = false + switch v.charAtOffset(0) { + case 0: + return "" + case '[': + v.pos++ + v.scanClassSetExpression() + v.scanExpectedChar(']') + return "" + case '\\': + v.pos++ + if v.scanCharacterClassEscape() { + return "" + } else if v.charAtOffset(0) == 'q' { + v.pos++ + if v.charAtOffset(0) == '{' { + v.pos++ + v.scanClassStringDisjunctionContents() + v.scanExpectedChar('}') + return "" + } else { + v.error(diagnostics.X_q_must_be_followed_by_string_alternatives_enclosed_in_braces, v.pos-2, 2) + return "q" + } + } + v.pos-- + // falls through + } + return v.scanClassSetCharacter() +} + +// ClassStringDisjunctionContents ::= ClassSetCharacter* ('|' ClassSetCharacter*)* +func (v *RegExpValidator) scanClassStringDisjunctionContents() { + characterCount := 0 + for { + ch := v.charAtOffset(0) + switch ch { + case 0: + return + case '}': + if characterCount != 1 { + v.mayContainStrings = true + } + return + case '|': + if characterCount != 1 { + v.mayContainStrings = true + } + v.pos++ + characterCount = 0 + default: + v.scanClassSetCharacter() + characterCount++ + } + } +} + +// ClassSetCharacter ::= +// +// | SourceCharacter -- ClassSetSyntaxCharacter -- ClassSetReservedDoublePunctuator +// | '\' (CharacterEscape | ClassSetReservedPunctuator | 'b') +func (v *RegExpValidator) scanClassSetCharacter() string { + ch := v.charAtOffset(0) + if ch == 0 { + return "" + } + + if ch == '\\' { + v.pos++ + ch = v.charAtOffset(0) + switch ch { + case 'b': + v.pos++ + return "\b" + case '&', '-', '!', '#', '%', ',', ':', ';', '<', '=', '>', '@', '`', '~': + v.pos++ + return string(ch) + default: + return v.scanCharacterEscape(false) + } + } else if ch == v.charAtOffset(1) { + // Check for reserved double punctuators + switch ch { + case '&', '!', '#', '%', '*', '+', ',', '.', ':', ';', '<', '=', '>', '?', '@', '`', '~': + v.error(diagnostics.A_character_class_must_not_contain_a_reserved_double_punctuator_Did_you_mean_to_escape_it_with_backslash, v.pos, 2) + v.pos += 2 + return v.text[v.pos-2 : v.pos] + } + } + + switch ch { + case '/', '(', ')', '[', ']', '{', '}', '-', '|': + v.error(diagnostics.Unexpected_0_Did_you_mean_to_escape_it_with_backslash, v.pos, 1, string(ch)) + v.pos++ + return string(ch) + } + + return v.scanSourceCharacter() +} diff --git a/testdata/baselines/reference/compiler/regexpTestSimple.errors.txt b/testdata/baselines/reference/compiler/regexpTestSimple.errors.txt new file mode 100644 index 0000000000..0094755150 --- /dev/null +++ b/testdata/baselines/reference/compiler/regexpTestSimple.errors.txt @@ -0,0 +1,12 @@ +regexpTestSimple.ts(2,16): error TS1499: Unknown regular expression flag. +regexpTestSimple.ts(2,18): error TS1499: Unknown regular expression flag. + + +==== regexpTestSimple.ts (2 errors) ==== + // Simple test + const x = /foo/xyz; + ~ +!!! error TS1499: Unknown regular expression flag. + ~ +!!! error TS1499: Unknown regular expression flag. + \ No newline at end of file diff --git a/testdata/baselines/reference/compiler/regexpTestSimple.js b/testdata/baselines/reference/compiler/regexpTestSimple.js new file mode 100644 index 0000000000..c855a7f9fc --- /dev/null +++ b/testdata/baselines/reference/compiler/regexpTestSimple.js @@ -0,0 +1,10 @@ +//// [tests/cases/compiler/regexpTestSimple.ts] //// + +//// [regexpTestSimple.ts] +// Simple test +const x = /foo/xyz; + + +//// [regexpTestSimple.js] +// Simple test +const x = /foo/xyz; diff --git a/testdata/baselines/reference/compiler/regexpTestSimple.symbols b/testdata/baselines/reference/compiler/regexpTestSimple.symbols new file mode 100644 index 0000000000..f1e0130855 --- /dev/null +++ b/testdata/baselines/reference/compiler/regexpTestSimple.symbols @@ -0,0 +1,7 @@ +//// [tests/cases/compiler/regexpTestSimple.ts] //// + +=== regexpTestSimple.ts === +// Simple test +const x = /foo/xyz; +>x : Symbol(x, Decl(regexpTestSimple.ts, 1, 5)) + diff --git a/testdata/baselines/reference/compiler/regexpTestSimple.types b/testdata/baselines/reference/compiler/regexpTestSimple.types new file mode 100644 index 0000000000..2167d88e90 --- /dev/null +++ b/testdata/baselines/reference/compiler/regexpTestSimple.types @@ -0,0 +1,8 @@ +//// [tests/cases/compiler/regexpTestSimple.ts] //// + +=== regexpTestSimple.ts === +// Simple test +const x = /foo/xyz; +>x : RegExp +>/foo/xyz : RegExp + diff --git a/testdata/baselines/reference/submodule/compiler/doYouNeedToChangeYourTargetLibraryES2016Plus.errors.txt b/testdata/baselines/reference/submodule/compiler/doYouNeedToChangeYourTargetLibraryES2016Plus.errors.txt index 5841b5eba3..0bc0cc1bc3 100644 --- a/testdata/baselines/reference/submodule/compiler/doYouNeedToChangeYourTargetLibraryES2016Plus.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/doYouNeedToChangeYourTargetLibraryES2016Plus.errors.txt @@ -8,7 +8,13 @@ doYouNeedToChangeYourTargetLibraryES2016Plus.ts(10,64): error TS2550: Property ' doYouNeedToChangeYourTargetLibraryES2016Plus.ts(11,21): error TS2583: Cannot find name 'Atomics'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2017' or later. doYouNeedToChangeYourTargetLibraryES2016Plus.ts(12,35): error TS2583: Cannot find name 'SharedArrayBuffer'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2017' or later. doYouNeedToChangeYourTargetLibraryES2016Plus.ts(15,50): error TS2550: Property 'finally' does not exist on type 'Promise'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2018' or later. +doYouNeedToChangeYourTargetLibraryES2016Plus.ts(16,58): error TS1503: Named capturing groups are only available when targeting 'ES2018' or later. +doYouNeedToChangeYourTargetLibraryES2016Plus.ts(16,76): error TS1503: Named capturing groups are only available when targeting 'ES2018' or later. +doYouNeedToChangeYourTargetLibraryES2016Plus.ts(16,95): error TS1503: Named capturing groups are only available when targeting 'ES2018' or later. doYouNeedToChangeYourTargetLibraryES2016Plus.ts(16,113): error TS2550: Property 'groups' does not exist on type 'RegExpMatchArray'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2018' or later. +doYouNeedToChangeYourTargetLibraryES2016Plus.ts(17,38): error TS1503: Named capturing groups are only available when targeting 'ES2018' or later. +doYouNeedToChangeYourTargetLibraryES2016Plus.ts(17,56): error TS1503: Named capturing groups are only available when targeting 'ES2018' or later. +doYouNeedToChangeYourTargetLibraryES2016Plus.ts(17,75): error TS1503: Named capturing groups are only available when targeting 'ES2018' or later. doYouNeedToChangeYourTargetLibraryES2016Plus.ts(17,111): error TS2550: Property 'groups' does not exist on type 'RegExpExecArray'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2018' or later. doYouNeedToChangeYourTargetLibraryES2016Plus.ts(18,33): error TS2550: Property 'dotAll' does not exist on type 'RegExp'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2018' or later. doYouNeedToChangeYourTargetLibraryES2016Plus.ts(19,38): error TS2550: Property 'PluralRules' does not exist on type 'typeof Intl'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2018' or later. @@ -33,7 +39,7 @@ doYouNeedToChangeYourTargetLibraryES2016Plus.ts(43,32): error TS2550: Property ' doYouNeedToChangeYourTargetLibraryES2016Plus.ts(44,33): error TS2550: Property 'replaceAll' does not exist on type '""'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2021' or later. -==== doYouNeedToChangeYourTargetLibraryES2016Plus.ts (33 errors) ==== +==== doYouNeedToChangeYourTargetLibraryES2016Plus.ts (39 errors) ==== // es2016 const testIncludes = ["hello"].includes("world"); ~~~~~~~~ @@ -70,9 +76,21 @@ doYouNeedToChangeYourTargetLibraryES2016Plus.ts(44,33): error TS2550: Property ' ~~~~~~~ !!! error TS2550: Property 'finally' does not exist on type 'Promise'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2018' or later. const testRegExpMatchArrayGroups = "2019-04-30".match(/(?[0-9]{4})-(?[0-9]{2})-(?[0-9]{2})/g).groups; + ~~~~~~ +!!! error TS1503: Named capturing groups are only available when targeting 'ES2018' or later. + ~~~~~~~ +!!! error TS1503: Named capturing groups are only available when targeting 'ES2018' or later. + ~~~~~ +!!! error TS1503: Named capturing groups are only available when targeting 'ES2018' or later. ~~~~~~ !!! error TS2550: Property 'groups' does not exist on type 'RegExpMatchArray'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2018' or later. const testRegExpExecArrayGroups = /(?[0-9]{4})-(?[0-9]{2})-(?[0-9]{2})/g.exec("2019-04-30").groups; + ~~~~~~ +!!! error TS1503: Named capturing groups are only available when targeting 'ES2018' or later. + ~~~~~~~ +!!! error TS1503: Named capturing groups are only available when targeting 'ES2018' or later. + ~~~~~ +!!! error TS1503: Named capturing groups are only available when targeting 'ES2018' or later. ~~~~~~ !!! error TS2550: Property 'groups' does not exist on type 'RegExpExecArray'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2018' or later. const testRegExpDotAll = /foo/g.dotAll; diff --git a/testdata/baselines/reference/submodule/compiler/doYouNeedToChangeYourTargetLibraryES2016Plus.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/doYouNeedToChangeYourTargetLibraryES2016Plus.errors.txt.diff deleted file mode 100644 index 4eaabe249c..0000000000 --- a/testdata/baselines/reference/submodule/compiler/doYouNeedToChangeYourTargetLibraryES2016Plus.errors.txt.diff +++ /dev/null @@ -1,47 +0,0 @@ ---- old.doYouNeedToChangeYourTargetLibraryES2016Plus.errors.txt -+++ new.doYouNeedToChangeYourTargetLibraryES2016Plus.errors.txt -@@= skipped -7, +7 lines =@@ - doYouNeedToChangeYourTargetLibraryES2016Plus.ts(11,21): error TS2583: Cannot find name 'Atomics'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2017' or later. - doYouNeedToChangeYourTargetLibraryES2016Plus.ts(12,35): error TS2583: Cannot find name 'SharedArrayBuffer'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2017' or later. - doYouNeedToChangeYourTargetLibraryES2016Plus.ts(15,50): error TS2550: Property 'finally' does not exist on type 'Promise'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2018' or later. --doYouNeedToChangeYourTargetLibraryES2016Plus.ts(16,58): error TS1503: Named capturing groups are only available when targeting 'ES2018' or later. --doYouNeedToChangeYourTargetLibraryES2016Plus.ts(16,76): error TS1503: Named capturing groups are only available when targeting 'ES2018' or later. --doYouNeedToChangeYourTargetLibraryES2016Plus.ts(16,95): error TS1503: Named capturing groups are only available when targeting 'ES2018' or later. - doYouNeedToChangeYourTargetLibraryES2016Plus.ts(16,113): error TS2550: Property 'groups' does not exist on type 'RegExpMatchArray'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2018' or later. --doYouNeedToChangeYourTargetLibraryES2016Plus.ts(17,38): error TS1503: Named capturing groups are only available when targeting 'ES2018' or later. --doYouNeedToChangeYourTargetLibraryES2016Plus.ts(17,56): error TS1503: Named capturing groups are only available when targeting 'ES2018' or later. --doYouNeedToChangeYourTargetLibraryES2016Plus.ts(17,75): error TS1503: Named capturing groups are only available when targeting 'ES2018' or later. - doYouNeedToChangeYourTargetLibraryES2016Plus.ts(17,111): error TS2550: Property 'groups' does not exist on type 'RegExpExecArray'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2018' or later. - doYouNeedToChangeYourTargetLibraryES2016Plus.ts(18,33): error TS2550: Property 'dotAll' does not exist on type 'RegExp'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2018' or later. - doYouNeedToChangeYourTargetLibraryES2016Plus.ts(19,38): error TS2550: Property 'PluralRules' does not exist on type 'typeof Intl'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2018' or later. -@@= skipped -31, +25 lines =@@ - doYouNeedToChangeYourTargetLibraryES2016Plus.ts(44,33): error TS2550: Property 'replaceAll' does not exist on type '""'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2021' or later. - - --==== doYouNeedToChangeYourTargetLibraryES2016Plus.ts (39 errors) ==== -+==== doYouNeedToChangeYourTargetLibraryES2016Plus.ts (33 errors) ==== - // es2016 - const testIncludes = ["hello"].includes("world"); - ~~~~~~~~ -@@= skipped -37, +37 lines =@@ - ~~~~~~~ - !!! error TS2550: Property 'finally' does not exist on type 'Promise'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2018' or later. - const testRegExpMatchArrayGroups = "2019-04-30".match(/(?[0-9]{4})-(?[0-9]{2})-(?[0-9]{2})/g).groups; -- ~~~~~~ --!!! error TS1503: Named capturing groups are only available when targeting 'ES2018' or later. -- ~~~~~~~ --!!! error TS1503: Named capturing groups are only available when targeting 'ES2018' or later. -- ~~~~~ --!!! error TS1503: Named capturing groups are only available when targeting 'ES2018' or later. - ~~~~~~ - !!! error TS2550: Property 'groups' does not exist on type 'RegExpMatchArray'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2018' or later. - const testRegExpExecArrayGroups = /(?[0-9]{4})-(?[0-9]{2})-(?[0-9]{2})/g.exec("2019-04-30").groups; -- ~~~~~~ --!!! error TS1503: Named capturing groups are only available when targeting 'ES2018' or later. -- ~~~~~~~ --!!! error TS1503: Named capturing groups are only available when targeting 'ES2018' or later. -- ~~~~~ --!!! error TS1503: Named capturing groups are only available when targeting 'ES2018' or later. - ~~~~~~ - !!! error TS2550: Property 'groups' does not exist on type 'RegExpExecArray'. Do you need to change your target library? Try changing the 'lib' compiler option to 'es2018' or later. - const testRegExpDotAll = /foo/g.dotAll; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/regExpWithOpenBracketInCharClass(target=es2015).errors.txt b/testdata/baselines/reference/submodule/compiler/regExpWithOpenBracketInCharClass(target=es2015).errors.txt new file mode 100644 index 0000000000..86e97bc3ed --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/regExpWithOpenBracketInCharClass(target=es2015).errors.txt @@ -0,0 +1,15 @@ +regExpWithOpenBracketInCharClass.ts(4,7): error TS1005: ']' expected. +regExpWithOpenBracketInCharClass.ts(4,8): error TS1501: This regular expression flag is only available when targeting 'es2024' or later. + + +==== regExpWithOpenBracketInCharClass.ts (2 errors) ==== + const regexes: RegExp[] = [ + /[[]/, // Valid + /[[]/u, // Valid + /[[]/v, // Well-terminated regex with an incomplete character class + +!!! error TS1005: ']' expected. + ~ +!!! error TS1501: This regular expression flag is only available when targeting 'es2024' or later. + ]; + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/regExpWithOpenBracketInCharClass(target=es2015).errors.txt.diff b/testdata/baselines/reference/submodule/compiler/regExpWithOpenBracketInCharClass(target=es2015).errors.txt.diff deleted file mode 100644 index 2b83180532..0000000000 --- a/testdata/baselines/reference/submodule/compiler/regExpWithOpenBracketInCharClass(target=es2015).errors.txt.diff +++ /dev/null @@ -1,19 +0,0 @@ ---- old.regExpWithOpenBracketInCharClass(target=es2015).errors.txt -+++ new.regExpWithOpenBracketInCharClass(target=es2015).errors.txt -@@= skipped -0, +0 lines =@@ --regExpWithOpenBracketInCharClass.ts(4,7): error TS1005: ']' expected. --regExpWithOpenBracketInCharClass.ts(4,8): error TS1501: This regular expression flag is only available when targeting 'es2024' or later. -- -- --==== regExpWithOpenBracketInCharClass.ts (2 errors) ==== -- const regexes: RegExp[] = [ -- /[[]/, // Valid -- /[[]/u, // Valid -- /[[]/v, // Well-terminated regex with an incomplete character class -- --!!! error TS1005: ']' expected. -- ~ --!!! error TS1501: This regular expression flag is only available when targeting 'es2024' or later. -- ]; -- -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/regExpWithOpenBracketInCharClass(target=es5).errors.txt b/testdata/baselines/reference/submodule/compiler/regExpWithOpenBracketInCharClass(target=es5).errors.txt new file mode 100644 index 0000000000..86e97bc3ed --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/regExpWithOpenBracketInCharClass(target=es5).errors.txt @@ -0,0 +1,15 @@ +regExpWithOpenBracketInCharClass.ts(4,7): error TS1005: ']' expected. +regExpWithOpenBracketInCharClass.ts(4,8): error TS1501: This regular expression flag is only available when targeting 'es2024' or later. + + +==== regExpWithOpenBracketInCharClass.ts (2 errors) ==== + const regexes: RegExp[] = [ + /[[]/, // Valid + /[[]/u, // Valid + /[[]/v, // Well-terminated regex with an incomplete character class + +!!! error TS1005: ']' expected. + ~ +!!! error TS1501: This regular expression flag is only available when targeting 'es2024' or later. + ]; + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/regExpWithOpenBracketInCharClass(target=es5).errors.txt.diff b/testdata/baselines/reference/submodule/compiler/regExpWithOpenBracketInCharClass(target=es5).errors.txt.diff deleted file mode 100644 index 9c16dffe26..0000000000 --- a/testdata/baselines/reference/submodule/compiler/regExpWithOpenBracketInCharClass(target=es5).errors.txt.diff +++ /dev/null @@ -1,19 +0,0 @@ ---- old.regExpWithOpenBracketInCharClass(target=es5).errors.txt -+++ new.regExpWithOpenBracketInCharClass(target=es5).errors.txt -@@= skipped -0, +0 lines =@@ --regExpWithOpenBracketInCharClass.ts(4,7): error TS1005: ']' expected. --regExpWithOpenBracketInCharClass.ts(4,8): error TS1501: This regular expression flag is only available when targeting 'es2024' or later. -- -- --==== regExpWithOpenBracketInCharClass.ts (2 errors) ==== -- const regexes: RegExp[] = [ -- /[[]/, // Valid -- /[[]/u, // Valid -- /[[]/v, // Well-terminated regex with an incomplete character class -- --!!! error TS1005: ']' expected. -- ~ --!!! error TS1501: This regular expression flag is only available when targeting 'es2024' or later. -- ]; -- -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/regExpWithOpenBracketInCharClass(target=esnext).errors.txt b/testdata/baselines/reference/submodule/compiler/regExpWithOpenBracketInCharClass(target=esnext).errors.txt new file mode 100644 index 0000000000..fb5540bc6b --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/regExpWithOpenBracketInCharClass(target=esnext).errors.txt @@ -0,0 +1,12 @@ +regExpWithOpenBracketInCharClass.ts(4,7): error TS1005: ']' expected. + + +==== regExpWithOpenBracketInCharClass.ts (1 errors) ==== + const regexes: RegExp[] = [ + /[[]/, // Valid + /[[]/u, // Valid + /[[]/v, // Well-terminated regex with an incomplete character class + +!!! error TS1005: ']' expected. + ]; + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/regExpWithOpenBracketInCharClass(target=esnext).errors.txt.diff b/testdata/baselines/reference/submodule/compiler/regExpWithOpenBracketInCharClass(target=esnext).errors.txt.diff deleted file mode 100644 index 52ebf56baa..0000000000 --- a/testdata/baselines/reference/submodule/compiler/regExpWithOpenBracketInCharClass(target=esnext).errors.txt.diff +++ /dev/null @@ -1,16 +0,0 @@ ---- old.regExpWithOpenBracketInCharClass(target=esnext).errors.txt -+++ new.regExpWithOpenBracketInCharClass(target=esnext).errors.txt -@@= skipped -0, +0 lines =@@ --regExpWithOpenBracketInCharClass.ts(4,7): error TS1005: ']' expected. -- -- --==== regExpWithOpenBracketInCharClass.ts (1 errors) ==== -- const regexes: RegExp[] = [ -- /[[]/, // Valid -- /[[]/u, // Valid -- /[[]/v, // Well-terminated regex with an incomplete character class -- --!!! error TS1005: ']' expected. -- ]; -- -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/regularExpressionAnnexB.errors.txt b/testdata/baselines/reference/submodule/compiler/regularExpressionAnnexB.errors.txt new file mode 100644 index 0000000000..f08ceaf895 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/regularExpressionAnnexB.errors.txt @@ -0,0 +1,269 @@ +regularExpressionAnnexB.ts(2,8): error TS1125: Hexadecimal digit expected. +regularExpressionAnnexB.ts(2,22): error TS1125: Hexadecimal digit expected. +regularExpressionAnnexB.ts(2,28): error TS1125: Hexadecimal digit expected. +regularExpressionAnnexB.ts(3,9): error TS1125: Hexadecimal digit expected. +regularExpressionAnnexB.ts(3,23): error TS1125: Hexadecimal digit expected. +regularExpressionAnnexB.ts(3,29): error TS1125: Hexadecimal digit expected. +regularExpressionAnnexB.ts(7,4): error TS1535: This character cannot be escaped in a regular expression. +regularExpressionAnnexB.ts(7,8): error TS1125: Hexadecimal digit expected. +regularExpressionAnnexB.ts(7,10): error TS1512: '\c' must be followed by an ASCII letter. +regularExpressionAnnexB.ts(7,12): error TS1510: '\k' must be followed by a capturing group name enclosed in angle brackets. +regularExpressionAnnexB.ts(7,14): error TS1535: This character cannot be escaped in a regular expression. +regularExpressionAnnexB.ts(7,18): error TS1535: This character cannot be escaped in a regular expression. +regularExpressionAnnexB.ts(7,22): error TS1125: Hexadecimal digit expected. +regularExpressionAnnexB.ts(7,24): error TS1535: This character cannot be escaped in a regular expression. +regularExpressionAnnexB.ts(7,28): error TS1125: Hexadecimal digit expected. +regularExpressionAnnexB.ts(7,30): error TS1531: '\p' must be followed by a Unicode property value expression enclosed in braces. +regularExpressionAnnexB.ts(8,5): error TS1535: This character cannot be escaped in a regular expression. +regularExpressionAnnexB.ts(8,9): error TS1125: Hexadecimal digit expected. +regularExpressionAnnexB.ts(8,11): error TS1512: '\c' must be followed by an ASCII letter. +regularExpressionAnnexB.ts(8,13): error TS1535: This character cannot be escaped in a regular expression. +regularExpressionAnnexB.ts(8,15): error TS1535: This character cannot be escaped in a regular expression. +regularExpressionAnnexB.ts(8,19): error TS1535: This character cannot be escaped in a regular expression. +regularExpressionAnnexB.ts(8,23): error TS1125: Hexadecimal digit expected. +regularExpressionAnnexB.ts(8,25): error TS1535: This character cannot be escaped in a regular expression. +regularExpressionAnnexB.ts(8,29): error TS1125: Hexadecimal digit expected. +regularExpressionAnnexB.ts(8,31): error TS1531: '\p' must be followed by a Unicode property value expression enclosed in braces. +regularExpressionAnnexB.ts(9,4): error TS1531: '\P' must be followed by a Unicode property value expression enclosed in braces. +regularExpressionAnnexB.ts(9,7): error TS1531: '\P' must be followed by a Unicode property value expression enclosed in braces. +regularExpressionAnnexB.ts(9,9): error TS1516: A character class range must not be bounded by another character class. +regularExpressionAnnexB.ts(23,4): error TS1507: There is nothing available for repetition. +regularExpressionAnnexB.ts(23,8): error TS1507: There is nothing available for repetition. +regularExpressionAnnexB.ts(24,4): error TS1507: There is nothing available for repetition. +regularExpressionAnnexB.ts(24,9): error TS1507: There is nothing available for repetition. +regularExpressionAnnexB.ts(25,4): error TS1507: There is nothing available for repetition. +regularExpressionAnnexB.ts(25,10): error TS1507: There is nothing available for repetition. +regularExpressionAnnexB.ts(26,4): error TS1507: There is nothing available for repetition. +regularExpressionAnnexB.ts(26,5): error TS1506: Numbers out of order in quantifier. +regularExpressionAnnexB.ts(26,10): error TS1507: There is nothing available for repetition. +regularExpressionAnnexB.ts(29,4): error TS1508: Unexpected '{'. Did you mean to escape it with backslash? +regularExpressionAnnexB.ts(30,4): error TS1508: Unexpected '{'. Did you mean to escape it with backslash? +regularExpressionAnnexB.ts(31,4): error TS1507: There is nothing available for repetition. +regularExpressionAnnexB.ts(31,5): error TS1505: Incomplete quantifier. Digit expected. +regularExpressionAnnexB.ts(31,7): error TS1005: '}' expected. +regularExpressionAnnexB.ts(31,8): error TS1507: There is nothing available for repetition. +regularExpressionAnnexB.ts(32,4): error TS1507: There is nothing available for repetition. +regularExpressionAnnexB.ts(32,6): error TS1005: '}' expected. +regularExpressionAnnexB.ts(32,7): error TS1507: There is nothing available for repetition. +regularExpressionAnnexB.ts(33,4): error TS1507: There is nothing available for repetition. +regularExpressionAnnexB.ts(33,7): error TS1005: '}' expected. +regularExpressionAnnexB.ts(33,8): error TS1507: There is nothing available for repetition. +regularExpressionAnnexB.ts(34,4): error TS1507: There is nothing available for repetition. +regularExpressionAnnexB.ts(34,8): error TS1005: '}' expected. +regularExpressionAnnexB.ts(34,9): error TS1507: There is nothing available for repetition. +regularExpressionAnnexB.ts(35,4): error TS1507: There is nothing available for repetition. +regularExpressionAnnexB.ts(35,5): error TS1506: Numbers out of order in quantifier. +regularExpressionAnnexB.ts(35,8): error TS1005: '}' expected. +regularExpressionAnnexB.ts(35,9): error TS1507: There is nothing available for repetition. +regularExpressionAnnexB.ts(36,4): error TS1508: Unexpected '{'. Did you mean to escape it with backslash? +regularExpressionAnnexB.ts(36,5): error TS1508: Unexpected '}'. Did you mean to escape it with backslash? +regularExpressionAnnexB.ts(37,4): error TS1507: There is nothing available for repetition. +regularExpressionAnnexB.ts(37,5): error TS1505: Incomplete quantifier. Digit expected. +regularExpressionAnnexB.ts(37,8): error TS1507: There is nothing available for repetition. +regularExpressionAnnexB.ts(38,4): error TS1507: There is nothing available for repetition. +regularExpressionAnnexB.ts(38,5): error TS1505: Incomplete quantifier. Digit expected. +regularExpressionAnnexB.ts(38,9): error TS1507: There is nothing available for repetition. +regularExpressionAnnexB.ts(39,4): error TS1507: There is nothing available for repetition. +regularExpressionAnnexB.ts(39,8): error TS1507: There is nothing available for repetition. +regularExpressionAnnexB.ts(40,4): error TS1507: There is nothing available for repetition. +regularExpressionAnnexB.ts(40,9): error TS1507: There is nothing available for repetition. +regularExpressionAnnexB.ts(41,4): error TS1507: There is nothing available for repetition. +regularExpressionAnnexB.ts(41,10): error TS1507: There is nothing available for repetition. +regularExpressionAnnexB.ts(42,4): error TS1507: There is nothing available for repetition. +regularExpressionAnnexB.ts(42,5): error TS1506: Numbers out of order in quantifier. +regularExpressionAnnexB.ts(42,10): error TS1507: There is nothing available for repetition. + + +==== regularExpressionAnnexB.ts (74 errors) ==== + const regexes: RegExp[] = [ + /\q\u\i\c\k\_\f\o\x\-\j\u\m\p\s/, + +!!! error TS1125: Hexadecimal digit expected. + +!!! error TS1125: Hexadecimal digit expected. + +!!! error TS1125: Hexadecimal digit expected. + /[\q\u\i\c\k\_\f\o\x\-\j\u\m\p\s]/, + +!!! error TS1125: Hexadecimal digit expected. + +!!! error TS1125: Hexadecimal digit expected. + +!!! error TS1125: Hexadecimal digit expected. + /\P[\P\w-_]/, + + // Compare to + /\q\u\i\c\k\_\f\o\x\-\j\u\m\p\s/u, + ~~ +!!! error TS1535: This character cannot be escaped in a regular expression. + +!!! error TS1125: Hexadecimal digit expected. + ~~ +!!! error TS1512: '\c' must be followed by an ASCII letter. + ~~ +!!! error TS1510: '\k' must be followed by a capturing group name enclosed in angle brackets. + ~~ +!!! error TS1535: This character cannot be escaped in a regular expression. + ~~ +!!! error TS1535: This character cannot be escaped in a regular expression. + +!!! error TS1125: Hexadecimal digit expected. + ~~ +!!! error TS1535: This character cannot be escaped in a regular expression. + +!!! error TS1125: Hexadecimal digit expected. + ~~ +!!! error TS1531: '\p' must be followed by a Unicode property value expression enclosed in braces. + /[\q\u\i\c\k\_\f\o\x\-\j\u\m\p\s]/u, + ~~ +!!! error TS1535: This character cannot be escaped in a regular expression. + +!!! error TS1125: Hexadecimal digit expected. + ~~ +!!! error TS1512: '\c' must be followed by an ASCII letter. + ~~ +!!! error TS1535: This character cannot be escaped in a regular expression. + ~~ +!!! error TS1535: This character cannot be escaped in a regular expression. + ~~ +!!! error TS1535: This character cannot be escaped in a regular expression. + +!!! error TS1125: Hexadecimal digit expected. + ~~ +!!! error TS1535: This character cannot be escaped in a regular expression. + +!!! error TS1125: Hexadecimal digit expected. + ~~ +!!! error TS1531: '\p' must be followed by a Unicode property value expression enclosed in braces. + /\P[\P\w-_]/u, + ~~ +!!! error TS1531: '\P' must be followed by a Unicode property value expression enclosed in braces. + ~~ +!!! error TS1531: '\P' must be followed by a Unicode property value expression enclosed in braces. + ~~ +!!! error TS1516: A character class range must not be bounded by another character class. + ]; + + const regexesWithBraces: RegExp[] = [ + /{??/, + /{,??/, + /{,1??/, + /{1??/, + /{1,??/, + /{1,2??/, + /{2,1??/, + /{}??/, + /{,}??/, + /{,1}??/, + /{1}??/, + ~~~~ +!!! error TS1507: There is nothing available for repetition. + ~ +!!! error TS1507: There is nothing available for repetition. + /{1,}??/, + ~~~~~ +!!! error TS1507: There is nothing available for repetition. + ~ +!!! error TS1507: There is nothing available for repetition. + /{1,2}??/, + ~~~~~~ +!!! error TS1507: There is nothing available for repetition. + ~ +!!! error TS1507: There is nothing available for repetition. + /{2,1}??/, + ~~~~~~ +!!! error TS1507: There is nothing available for repetition. + ~~~ +!!! error TS1506: Numbers out of order in quantifier. + ~ +!!! error TS1507: There is nothing available for repetition. + + // Compare to + /{??/u, + ~ +!!! error TS1508: Unexpected '{'. Did you mean to escape it with backslash? + /{,??/u, + ~ +!!! error TS1508: Unexpected '{'. Did you mean to escape it with backslash? + /{,1??/u, + ~~~~ +!!! error TS1507: There is nothing available for repetition. + +!!! error TS1505: Incomplete quantifier. Digit expected. + +!!! error TS1005: '}' expected. + ~ +!!! error TS1507: There is nothing available for repetition. + /{1??/u, + ~~~ +!!! error TS1507: There is nothing available for repetition. + +!!! error TS1005: '}' expected. + ~ +!!! error TS1507: There is nothing available for repetition. + /{1,??/u, + ~~~~ +!!! error TS1507: There is nothing available for repetition. + +!!! error TS1005: '}' expected. + ~ +!!! error TS1507: There is nothing available for repetition. + /{1,2??/u, + ~~~~~ +!!! error TS1507: There is nothing available for repetition. + +!!! error TS1005: '}' expected. + ~ +!!! error TS1507: There is nothing available for repetition. + /{2,1??/u, + ~~~~~ +!!! error TS1507: There is nothing available for repetition. + ~~~ +!!! error TS1506: Numbers out of order in quantifier. + +!!! error TS1005: '}' expected. + ~ +!!! error TS1507: There is nothing available for repetition. + /{}??/u, + ~ +!!! error TS1508: Unexpected '{'. Did you mean to escape it with backslash? + ~ +!!! error TS1508: Unexpected '}'. Did you mean to escape it with backslash? + /{,}??/u, + ~~~~ +!!! error TS1507: There is nothing available for repetition. + +!!! error TS1505: Incomplete quantifier. Digit expected. + ~ +!!! error TS1507: There is nothing available for repetition. + /{,1}??/u, + ~~~~~ +!!! error TS1507: There is nothing available for repetition. + +!!! error TS1505: Incomplete quantifier. Digit expected. + ~ +!!! error TS1507: There is nothing available for repetition. + /{1}??/u, + ~~~~ +!!! error TS1507: There is nothing available for repetition. + ~ +!!! error TS1507: There is nothing available for repetition. + /{1,}??/u, + ~~~~~ +!!! error TS1507: There is nothing available for repetition. + ~ +!!! error TS1507: There is nothing available for repetition. + /{1,2}??/u, + ~~~~~~ +!!! error TS1507: There is nothing available for repetition. + ~ +!!! error TS1507: There is nothing available for repetition. + /{2,1}??/u, + ~~~~~~ +!!! error TS1507: There is nothing available for repetition. + ~~~ +!!! error TS1506: Numbers out of order in quantifier. + ~ +!!! error TS1507: There is nothing available for repetition. + ]; + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/regularExpressionAnnexB.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/regularExpressionAnnexB.errors.txt.diff deleted file mode 100644 index fa48818b0d..0000000000 --- a/testdata/baselines/reference/submodule/compiler/regularExpressionAnnexB.errors.txt.diff +++ /dev/null @@ -1,273 +0,0 @@ ---- old.regularExpressionAnnexB.errors.txt -+++ new.regularExpressionAnnexB.errors.txt -@@= skipped -0, +0 lines =@@ --regularExpressionAnnexB.ts(2,8): error TS1125: Hexadecimal digit expected. --regularExpressionAnnexB.ts(2,22): error TS1125: Hexadecimal digit expected. --regularExpressionAnnexB.ts(2,28): error TS1125: Hexadecimal digit expected. --regularExpressionAnnexB.ts(3,9): error TS1125: Hexadecimal digit expected. --regularExpressionAnnexB.ts(3,23): error TS1125: Hexadecimal digit expected. --regularExpressionAnnexB.ts(3,29): error TS1125: Hexadecimal digit expected. --regularExpressionAnnexB.ts(7,4): error TS1535: This character cannot be escaped in a regular expression. --regularExpressionAnnexB.ts(7,8): error TS1125: Hexadecimal digit expected. --regularExpressionAnnexB.ts(7,10): error TS1512: '\c' must be followed by an ASCII letter. --regularExpressionAnnexB.ts(7,12): error TS1510: '\k' must be followed by a capturing group name enclosed in angle brackets. --regularExpressionAnnexB.ts(7,14): error TS1535: This character cannot be escaped in a regular expression. --regularExpressionAnnexB.ts(7,18): error TS1535: This character cannot be escaped in a regular expression. --regularExpressionAnnexB.ts(7,22): error TS1125: Hexadecimal digit expected. --regularExpressionAnnexB.ts(7,24): error TS1535: This character cannot be escaped in a regular expression. --regularExpressionAnnexB.ts(7,28): error TS1125: Hexadecimal digit expected. --regularExpressionAnnexB.ts(7,30): error TS1531: '\p' must be followed by a Unicode property value expression enclosed in braces. --regularExpressionAnnexB.ts(8,5): error TS1535: This character cannot be escaped in a regular expression. --regularExpressionAnnexB.ts(8,9): error TS1125: Hexadecimal digit expected. --regularExpressionAnnexB.ts(8,11): error TS1512: '\c' must be followed by an ASCII letter. --regularExpressionAnnexB.ts(8,13): error TS1535: This character cannot be escaped in a regular expression. --regularExpressionAnnexB.ts(8,15): error TS1535: This character cannot be escaped in a regular expression. --regularExpressionAnnexB.ts(8,19): error TS1535: This character cannot be escaped in a regular expression. --regularExpressionAnnexB.ts(8,23): error TS1125: Hexadecimal digit expected. --regularExpressionAnnexB.ts(8,25): error TS1535: This character cannot be escaped in a regular expression. --regularExpressionAnnexB.ts(8,29): error TS1125: Hexadecimal digit expected. --regularExpressionAnnexB.ts(8,31): error TS1531: '\p' must be followed by a Unicode property value expression enclosed in braces. --regularExpressionAnnexB.ts(9,4): error TS1531: '\P' must be followed by a Unicode property value expression enclosed in braces. --regularExpressionAnnexB.ts(9,7): error TS1531: '\P' must be followed by a Unicode property value expression enclosed in braces. --regularExpressionAnnexB.ts(9,9): error TS1516: A character class range must not be bounded by another character class. --regularExpressionAnnexB.ts(23,4): error TS1507: There is nothing available for repetition. --regularExpressionAnnexB.ts(23,8): error TS1507: There is nothing available for repetition. --regularExpressionAnnexB.ts(24,4): error TS1507: There is nothing available for repetition. --regularExpressionAnnexB.ts(24,9): error TS1507: There is nothing available for repetition. --regularExpressionAnnexB.ts(25,4): error TS1507: There is nothing available for repetition. --regularExpressionAnnexB.ts(25,10): error TS1507: There is nothing available for repetition. --regularExpressionAnnexB.ts(26,4): error TS1507: There is nothing available for repetition. --regularExpressionAnnexB.ts(26,5): error TS1506: Numbers out of order in quantifier. --regularExpressionAnnexB.ts(26,10): error TS1507: There is nothing available for repetition. --regularExpressionAnnexB.ts(29,4): error TS1508: Unexpected '{'. Did you mean to escape it with backslash? --regularExpressionAnnexB.ts(30,4): error TS1508: Unexpected '{'. Did you mean to escape it with backslash? --regularExpressionAnnexB.ts(31,4): error TS1507: There is nothing available for repetition. --regularExpressionAnnexB.ts(31,5): error TS1505: Incomplete quantifier. Digit expected. --regularExpressionAnnexB.ts(31,7): error TS1005: '}' expected. --regularExpressionAnnexB.ts(31,8): error TS1507: There is nothing available for repetition. --regularExpressionAnnexB.ts(32,4): error TS1507: There is nothing available for repetition. --regularExpressionAnnexB.ts(32,6): error TS1005: '}' expected. --regularExpressionAnnexB.ts(32,7): error TS1507: There is nothing available for repetition. --regularExpressionAnnexB.ts(33,4): error TS1507: There is nothing available for repetition. --regularExpressionAnnexB.ts(33,7): error TS1005: '}' expected. --regularExpressionAnnexB.ts(33,8): error TS1507: There is nothing available for repetition. --regularExpressionAnnexB.ts(34,4): error TS1507: There is nothing available for repetition. --regularExpressionAnnexB.ts(34,8): error TS1005: '}' expected. --regularExpressionAnnexB.ts(34,9): error TS1507: There is nothing available for repetition. --regularExpressionAnnexB.ts(35,4): error TS1507: There is nothing available for repetition. --regularExpressionAnnexB.ts(35,5): error TS1506: Numbers out of order in quantifier. --regularExpressionAnnexB.ts(35,8): error TS1005: '}' expected. --regularExpressionAnnexB.ts(35,9): error TS1507: There is nothing available for repetition. --regularExpressionAnnexB.ts(36,4): error TS1508: Unexpected '{'. Did you mean to escape it with backslash? --regularExpressionAnnexB.ts(36,5): error TS1508: Unexpected '}'. Did you mean to escape it with backslash? --regularExpressionAnnexB.ts(37,4): error TS1507: There is nothing available for repetition. --regularExpressionAnnexB.ts(37,5): error TS1505: Incomplete quantifier. Digit expected. --regularExpressionAnnexB.ts(37,8): error TS1507: There is nothing available for repetition. --regularExpressionAnnexB.ts(38,4): error TS1507: There is nothing available for repetition. --regularExpressionAnnexB.ts(38,5): error TS1505: Incomplete quantifier. Digit expected. --regularExpressionAnnexB.ts(38,9): error TS1507: There is nothing available for repetition. --regularExpressionAnnexB.ts(39,4): error TS1507: There is nothing available for repetition. --regularExpressionAnnexB.ts(39,8): error TS1507: There is nothing available for repetition. --regularExpressionAnnexB.ts(40,4): error TS1507: There is nothing available for repetition. --regularExpressionAnnexB.ts(40,9): error TS1507: There is nothing available for repetition. --regularExpressionAnnexB.ts(41,4): error TS1507: There is nothing available for repetition. --regularExpressionAnnexB.ts(41,10): error TS1507: There is nothing available for repetition. --regularExpressionAnnexB.ts(42,4): error TS1507: There is nothing available for repetition. --regularExpressionAnnexB.ts(42,5): error TS1506: Numbers out of order in quantifier. --regularExpressionAnnexB.ts(42,10): error TS1507: There is nothing available for repetition. -- -- --==== regularExpressionAnnexB.ts (74 errors) ==== -- const regexes: RegExp[] = [ -- /\q\u\i\c\k\_\f\o\x\-\j\u\m\p\s/, -- --!!! error TS1125: Hexadecimal digit expected. -- --!!! error TS1125: Hexadecimal digit expected. -- --!!! error TS1125: Hexadecimal digit expected. -- /[\q\u\i\c\k\_\f\o\x\-\j\u\m\p\s]/, -- --!!! error TS1125: Hexadecimal digit expected. -- --!!! error TS1125: Hexadecimal digit expected. -- --!!! error TS1125: Hexadecimal digit expected. -- /\P[\P\w-_]/, -- -- // Compare to -- /\q\u\i\c\k\_\f\o\x\-\j\u\m\p\s/u, -- ~~ --!!! error TS1535: This character cannot be escaped in a regular expression. -- --!!! error TS1125: Hexadecimal digit expected. -- ~~ --!!! error TS1512: '\c' must be followed by an ASCII letter. -- ~~ --!!! error TS1510: '\k' must be followed by a capturing group name enclosed in angle brackets. -- ~~ --!!! error TS1535: This character cannot be escaped in a regular expression. -- ~~ --!!! error TS1535: This character cannot be escaped in a regular expression. -- --!!! error TS1125: Hexadecimal digit expected. -- ~~ --!!! error TS1535: This character cannot be escaped in a regular expression. -- --!!! error TS1125: Hexadecimal digit expected. -- ~~ --!!! error TS1531: '\p' must be followed by a Unicode property value expression enclosed in braces. -- /[\q\u\i\c\k\_\f\o\x\-\j\u\m\p\s]/u, -- ~~ --!!! error TS1535: This character cannot be escaped in a regular expression. -- --!!! error TS1125: Hexadecimal digit expected. -- ~~ --!!! error TS1512: '\c' must be followed by an ASCII letter. -- ~~ --!!! error TS1535: This character cannot be escaped in a regular expression. -- ~~ --!!! error TS1535: This character cannot be escaped in a regular expression. -- ~~ --!!! error TS1535: This character cannot be escaped in a regular expression. -- --!!! error TS1125: Hexadecimal digit expected. -- ~~ --!!! error TS1535: This character cannot be escaped in a regular expression. -- --!!! error TS1125: Hexadecimal digit expected. -- ~~ --!!! error TS1531: '\p' must be followed by a Unicode property value expression enclosed in braces. -- /\P[\P\w-_]/u, -- ~~ --!!! error TS1531: '\P' must be followed by a Unicode property value expression enclosed in braces. -- ~~ --!!! error TS1531: '\P' must be followed by a Unicode property value expression enclosed in braces. -- ~~ --!!! error TS1516: A character class range must not be bounded by another character class. -- ]; -- -- const regexesWithBraces: RegExp[] = [ -- /{??/, -- /{,??/, -- /{,1??/, -- /{1??/, -- /{1,??/, -- /{1,2??/, -- /{2,1??/, -- /{}??/, -- /{,}??/, -- /{,1}??/, -- /{1}??/, -- ~~~~ --!!! error TS1507: There is nothing available for repetition. -- ~ --!!! error TS1507: There is nothing available for repetition. -- /{1,}??/, -- ~~~~~ --!!! error TS1507: There is nothing available for repetition. -- ~ --!!! error TS1507: There is nothing available for repetition. -- /{1,2}??/, -- ~~~~~~ --!!! error TS1507: There is nothing available for repetition. -- ~ --!!! error TS1507: There is nothing available for repetition. -- /{2,1}??/, -- ~~~~~~ --!!! error TS1507: There is nothing available for repetition. -- ~~~ --!!! error TS1506: Numbers out of order in quantifier. -- ~ --!!! error TS1507: There is nothing available for repetition. -- -- // Compare to -- /{??/u, -- ~ --!!! error TS1508: Unexpected '{'. Did you mean to escape it with backslash? -- /{,??/u, -- ~ --!!! error TS1508: Unexpected '{'. Did you mean to escape it with backslash? -- /{,1??/u, -- ~~~~ --!!! error TS1507: There is nothing available for repetition. -- --!!! error TS1505: Incomplete quantifier. Digit expected. -- --!!! error TS1005: '}' expected. -- ~ --!!! error TS1507: There is nothing available for repetition. -- /{1??/u, -- ~~~ --!!! error TS1507: There is nothing available for repetition. -- --!!! error TS1005: '}' expected. -- ~ --!!! error TS1507: There is nothing available for repetition. -- /{1,??/u, -- ~~~~ --!!! error TS1507: There is nothing available for repetition. -- --!!! error TS1005: '}' expected. -- ~ --!!! error TS1507: There is nothing available for repetition. -- /{1,2??/u, -- ~~~~~ --!!! error TS1507: There is nothing available for repetition. -- --!!! error TS1005: '}' expected. -- ~ --!!! error TS1507: There is nothing available for repetition. -- /{2,1??/u, -- ~~~~~ --!!! error TS1507: There is nothing available for repetition. -- ~~~ --!!! error TS1506: Numbers out of order in quantifier. -- --!!! error TS1005: '}' expected. -- ~ --!!! error TS1507: There is nothing available for repetition. -- /{}??/u, -- ~ --!!! error TS1508: Unexpected '{'. Did you mean to escape it with backslash? -- ~ --!!! error TS1508: Unexpected '}'. Did you mean to escape it with backslash? -- /{,}??/u, -- ~~~~ --!!! error TS1507: There is nothing available for repetition. -- --!!! error TS1505: Incomplete quantifier. Digit expected. -- ~ --!!! error TS1507: There is nothing available for repetition. -- /{,1}??/u, -- ~~~~~ --!!! error TS1507: There is nothing available for repetition. -- --!!! error TS1505: Incomplete quantifier. Digit expected. -- ~ --!!! error TS1507: There is nothing available for repetition. -- /{1}??/u, -- ~~~~ --!!! error TS1507: There is nothing available for repetition. -- ~ --!!! error TS1507: There is nothing available for repetition. -- /{1,}??/u, -- ~~~~~ --!!! error TS1507: There is nothing available for repetition. -- ~ --!!! error TS1507: There is nothing available for repetition. -- /{1,2}??/u, -- ~~~~~~ --!!! error TS1507: There is nothing available for repetition. -- ~ --!!! error TS1507: There is nothing available for repetition. -- /{2,1}??/u, -- ~~~~~~ --!!! error TS1507: There is nothing available for repetition. -- ~~~ --!!! error TS1506: Numbers out of order in quantifier. -- ~ --!!! error TS1507: There is nothing available for repetition. -- ]; -- -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/regularExpressionCharacterClassRangeOrder.errors.txt b/testdata/baselines/reference/submodule/compiler/regularExpressionCharacterClassRangeOrder.errors.txt new file mode 100644 index 0000000000..e0305b1ae0 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/regularExpressionCharacterClassRangeOrder.errors.txt @@ -0,0 +1,40 @@ +regularExpressionCharacterClassRangeOrder.ts(9,9): error TS1517: Range out of order in character class. +regularExpressionCharacterClassRangeOrder.ts(11,4): error TS1538: Unicode escape sequences are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. +regularExpressionCharacterClassRangeOrder.ts(11,14): error TS1538: Unicode escape sequences are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. +regularExpressionCharacterClassRangeOrder.ts(11,25): error TS1538: Unicode escape sequences are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. +regularExpressionCharacterClassRangeOrder.ts(11,35): error TS1538: Unicode escape sequences are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. +regularExpressionCharacterClassRangeOrder.ts(13,25): error TS1517: Range out of order in character class. + + +==== regularExpressionCharacterClassRangeOrder.ts (6 errors) ==== + // The characters in the following regular expressions are ASCII-lookalike characters found in Unicode, including: + // - š˜ˆ (U+1D608 Mathematical Sans-Serif Italic Capital A) + // - š˜” (U+1D621 Mathematical Sans-Serif Italic Capital Z) + // + // See https://en.wikipedia.org/wiki/Mathematical_Alphanumeric_Symbols + const regexes: RegExp[] = [ + /[š˜ˆ-š˜”][š˜”-š˜ˆ]/, + /[š˜ˆ-š˜”][š˜”-š˜ˆ]/u, + /[š˜ˆ-š˜”][š˜”-š˜ˆ]/v, + ~~~ +!!! error TS1517: Range out of order in character class. + + /[\u{1D608}-\u{1D621}][\u{1D621}-\u{1D608}]/, + ~~~~~~~~~ +!!! error TS1538: Unicode escape sequences are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. + ~~~~~~~~~ +!!! error TS1538: Unicode escape sequences are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. + ~~~~~~~~~ +!!! error TS1538: Unicode escape sequences are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. + ~~~~~~~~~ +!!! error TS1538: Unicode escape sequences are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. + /[\u{1D608}-\u{1D621}][\u{1D621}-\u{1D608}]/u, + /[\u{1D608}-\u{1D621}][\u{1D621}-\u{1D608}]/v, + ~~~~~~~~~~~~~~~~~~~ +!!! error TS1517: Range out of order in character class. + + /[\uD835\uDE08-\uD835\uDE21][\uD835\uDE21-\uD835\uDE08]/, + /[\uD835\uDE08-\uD835\uDE21][\uD835\uDE21-\uD835\uDE08]/u, + /[\uD835\uDE08-\uD835\uDE21][\uD835\uDE21-\uD835\uDE08]/v, + ]; + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/regularExpressionCharacterClassRangeOrder.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/regularExpressionCharacterClassRangeOrder.errors.txt.diff index 09a02fe00b..73ff1407c2 100644 --- a/testdata/baselines/reference/submodule/compiler/regularExpressionCharacterClassRangeOrder.errors.txt.diff +++ b/testdata/baselines/reference/submodule/compiler/regularExpressionCharacterClassRangeOrder.errors.txt.diff @@ -5,13 +5,14 @@ -regularExpressionCharacterClassRangeOrder.ts(7,12): error TS1517: Range out of order in character class. -regularExpressionCharacterClassRangeOrder.ts(8,11): error TS1517: Range out of order in character class. -regularExpressionCharacterClassRangeOrder.ts(9,11): error TS1517: Range out of order in character class. --regularExpressionCharacterClassRangeOrder.ts(11,4): error TS1538: Unicode escape sequences are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. --regularExpressionCharacterClassRangeOrder.ts(11,14): error TS1538: Unicode escape sequences are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. --regularExpressionCharacterClassRangeOrder.ts(11,25): error TS1538: Unicode escape sequences are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. ++regularExpressionCharacterClassRangeOrder.ts(9,9): error TS1517: Range out of order in character class. + regularExpressionCharacterClassRangeOrder.ts(11,4): error TS1538: Unicode escape sequences are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. + regularExpressionCharacterClassRangeOrder.ts(11,14): error TS1538: Unicode escape sequences are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. + regularExpressionCharacterClassRangeOrder.ts(11,25): error TS1538: Unicode escape sequences are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. -regularExpressionCharacterClassRangeOrder.ts(11,25): error TS1517: Range out of order in character class. --regularExpressionCharacterClassRangeOrder.ts(11,35): error TS1538: Unicode escape sequences are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. + regularExpressionCharacterClassRangeOrder.ts(11,35): error TS1538: Unicode escape sequences are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. -regularExpressionCharacterClassRangeOrder.ts(12,25): error TS1517: Range out of order in character class. --regularExpressionCharacterClassRangeOrder.ts(13,25): error TS1517: Range out of order in character class. + regularExpressionCharacterClassRangeOrder.ts(13,25): error TS1517: Range out of order in character class. -regularExpressionCharacterClassRangeOrder.ts(15,10): error TS1517: Range out of order in character class. -regularExpressionCharacterClassRangeOrder.ts(15,37): error TS1517: Range out of order in character class. -regularExpressionCharacterClassRangeOrder.ts(16,31): error TS1517: Range out of order in character class. @@ -19,53 +20,54 @@ - - -==== regularExpressionCharacterClassRangeOrder.ts (15 errors) ==== -- // The characters in the following regular expressions are ASCII-lookalike characters found in Unicode, including: -- // - š˜ˆ (U+1D608 Mathematical Sans-Serif Italic Capital A) -- // - š˜” (U+1D621 Mathematical Sans-Serif Italic Capital Z) -- // -- // See https://en.wikipedia.org/wiki/Mathematical_Alphanumeric_Symbols -- const regexes: RegExp[] = [ -- /[š˜ˆ-š˜”][š˜”-š˜ˆ]/, ++ ++ ++==== regularExpressionCharacterClassRangeOrder.ts (6 errors) ==== + // The characters in the following regular expressions are ASCII-lookalike characters found in Unicode, including: + // - š˜ˆ (U+1D608 Mathematical Sans-Serif Italic Capital A) + // - š˜” (U+1D621 Mathematical Sans-Serif Italic Capital Z) +@@= skipped -22, +13 lines =@@ + // See https://en.wikipedia.org/wiki/Mathematical_Alphanumeric_Symbols + const regexes: RegExp[] = [ + /[š˜ˆ-š˜”][š˜”-š˜ˆ]/, - ~~~ -!!! error TS1517: Range out of order in character class. - ~~~ -!!! error TS1517: Range out of order in character class. -- /[š˜ˆ-š˜”][š˜”-š˜ˆ]/u, + /[š˜ˆ-š˜”][š˜”-š˜ˆ]/u, - ~~~~~ -!!! error TS1517: Range out of order in character class. -- /[š˜ˆ-š˜”][š˜”-š˜ˆ]/v, + /[š˜ˆ-š˜”][š˜”-š˜ˆ]/v, - ~~~~~ --!!! error TS1517: Range out of order in character class. -- -- /[\u{1D608}-\u{1D621}][\u{1D621}-\u{1D608}]/, -- ~~~~~~~~~ --!!! error TS1538: Unicode escape sequences are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. -- ~~~~~~~~~ --!!! error TS1538: Unicode escape sequences are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. -- ~~~~~~~~~ --!!! error TS1538: Unicode escape sequences are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. -- ~~~~~~~~~~~~~~~~~~~ --!!! error TS1517: Range out of order in character class. -- ~~~~~~~~~ --!!! error TS1538: Unicode escape sequences are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. -- /[\u{1D608}-\u{1D621}][\u{1D621}-\u{1D608}]/u, ++ ~~~ + !!! error TS1517: Range out of order in character class. + + /[\u{1D608}-\u{1D621}][\u{1D621}-\u{1D608}]/, +@@= skipped -18, +12 lines =@@ + !!! error TS1538: Unicode escape sequences are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. + ~~~~~~~~~ + !!! error TS1538: Unicode escape sequences are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. - ~~~~~~~~~~~~~~~~~~~ -!!! error TS1517: Range out of order in character class. -- /[\u{1D608}-\u{1D621}][\u{1D621}-\u{1D608}]/v, + ~~~~~~~~~ + !!! error TS1538: Unicode escape sequences are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. + /[\u{1D608}-\u{1D621}][\u{1D621}-\u{1D608}]/u, - ~~~~~~~~~~~~~~~~~~~ -!!! error TS1517: Range out of order in character class. -- -- /[\uD835\uDE08-\uD835\uDE21][\uD835\uDE21-\uD835\uDE08]/, + /[\u{1D608}-\u{1D621}][\u{1D621}-\u{1D608}]/v, + ~~~~~~~~~~~~~~~~~~~ + !!! error TS1517: Range out of order in character class. + + /[\uD835\uDE08-\uD835\uDE21][\uD835\uDE21-\uD835\uDE08]/, - ~~~~~~~~~~~~~ -!!! error TS1517: Range out of order in character class. - ~~~~~~~~~~~~~ -!!! error TS1517: Range out of order in character class. -- /[\uD835\uDE08-\uD835\uDE21][\uD835\uDE21-\uD835\uDE08]/u, + /[\uD835\uDE08-\uD835\uDE21][\uD835\uDE21-\uD835\uDE08]/u, - ~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS1517: Range out of order in character class. -- /[\uD835\uDE08-\uD835\uDE21][\uD835\uDE21-\uD835\uDE08]/v, + /[\uD835\uDE08-\uD835\uDE21][\uD835\uDE21-\uD835\uDE08]/v, - ~~~~~~~~~~~~~~~~~~~~~~~~~ -!!! error TS1517: Range out of order in character class. -- ]; -- -+ \ No newline at end of file + ]; + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/regularExpressionExtendedUnicodeEscapes.errors.txt b/testdata/baselines/reference/submodule/compiler/regularExpressionExtendedUnicodeEscapes.errors.txt new file mode 100644 index 0000000000..6414010e5c --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/regularExpressionExtendedUnicodeEscapes.errors.txt @@ -0,0 +1,15 @@ +regularExpressionExtendedUnicodeEscapes.ts(2,3): error TS1538: Unicode escape sequences are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. +regularExpressionExtendedUnicodeEscapes.ts(2,13): error TS1538: Unicode escape sequences are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. + + +==== regularExpressionExtendedUnicodeEscapes.ts (2 errors) ==== + const regexes: RegExp[] = [ + /\u{10000}[\u{10000}]/, + ~~~~~~~~~ +!!! error TS1538: Unicode escape sequences are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. + ~~~~~~~~~ +!!! error TS1538: Unicode escape sequences are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. + /\u{10000}[\u{10000}]/u, + /\u{10000}[\u{10000}]/v, + ]; + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/regularExpressionExtendedUnicodeEscapes.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/regularExpressionExtendedUnicodeEscapes.errors.txt.diff deleted file mode 100644 index af46f29a92..0000000000 --- a/testdata/baselines/reference/submodule/compiler/regularExpressionExtendedUnicodeEscapes.errors.txt.diff +++ /dev/null @@ -1,19 +0,0 @@ ---- old.regularExpressionExtendedUnicodeEscapes.errors.txt -+++ new.regularExpressionExtendedUnicodeEscapes.errors.txt -@@= skipped -0, +0 lines =@@ --regularExpressionExtendedUnicodeEscapes.ts(2,3): error TS1538: Unicode escape sequences are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. --regularExpressionExtendedUnicodeEscapes.ts(2,13): error TS1538: Unicode escape sequences are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. -- -- --==== regularExpressionExtendedUnicodeEscapes.ts (2 errors) ==== -- const regexes: RegExp[] = [ -- /\u{10000}[\u{10000}]/, -- ~~~~~~~~~ --!!! error TS1538: Unicode escape sequences are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. -- ~~~~~~~~~ --!!! error TS1538: Unicode escape sequences are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. -- /\u{10000}[\u{10000}]/u, -- /\u{10000}[\u{10000}]/v, -- ]; -- -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/regularExpressionGroupNameSuggestions.errors.txt b/testdata/baselines/reference/submodule/compiler/regularExpressionGroupNameSuggestions.errors.txt new file mode 100644 index 0000000000..b900c35fe6 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/regularExpressionGroupNameSuggestions.errors.txt @@ -0,0 +1,12 @@ +regularExpressionGroupNameSuggestions.ts(1,18): error TS1503: Named capturing groups are only available when targeting 'ES2018' or later. +regularExpressionGroupNameSuggestions.ts(1,27): error TS1532: There is no capturing group named 'Foo' in this regular expression. + + +==== regularExpressionGroupNameSuggestions.ts (2 errors) ==== + const regex = /(?)\k/; + ~~~~~ +!!! error TS1503: Named capturing groups are only available when targeting 'ES2018' or later. + ~~~ +!!! error TS1532: There is no capturing group named 'Foo' in this regular expression. +!!! related TS1369: Did you mean 'foo'? + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/regularExpressionGroupNameSuggestions.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/regularExpressionGroupNameSuggestions.errors.txt.diff deleted file mode 100644 index d269c48fd1..0000000000 --- a/testdata/baselines/reference/submodule/compiler/regularExpressionGroupNameSuggestions.errors.txt.diff +++ /dev/null @@ -1,16 +0,0 @@ ---- old.regularExpressionGroupNameSuggestions.errors.txt -+++ new.regularExpressionGroupNameSuggestions.errors.txt -@@= skipped -0, +0 lines =@@ --regularExpressionGroupNameSuggestions.ts(1,18): error TS1503: Named capturing groups are only available when targeting 'ES2018' or later. --regularExpressionGroupNameSuggestions.ts(1,27): error TS1532: There is no capturing group named 'Foo' in this regular expression. -- -- --==== regularExpressionGroupNameSuggestions.ts (2 errors) ==== -- const regex = /(?)\k/; -- ~~~~~ --!!! error TS1503: Named capturing groups are only available when targeting 'ES2018' or later. -- ~~~ --!!! error TS1532: There is no capturing group named 'Foo' in this regular expression. --!!! related TS1369: Did you mean 'foo'? -- -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/regularExpressionScanning(target=es2015).errors.txt b/testdata/baselines/reference/submodule/compiler/regularExpressionScanning(target=es2015).errors.txt new file mode 100644 index 0000000000..a32fb1567c --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/regularExpressionScanning(target=es2015).errors.txt @@ -0,0 +1,709 @@ +regularExpressionScanning.ts(3,7): error TS1501: This regular expression flag is only available when targeting 'es2024' or later. +regularExpressionScanning.ts(3,9): error TS1501: This regular expression flag is only available when targeting 'es2018' or later. +regularExpressionScanning.ts(3,10): error TS1502: The Unicode (u) flag and the Unicode Sets (v) flag cannot be set simultaneously. +regularExpressionScanning.ts(3,11): error TS1499: Unknown regular expression flag. +regularExpressionScanning.ts(3,12): error TS1499: Unknown regular expression flag. +regularExpressionScanning.ts(3,13): error TS1500: Duplicate regular expression flag. +regularExpressionScanning.ts(3,14): error TS1499: Unknown regular expression flag. +regularExpressionScanning.ts(3,15): error TS1502: The Unicode (u) flag and the Unicode Sets (v) flag cannot be set simultaneously. +regularExpressionScanning.ts(3,16): error TS1501: This regular expression flag is only available when targeting 'es2022' or later. +regularExpressionScanning.ts(3,17): error TS1500: Duplicate regular expression flag. +regularExpressionScanning.ts(3,18): error TS1499: Unknown regular expression flag. +regularExpressionScanning.ts(3,19): error TS1499: Unknown regular expression flag. +regularExpressionScanning.ts(3,20): error TS1499: Unknown regular expression flag. +regularExpressionScanning.ts(3,21): error TS1500: Duplicate regular expression flag. +regularExpressionScanning.ts(3,22): error TS1499: Unknown regular expression flag. +regularExpressionScanning.ts(5,6): error TS1499: Unknown regular expression flag. +regularExpressionScanning.ts(5,7): error TS1509: This regular expression flag cannot be toggled within a subpattern. +regularExpressionScanning.ts(5,10): error TS1509: This regular expression flag cannot be toggled within a subpattern. +regularExpressionScanning.ts(5,11): error TS1500: Duplicate regular expression flag. +regularExpressionScanning.ts(8,4): error TS1534: This backreference refers to a group that does not exist. There are no capturing groups in this regular expression. +regularExpressionScanning.ts(9,4): error TS1534: This backreference refers to a group that does not exist. There are no capturing groups in this regular expression. +regularExpressionScanning.ts(12,9): error TS1533: This backreference refers to a group that does not exist. There are only 4 capturing groups in this regular expression. +regularExpressionScanning.ts(12,24): error TS1536: Octal escape sequences and backreferences are not allowed in a character class. If this was intended as an escape sequence, use the syntax '\x01' instead. +regularExpressionScanning.ts(12,26): error TS1487: Octal escape sequences are not allowed. Use the syntax '\x01'. +regularExpressionScanning.ts(12,29): error TS1536: Octal escape sequences and backreferences are not allowed in a character class. If this was intended as an escape sequence, use the syntax '\x53' instead. +regularExpressionScanning.ts(12,33): error TS1487: Octal escape sequences are not allowed. Use the syntax '\x00'. +regularExpressionScanning.ts(12,36): error TS1537: Decimal escape sequences and backreferences are not allowed in a character class. +regularExpressionScanning.ts(12,42): error TS1487: Octal escape sequences are not allowed. Use the syntax '\x03'. +regularExpressionScanning.ts(12,47): error TS1533: This backreference refers to a group that does not exist. There are only 4 capturing groups in this regular expression. +regularExpressionScanning.ts(12,48): error TS1487: Octal escape sequences are not allowed. Use the syntax '\x05'. +regularExpressionScanning.ts(12,53): error TS1533: This backreference refers to a group that does not exist. There are only 4 capturing groups in this regular expression. +regularExpressionScanning.ts(12,54): error TS1487: Octal escape sequences are not allowed. Use the syntax '\x00'. +regularExpressionScanning.ts(13,9): error TS1533: This backreference refers to a group that does not exist. There are only 4 capturing groups in this regular expression. +regularExpressionScanning.ts(13,24): error TS1536: Octal escape sequences and backreferences are not allowed in a character class. If this was intended as an escape sequence, use the syntax '\x01' instead. +regularExpressionScanning.ts(13,26): error TS1487: Octal escape sequences are not allowed. Use the syntax '\x01'. +regularExpressionScanning.ts(13,29): error TS1536: Octal escape sequences and backreferences are not allowed in a character class. If this was intended as an escape sequence, use the syntax '\x53' instead. +regularExpressionScanning.ts(13,33): error TS1487: Octal escape sequences are not allowed. Use the syntax '\x00'. +regularExpressionScanning.ts(13,36): error TS1537: Decimal escape sequences and backreferences are not allowed in a character class. +regularExpressionScanning.ts(13,42): error TS1487: Octal escape sequences are not allowed. Use the syntax '\x03'. +regularExpressionScanning.ts(13,47): error TS1533: This backreference refers to a group that does not exist. There are only 4 capturing groups in this regular expression. +regularExpressionScanning.ts(13,48): error TS1487: Octal escape sequences are not allowed. Use the syntax '\x05'. +regularExpressionScanning.ts(13,53): error TS1533: This backreference refers to a group that does not exist. There are only 4 capturing groups in this regular expression. +regularExpressionScanning.ts(13,54): error TS1487: Octal escape sequences are not allowed. Use the syntax '\x00'. +regularExpressionScanning.ts(14,5): error TS1503: Named capturing groups are only available when targeting 'ES2018' or later. +regularExpressionScanning.ts(14,14): error TS1503: Named capturing groups are only available when targeting 'ES2018' or later. +regularExpressionScanning.ts(14,29): error TS1503: Named capturing groups are only available when targeting 'ES2018' or later. +regularExpressionScanning.ts(14,45): error TS1503: Named capturing groups are only available when targeting 'ES2018' or later. +regularExpressionScanning.ts(14,57): error TS1503: Named capturing groups are only available when targeting 'ES2018' or later. +regularExpressionScanning.ts(15,15): error TS1532: There is no capturing group named 'absent' in this regular expression. +regularExpressionScanning.ts(15,24): error TS1503: Named capturing groups are only available when targeting 'ES2018' or later. +regularExpressionScanning.ts(15,36): error TS1503: Named capturing groups are only available when targeting 'ES2018' or later. +regularExpressionScanning.ts(15,45): error TS1503: Named capturing groups are only available when targeting 'ES2018' or later. +regularExpressionScanning.ts(15,58): error TS1503: Named capturing groups are only available when targeting 'ES2018' or later. +regularExpressionScanning.ts(15,59): error TS1515: Named capturing groups with the same name must be mutually exclusive to each other. +regularExpressionScanning.ts(17,31): error TS1507: There is nothing available for repetition. +regularExpressionScanning.ts(17,32): error TS1506: Numbers out of order in quantifier. +regularExpressionScanning.ts(17,40): error TS1507: There is nothing available for repetition. +regularExpressionScanning.ts(19,12): error TS1517: Range out of order in character class. +regularExpressionScanning.ts(19,15): error TS1517: Range out of order in character class. +regularExpressionScanning.ts(19,28): error TS1517: Range out of order in character class. +regularExpressionScanning.ts(20,3): error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. +regularExpressionScanning.ts(20,8): error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. +regularExpressionScanning.ts(20,16): error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. +regularExpressionScanning.ts(20,25): error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. +regularExpressionScanning.ts(20,28): error TS1529: Unknown Unicode property name or value. +regularExpressionScanning.ts(20,37): error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. +regularExpressionScanning.ts(20,42): error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. +regularExpressionScanning.ts(20,50): error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. +regularExpressionScanning.ts(20,59): error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. +regularExpressionScanning.ts(20,62): error TS1529: Unknown Unicode property name or value. +regularExpressionScanning.ts(21,28): error TS1529: Unknown Unicode property name or value. +regularExpressionScanning.ts(21,62): error TS1529: Unknown Unicode property name or value. +regularExpressionScanning.ts(22,28): error TS1529: Unknown Unicode property name or value. +regularExpressionScanning.ts(22,62): error TS1529: Unknown Unicode property name or value. +regularExpressionScanning.ts(22,72): error TS1501: This regular expression flag is only available when targeting 'es2024' or later. +regularExpressionScanning.ts(23,3): error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. +regularExpressionScanning.ts(23,6): error TS1524: Unknown Unicode property name. +regularExpressionScanning.ts(23,28): error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. +regularExpressionScanning.ts(23,31): error TS1523: Expected a Unicode property name. +regularExpressionScanning.ts(23,32): error TS1525: Expected a Unicode property value. +regularExpressionScanning.ts(23,33): error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. +regularExpressionScanning.ts(23,39): error TS1525: Expected a Unicode property value. +regularExpressionScanning.ts(23,40): error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. +regularExpressionScanning.ts(23,43): error TS1523: Expected a Unicode property name. +regularExpressionScanning.ts(23,49): error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. +regularExpressionScanning.ts(23,52): error TS1527: Expected a Unicode property name or value. +regularExpressionScanning.ts(23,59): error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. +regularExpressionScanning.ts(23,62): error TS1527: Expected a Unicode property name or value. +regularExpressionScanning.ts(23,63): error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. +regularExpressionScanning.ts(23,66): error TS1527: Expected a Unicode property name or value. +regularExpressionScanning.ts(24,6): error TS1524: Unknown Unicode property name. +regularExpressionScanning.ts(24,31): error TS1523: Expected a Unicode property name. +regularExpressionScanning.ts(24,32): error TS1525: Expected a Unicode property value. +regularExpressionScanning.ts(24,39): error TS1525: Expected a Unicode property value. +regularExpressionScanning.ts(24,43): error TS1523: Expected a Unicode property name. +regularExpressionScanning.ts(24,52): error TS1527: Expected a Unicode property name or value. +regularExpressionScanning.ts(24,53): error TS1531: '\p' must be followed by a Unicode property value expression enclosed in braces. +regularExpressionScanning.ts(24,57): error TS1531: '\P' must be followed by a Unicode property value expression enclosed in braces. +regularExpressionScanning.ts(24,62): error TS1527: Expected a Unicode property name or value. +regularExpressionScanning.ts(24,66): error TS1527: Expected a Unicode property name or value. +regularExpressionScanning.ts(25,6): error TS1524: Unknown Unicode property name. +regularExpressionScanning.ts(25,31): error TS1523: Expected a Unicode property name. +regularExpressionScanning.ts(25,32): error TS1525: Expected a Unicode property value. +regularExpressionScanning.ts(25,39): error TS1525: Expected a Unicode property value. +regularExpressionScanning.ts(25,43): error TS1523: Expected a Unicode property name. +regularExpressionScanning.ts(25,52): error TS1527: Expected a Unicode property name or value. +regularExpressionScanning.ts(25,53): error TS1531: '\p' must be followed by a Unicode property value expression enclosed in braces. +regularExpressionScanning.ts(25,57): error TS1531: '\P' must be followed by a Unicode property value expression enclosed in braces. +regularExpressionScanning.ts(25,62): error TS1527: Expected a Unicode property name or value. +regularExpressionScanning.ts(25,66): error TS1527: Expected a Unicode property name or value. +regularExpressionScanning.ts(25,67): error TS1501: This regular expression flag is only available when targeting 'es2024' or later. +regularExpressionScanning.ts(26,3): error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. +regularExpressionScanning.ts(26,6): error TS1528: Any Unicode property that would possibly match more than a single character is only available when the Unicode Sets (v) flag is set. +regularExpressionScanning.ts(26,16): error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. +regularExpressionScanning.ts(26,19): error TS1528: Any Unicode property that would possibly match more than a single character is only available when the Unicode Sets (v) flag is set. +regularExpressionScanning.ts(26,31): error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. +regularExpressionScanning.ts(26,34): error TS1528: Any Unicode property that would possibly match more than a single character is only available when the Unicode Sets (v) flag is set. +regularExpressionScanning.ts(26,44): error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. +regularExpressionScanning.ts(26,47): error TS1528: Any Unicode property that would possibly match more than a single character is only available when the Unicode Sets (v) flag is set. +regularExpressionScanning.ts(27,6): error TS1528: Any Unicode property that would possibly match more than a single character is only available when the Unicode Sets (v) flag is set. +regularExpressionScanning.ts(27,19): error TS1528: Any Unicode property that would possibly match more than a single character is only available when the Unicode Sets (v) flag is set. +regularExpressionScanning.ts(27,34): error TS1528: Any Unicode property that would possibly match more than a single character is only available when the Unicode Sets (v) flag is set. +regularExpressionScanning.ts(27,47): error TS1528: Any Unicode property that would possibly match more than a single character is only available when the Unicode Sets (v) flag is set. +regularExpressionScanning.ts(28,19): error TS1518: Anything that would possibly match more than a single character is invalid inside a negated character class. +regularExpressionScanning.ts(28,31): error TS1518: Anything that would possibly match more than a single character is invalid inside a negated character class. +regularExpressionScanning.ts(28,47): error TS1518: Anything that would possibly match more than a single character is invalid inside a negated character class. +regularExpressionScanning.ts(28,59): error TS1501: This regular expression flag is only available when targeting 'es2024' or later. +regularExpressionScanning.ts(31,3): error TS1512: '\c' must be followed by an ASCII letter. +regularExpressionScanning.ts(31,6): error TS1512: '\c' must be followed by an ASCII letter. +regularExpressionScanning.ts(31,15): error TS1512: '\c' must be followed by an ASCII letter. +regularExpressionScanning.ts(31,17): error TS1535: This character cannot be escaped in a regular expression. +regularExpressionScanning.ts(31,20): error TS1512: '\c' must be followed by an ASCII letter. +regularExpressionScanning.ts(31,23): error TS1535: This character cannot be escaped in a regular expression. +regularExpressionScanning.ts(33,3): error TS1535: This character cannot be escaped in a regular expression. +regularExpressionScanning.ts(33,7): error TS1535: This character cannot be escaped in a regular expression. +regularExpressionScanning.ts(33,10): error TS1535: This character cannot be escaped in a regular expression. +regularExpressionScanning.ts(33,14): error TS1535: This character cannot be escaped in a regular expression. +regularExpressionScanning.ts(33,17): error TS1535: This character cannot be escaped in a regular expression. +regularExpressionScanning.ts(33,21): error TS1535: This character cannot be escaped in a regular expression. +regularExpressionScanning.ts(33,24): error TS1535: This character cannot be escaped in a regular expression. +regularExpressionScanning.ts(33,39): error TS1535: This character cannot be escaped in a regular expression. +regularExpressionScanning.ts(33,41): error TS1508: Unexpected '{'. Did you mean to escape it with backslash? +regularExpressionScanning.ts(33,42): error TS1508: Unexpected ']'. Did you mean to escape it with backslash? +regularExpressionScanning.ts(33,43): error TS1535: This character cannot be escaped in a regular expression. +regularExpressionScanning.ts(33,45): error TS1508: Unexpected '{'. Did you mean to escape it with backslash? +regularExpressionScanning.ts(34,3): error TS1511: '\q' is only available inside character class. +regularExpressionScanning.ts(34,7): error TS1535: This character cannot be escaped in a regular expression. +regularExpressionScanning.ts(34,10): error TS1521: '\q' must be followed by string alternatives enclosed in braces. +regularExpressionScanning.ts(34,17): error TS1535: This character cannot be escaped in a regular expression. +regularExpressionScanning.ts(34,21): error TS1535: This character cannot be escaped in a regular expression. +regularExpressionScanning.ts(34,23): error TS1508: Unexpected '{'. Did you mean to escape it with backslash? +regularExpressionScanning.ts(34,38): error TS1508: Unexpected ']'. Did you mean to escape it with backslash? +regularExpressionScanning.ts(34,39): error TS1535: This character cannot be escaped in a regular expression. +regularExpressionScanning.ts(34,41): error TS1508: Unexpected '{'. Did you mean to escape it with backslash? +regularExpressionScanning.ts(34,42): error TS1508: Unexpected ']'. Did you mean to escape it with backslash? +regularExpressionScanning.ts(34,43): error TS1535: This character cannot be escaped in a regular expression. +regularExpressionScanning.ts(34,45): error TS1508: Unexpected '{'. Did you mean to escape it with backslash? +regularExpressionScanning.ts(34,46): error TS1005: '}' expected. +regularExpressionScanning.ts(34,47): error TS1501: This regular expression flag is only available when targeting 'es2024' or later. +regularExpressionScanning.ts(36,4): error TS1517: Range out of order in character class. +regularExpressionScanning.ts(36,8): error TS1517: Range out of order in character class. +regularExpressionScanning.ts(36,34): error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. +regularExpressionScanning.ts(36,42): error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. +regularExpressionScanning.ts(36,63): error TS1517: Range out of order in character class. +regularExpressionScanning.ts(37,4): error TS1517: Range out of order in character class. +regularExpressionScanning.ts(37,8): error TS1517: Range out of order in character class. +regularExpressionScanning.ts(37,19): error TS1508: Unexpected ']'. Did you mean to escape it with backslash? +regularExpressionScanning.ts(37,50): error TS1508: Unexpected ']'. Did you mean to escape it with backslash? +regularExpressionScanning.ts(37,51): error TS1508: Unexpected ']'. Did you mean to escape it with backslash? +regularExpressionScanning.ts(37,55): error TS1535: This character cannot be escaped in a regular expression. +regularExpressionScanning.ts(37,57): error TS1508: Unexpected '{'. Did you mean to escape it with backslash? +regularExpressionScanning.ts(37,61): error TS1508: Unexpected '}'. Did you mean to escape it with backslash? +regularExpressionScanning.ts(37,63): error TS1517: Range out of order in character class. +regularExpressionScanning.ts(37,76): error TS1535: This character cannot be escaped in a regular expression. +regularExpressionScanning.ts(38,8): error TS1005: '--' expected. +regularExpressionScanning.ts(38,9): error TS1520: Expected a class set operand. +regularExpressionScanning.ts(38,11): error TS1520: Expected a class set operand. +regularExpressionScanning.ts(38,12): error TS1005: '--' expected. +regularExpressionScanning.ts(38,15): error TS1522: A character class must not contain a reserved double punctuator. Did you mean to escape it with backslash? +regularExpressionScanning.ts(38,20): error TS1519: Operators must not be mixed within a character class. Wrap it in a nested class instead. +regularExpressionScanning.ts(38,28): error TS1519: Operators must not be mixed within a character class. Wrap it in a nested class instead. +regularExpressionScanning.ts(38,40): error TS1519: Operators must not be mixed within a character class. Wrap it in a nested class instead. +regularExpressionScanning.ts(38,47): error TS1519: Operators must not be mixed within a character class. Wrap it in a nested class instead. +regularExpressionScanning.ts(38,49): error TS1519: Operators must not be mixed within a character class. Wrap it in a nested class instead. +regularExpressionScanning.ts(38,50): error TS1520: Expected a class set operand. +regularExpressionScanning.ts(38,55): error TS1511: '\q' is only available inside character class. +regularExpressionScanning.ts(38,57): error TS1508: Unexpected '{'. Did you mean to escape it with backslash? +regularExpressionScanning.ts(38,61): error TS1508: Unexpected '}'. Did you mean to escape it with backslash? +regularExpressionScanning.ts(38,66): error TS1508: Unexpected '-'. Did you mean to escape it with backslash? +regularExpressionScanning.ts(38,67): error TS1005: '--' expected. +regularExpressionScanning.ts(38,70): error TS1520: Expected a class set operand. +regularExpressionScanning.ts(38,75): error TS1508: Unexpected '&'. Did you mean to escape it with backslash? +regularExpressionScanning.ts(38,85): error TS1520: Expected a class set operand. +regularExpressionScanning.ts(38,87): error TS1501: This regular expression flag is only available when targeting 'es2024' or later. +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,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,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,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,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. +regularExpressionScanning.ts(46,5): error TS1518: Anything that would possibly match more than a single character is invalid inside a negated character class. +regularExpressionScanning.ts(46,79): error TS1518: Anything that would possibly match more than a single character is invalid inside a negated character class. +regularExpressionScanning.ts(46,91): error TS1501: This regular expression flag is only available when targeting 'es2024' or later. +regularExpressionScanning.ts(47,5): error TS1518: Anything that would possibly match more than a single character is invalid inside a negated character class. +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(47,101): error TS1501: This regular expression flag is only available when targeting 'es2024' or later. + + +==== regularExpressionScanning.ts (219 errors) ==== + const regexes: RegExp[] = [ + // Flags + /foo/visualstudiocode, + ~ +!!! error TS1501: This regular expression flag is only available when targeting 'es2024' or later. + ~ +!!! error TS1501: This regular expression flag is only available when targeting 'es2018' or later. + ~ +!!! error TS1502: The Unicode (u) flag and the Unicode Sets (v) flag cannot be set simultaneously. + ~ +!!! error TS1499: Unknown regular expression flag. + ~ +!!! error TS1499: Unknown regular expression flag. + ~ +!!! error TS1500: Duplicate regular expression flag. + ~ +!!! error TS1499: Unknown regular expression flag. + ~ +!!! error TS1502: The Unicode (u) flag and the Unicode Sets (v) flag cannot be set simultaneously. + ~ +!!! error TS1501: This regular expression flag is only available when targeting 'es2022' or later. + ~ +!!! error TS1500: Duplicate regular expression flag. + ~ +!!! error TS1499: Unknown regular expression flag. + ~ +!!! error TS1499: Unknown regular expression flag. + ~ +!!! error TS1499: Unknown regular expression flag. + ~ +!!! error TS1500: Duplicate regular expression flag. + ~ +!!! error TS1499: Unknown regular expression flag. + // Pattern modifiers + /(?med-ium:bar)/, + ~ +!!! error TS1499: Unknown regular expression flag. + ~ +!!! error TS1509: This regular expression flag cannot be toggled within a subpattern. + ~ +!!! error TS1509: This regular expression flag cannot be toggled within a subpattern. + ~ +!!! error TS1500: Duplicate regular expression flag. + // Capturing groups + /\0/, + /\1/, + ~ +!!! error TS1534: This backreference refers to a group that does not exist. There are no capturing groups in this regular expression. + /\2/, + ~ +!!! error TS1534: This backreference refers to a group that does not exist. There are no capturing groups in this regular expression. + /(hi)\1/, + /(hi) (hello) \2/, + /\2()(\12)(foo)\1\0[\0\1\01\123\08\8](\3\03)\5\005\9\009/, + ~~ +!!! error TS1533: This backreference refers to a group that does not exist. There are only 4 capturing groups in this regular expression. + ~~ +!!! error TS1536: Octal escape sequences and backreferences are not allowed in a character class. If this was intended as an escape sequence, use the syntax '\x01' instead. + ~~~ +!!! error TS1487: Octal escape sequences are not allowed. Use the syntax '\x01'. + ~~~~ +!!! error TS1536: Octal escape sequences and backreferences are not allowed in a character class. If this was intended as an escape sequence, use the syntax '\x53' instead. + ~~ +!!! error TS1487: Octal escape sequences are not allowed. Use the syntax '\x00'. + ~~ +!!! error TS1537: Decimal escape sequences and backreferences are not allowed in a character class. + ~~~ +!!! error TS1487: Octal escape sequences are not allowed. Use the syntax '\x03'. + ~ +!!! error TS1533: This backreference refers to a group that does not exist. There are only 4 capturing groups in this regular expression. + ~~~~ +!!! error TS1487: Octal escape sequences are not allowed. Use the syntax '\x05'. + ~ +!!! error TS1533: This backreference refers to a group that does not exist. There are only 4 capturing groups in this regular expression. + ~~~ +!!! error TS1487: Octal escape sequences are not allowed. Use the syntax '\x00'. + /\2()(\12)(foo)\1\0[\0\1\01\123\08\8](\3\03)\5\005\9\009/u, + ~~ +!!! error TS1533: This backreference refers to a group that does not exist. There are only 4 capturing groups in this regular expression. + ~~ +!!! error TS1536: Octal escape sequences and backreferences are not allowed in a character class. If this was intended as an escape sequence, use the syntax '\x01' instead. + ~~~ +!!! error TS1487: Octal escape sequences are not allowed. Use the syntax '\x01'. + ~~~~ +!!! error TS1536: Octal escape sequences and backreferences are not allowed in a character class. If this was intended as an escape sequence, use the syntax '\x53' instead. + ~~ +!!! error TS1487: Octal escape sequences are not allowed. Use the syntax '\x00'. + ~~ +!!! error TS1537: Decimal escape sequences and backreferences are not allowed in a character class. + ~~~ +!!! error TS1487: Octal escape sequences are not allowed. Use the syntax '\x03'. + ~ +!!! error TS1533: This backreference refers to a group that does not exist. There are only 4 capturing groups in this regular expression. + ~~~~ +!!! error TS1487: Octal escape sequences are not allowed. Use the syntax '\x05'. + ~ +!!! error TS1533: This backreference refers to a group that does not exist. There are only 4 capturing groups in this regular expression. + ~~~ +!!! error TS1487: Octal escape sequences are not allowed. Use the syntax '\x00'. + /(?)((?bar)bar)(?baz)|(foo(?foo))(?)/, + ~~~~~ +!!! error TS1503: Named capturing groups are only available when targeting 'ES2018' or later. + ~~~~~ +!!! error TS1503: Named capturing groups are only available when targeting 'ES2018' or later. + ~~~~~ +!!! error TS1503: Named capturing groups are only available when targeting 'ES2018' or later. + ~~~~~ +!!! error TS1503: Named capturing groups are only available when targeting 'ES2018' or later. + ~~~~~ +!!! error TS1503: Named capturing groups are only available when targeting 'ES2018' or later. + /(\k)\k(?foo)|(?)((?)|(bar(?bar)))/, + ~~~~~~ +!!! error TS1532: There is no capturing group named 'absent' in this regular expression. + ~~~~~ +!!! error TS1503: Named capturing groups are only available when targeting 'ES2018' or later. + ~~~~~ +!!! error TS1503: Named capturing groups are only available when targeting 'ES2018' or later. + ~~~~~ +!!! error TS1503: Named capturing groups are only available when targeting 'ES2018' or later. + ~~~~~ +!!! error TS1503: Named capturing groups are only available when targeting 'ES2018' or later. + ~~~ +!!! error TS1515: Named capturing groups with the same name must be mutually exclusive to each other. + // Quantifiers + /{}{1,2}_{3}.{4,}?(foo){008}${32,16}\b{064,128}.+&*?\???\n{,256}{\\{,/, + ~~~~~~~ +!!! error TS1507: There is nothing available for repetition. + ~~~~~ +!!! error TS1506: Numbers out of order in quantifier. + ~~~~~~~~~ +!!! error TS1507: There is nothing available for repetition. + // Character classes + /[-A-Za-z-z-aZ-A\d_-\d-.-.\r-\n\w-\W]/, + ~~~ +!!! error TS1517: Range out of order in character class. + ~~~ +!!! error TS1517: Range out of order in character class. + ~~~~~ +!!! error TS1517: Range out of order in character class. + /\p{L}\p{gc=L}\p{ASCII}\p{Invalid}[\p{L}\p{gc=L}\P{ASCII}\p{Invalid}]/, + ~~~~~ +!!! error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. + ~~~~~~~~ +!!! error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. + ~~~~~~~~~ +!!! error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. + ~~~~~~~~~~~ +!!! error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. + ~~~~~~~ +!!! error TS1529: Unknown Unicode property name or value. + ~~~~~ +!!! error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. + ~~~~~~~~ +!!! error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. + ~~~~~~~~~ +!!! error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. + ~~~~~~~~~~~ +!!! error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. + ~~~~~~~ +!!! error TS1529: Unknown Unicode property name or value. + /\p{L}\p{gc=L}\p{ASCII}\p{Invalid}[\p{L}\p{gc=L}\P{ASCII}\p{Invalid}]/u, + ~~~~~~~ +!!! error TS1529: Unknown Unicode property name or value. + ~~~~~~~ +!!! error TS1529: Unknown Unicode property name or value. + /\p{L}\p{gc=L}\p{ASCII}\p{Invalid}[\p{L}\p{gc=L}\P{ASCII}\p{Invalid}]/v, + ~~~~~~~ +!!! error TS1529: Unknown Unicode property name or value. + ~~~~~~~ +!!! error TS1529: Unknown Unicode property name or value. + ~ +!!! error TS1501: This regular expression flag is only available when targeting 'es2024' or later. + /\p{InvalidProperty=Value}\p{=}\p{sc=}\P{=foo}[\p{}\p\\\P\P{]\p{/, + ~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. + ~~~~~~~~~~~~~~~ +!!! error TS1524: Unknown Unicode property name. + ~~~~~ +!!! error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. + +!!! error TS1523: Expected a Unicode property name. + +!!! error TS1525: Expected a Unicode property value. + ~~~~~~~ +!!! error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. + +!!! error TS1525: Expected a Unicode property value. + ~~~~~~~~ +!!! error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. + +!!! error TS1523: Expected a Unicode property name. + ~~~~ +!!! error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. + +!!! error TS1527: Expected a Unicode property name or value. + ~~~ +!!! error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. + +!!! error TS1527: Expected a Unicode property name or value. + ~~~ +!!! error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. + +!!! error TS1527: Expected a Unicode property name or value. + /\p{InvalidProperty=Value}\p{=}\p{sc=}\P{=foo}[\p{}\p\\\P\P{]\p{/u, + ~~~~~~~~~~~~~~~ +!!! error TS1524: Unknown Unicode property name. + +!!! error TS1523: Expected a Unicode property name. + +!!! error TS1525: Expected a Unicode property value. + +!!! error TS1525: Expected a Unicode property value. + +!!! error TS1523: Expected a Unicode property name. + +!!! error TS1527: Expected a Unicode property name or value. + ~~ +!!! error TS1531: '\p' must be followed by a Unicode property value expression enclosed in braces. + ~~ +!!! error TS1531: '\P' must be followed by a Unicode property value expression enclosed in braces. + +!!! error TS1527: Expected a Unicode property name or value. + +!!! error TS1527: Expected a Unicode property name or value. + /\p{InvalidProperty=Value}\p{=}\p{sc=}\P{=foo}[\p{}\p\\\P\P{]\p{/v, + ~~~~~~~~~~~~~~~ +!!! error TS1524: Unknown Unicode property name. + +!!! error TS1523: Expected a Unicode property name. + +!!! error TS1525: Expected a Unicode property value. + +!!! error TS1525: Expected a Unicode property value. + +!!! error TS1523: Expected a Unicode property name. + +!!! error TS1527: Expected a Unicode property name or value. + ~~ +!!! error TS1531: '\p' must be followed by a Unicode property value expression enclosed in braces. + ~~ +!!! error TS1531: '\P' must be followed by a Unicode property value expression enclosed in braces. + +!!! error TS1527: Expected a Unicode property name or value. + +!!! error TS1527: Expected a Unicode property name or value. + ~ +!!! error TS1501: This regular expression flag is only available when targeting 'es2024' or later. + /\p{RGI_Emoji}\P{RGI_Emoji}[^\p{RGI_Emoji}\P{RGI_Emoji}]/, + ~~~~~~~~~~~~~ +!!! error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. + ~~~~~~~~~ +!!! error TS1528: Any Unicode property that would possibly match more than a single character is only available when the Unicode Sets (v) flag is set. + ~~~~~~~~~~~~~ +!!! error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. + ~~~~~~~~~ +!!! error TS1528: Any Unicode property that would possibly match more than a single character is only available when the Unicode Sets (v) flag is set. + ~~~~~~~~~~~~~ +!!! error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. + ~~~~~~~~~ +!!! error TS1528: Any Unicode property that would possibly match more than a single character is only available when the Unicode Sets (v) flag is set. + ~~~~~~~~~~~~~ +!!! error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. + ~~~~~~~~~ +!!! error TS1528: Any Unicode property that would possibly match more than a single character is only available when the Unicode Sets (v) flag is set. + /\p{RGI_Emoji}\P{RGI_Emoji}[^\p{RGI_Emoji}\P{RGI_Emoji}]/u, + ~~~~~~~~~ +!!! error TS1528: Any Unicode property that would possibly match more than a single character is only available when the Unicode Sets (v) flag is set. + ~~~~~~~~~ +!!! error TS1528: Any Unicode property that would possibly match more than a single character is only available when the Unicode Sets (v) flag is set. + ~~~~~~~~~ +!!! error TS1528: Any Unicode property that would possibly match more than a single character is only available when the Unicode Sets (v) flag is set. + ~~~~~~~~~ +!!! error TS1528: Any Unicode property that would possibly match more than a single character is only available when the Unicode Sets (v) flag is set. + /\p{RGI_Emoji}\P{RGI_Emoji}[^\p{RGI_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 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 TS1501: This regular expression flag is only available when targeting 'es2024' or later. + // Character escapes + /\c[\c0\ca\cQ\c\C]\c1\C/, + /\c[\c0\ca\cQ\c\C]\c1\C/u, + ~~ +!!! error TS1512: '\c' must be followed by an ASCII letter. + ~~ +!!! error TS1512: '\c' must be followed by an ASCII letter. + ~~ +!!! error TS1512: '\c' must be followed by an ASCII letter. + ~~ +!!! error TS1535: This character cannot be escaped in a regular expression. + ~~ +!!! error TS1512: '\c' must be followed by an ASCII letter. + ~~ +!!! error TS1535: This character cannot be escaped in a regular expression. + /\q\\\`[\q\\\`[\Q\\\Q{\q{foo|bar|baz]\q{]\q{/, + /\q\\\`[\q\\\`[\Q\\\Q{\q{foo|bar|baz]\q{]\q{/u, + ~~ +!!! error TS1535: This character cannot be escaped in a regular expression. + ~~ +!!! error TS1535: This character cannot be escaped in a regular expression. + ~~ +!!! error TS1535: This character cannot be escaped in a regular expression. + ~~ +!!! error TS1535: This character cannot be escaped in a regular expression. + ~~ +!!! error TS1535: This character cannot be escaped in a regular expression. + ~~ +!!! error TS1535: This character cannot be escaped in a regular expression. + ~~ +!!! error TS1535: This character cannot be escaped in a regular expression. + ~~ +!!! error TS1535: This character cannot be escaped in a regular expression. + ~ +!!! error TS1508: Unexpected '{'. Did you mean to escape it with backslash? + ~ +!!! error TS1508: Unexpected ']'. Did you mean to escape it with backslash? + ~~ +!!! error TS1535: This character cannot be escaped in a regular expression. + ~ +!!! error TS1508: Unexpected '{'. Did you mean to escape it with backslash? + /\q\\\`[\q\\\`[\Q\\\Q{\q{foo|bar|baz]\q{]\q{/v, + ~~ +!!! error TS1511: '\q' is only available inside character class. + ~~ +!!! error TS1535: This character cannot be escaped in a regular expression. + ~~ +!!! error TS1521: '\q' must be followed by string alternatives enclosed in braces. + ~~ +!!! error TS1535: This character cannot be escaped in a regular expression. + ~~ +!!! error TS1535: This character cannot be escaped in a regular expression. + ~ +!!! error TS1508: Unexpected '{'. Did you mean to escape it with backslash? + ~ +!!! error TS1508: Unexpected ']'. Did you mean to escape it with backslash? + ~~ +!!! error TS1535: This character cannot be escaped in a regular expression. + ~ +!!! error TS1508: Unexpected '{'. Did you mean to escape it with backslash? + ~ +!!! error TS1508: Unexpected ']'. Did you mean to escape it with backslash? + ~~ +!!! error TS1535: This character cannot be escaped in a regular expression. + ~ +!!! error TS1508: Unexpected '{'. Did you mean to escape it with backslash? + +!!! error TS1005: '}' expected. + ~ +!!! error TS1501: This regular expression flag is only available when targeting 'es2024' or later. + // Unicode sets notation + /[a--b[--][\d++[]]&&[[&0-9--]&&[\p{L}]--\P{L}-_-]]&&&\q{foo}[0---9][&&q&&&\q{bar}&&]/, + ~~~ +!!! error TS1517: Range out of order in character class. + ~~~ +!!! error TS1517: Range out of order in character class. + ~~~~~ +!!! error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. + ~~~~~ +!!! error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. + ~~~ +!!! error TS1517: Range out of order in character class. + /[a--b[--][\d++[]]&&[[&0-9--]&&[\p{L}]--\P{L}-_-]]&&&\q{foo}[0---9][&&q&&&\q{bar}&&]/u, + ~~~ +!!! error TS1517: Range out of order in character class. + ~~~ +!!! error TS1517: Range out of order in character class. + ~ +!!! error TS1508: Unexpected ']'. Did you mean to escape it with backslash? + ~ +!!! error TS1508: Unexpected ']'. Did you mean to escape it with backslash? + ~ +!!! error TS1508: Unexpected ']'. Did you mean to escape it with backslash? + ~~ +!!! error TS1535: This character cannot be escaped in a regular expression. + ~ +!!! error TS1508: Unexpected '{'. Did you mean to escape it with backslash? + ~ +!!! error TS1508: Unexpected '}'. Did you mean to escape it with backslash? + ~~~ +!!! error TS1517: Range out of order in character class. + ~~ +!!! error TS1535: This character cannot be escaped in a regular expression. + /[a--b[--][\d++[]]&&[[&0-9--]&&[\p{L}]--\P{L}-_-]]&&&\q{foo}[0---9][&&q&&&\q{bar}&&]/v, + +!!! error TS1005: '--' expected. + +!!! error TS1520: Expected a class set operand. + +!!! error TS1520: Expected a class set operand. + +!!! error TS1005: '--' expected. + ~~ +!!! error TS1522: A character class must not contain a reserved double punctuator. Did you mean to escape it with backslash? + ~~ +!!! error TS1519: Operators must not be mixed within a character class. Wrap it in a nested class instead. + ~~ +!!! error TS1519: Operators must not be mixed within a character class. Wrap it in a nested class instead. + ~~ +!!! error TS1519: Operators must not be mixed within a character class. Wrap it in a nested class instead. + ~ +!!! error TS1519: Operators must not be mixed within a character class. Wrap it in a nested class instead. + ~ +!!! error TS1519: Operators must not be mixed within a character class. Wrap it in a nested class instead. + +!!! error TS1520: Expected a class set operand. + ~~ +!!! error TS1511: '\q' is only available inside character class. + ~ +!!! error TS1508: Unexpected '{'. Did you mean to escape it with backslash? + ~ +!!! error TS1508: Unexpected '}'. Did you mean to escape it with backslash? + ~ +!!! error TS1508: Unexpected '-'. Did you mean to escape it with backslash? + +!!! error TS1005: '--' expected. + +!!! error TS1520: Expected a class set operand. + ~ +!!! error TS1508: Unexpected '&'. Did you mean to escape it with backslash? + +!!! error TS1520: Expected a class set operand. + ~ +!!! error TS1501: This regular expression flag is only available when targeting 'es2024' or later. + /[[^\P{Decimal_Number}&&[0-9]]&&\p{L}&&\p{ID_Continue}--\p{ASCII}\p{CWCF}]/v, + ~~ +!!! error TS1519: Operators must not be mixed within a character class. Wrap it in a nested class instead. + +!!! error TS1005: '&&' expected. + ~ +!!! 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 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, + ~~~~~~~~~~~~~ +!!! 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 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. + ~ +!!! 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 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, + ~~~~~~~~~~~~~~~~~ +!!! 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 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. + ~ +!!! error TS1501: This regular expression flag is only available when targeting 'es2024' or later. + /[^\q{foo|bar|baz}--\q{foo}--\q{bar}--\q{baz}][^\p{L}--\q{foo}--[\q{bar}]--[^[\q{baz}]]]/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 TS1501: This regular expression flag is only available when targeting 'es2024' or later. + /[^[[\q{foo|bar|baz}]]--\q{foo}--\q{bar}--\q{baz}][^[^[^\p{L}]]--\q{foo}--[\q{bar}]--[^[\q{baz}]]]/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 TS1501: This regular expression flag is only available when targeting 'es2024' or later. + ]; + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/regularExpressionScanning(target=es2015).errors.txt.diff b/testdata/baselines/reference/submodule/compiler/regularExpressionScanning(target=es2015).errors.txt.diff deleted file mode 100644 index c0d8a52a11..0000000000 --- a/testdata/baselines/reference/submodule/compiler/regularExpressionScanning(target=es2015).errors.txt.diff +++ /dev/null @@ -1,713 +0,0 @@ ---- old.regularExpressionScanning(target=es2015).errors.txt -+++ new.regularExpressionScanning(target=es2015).errors.txt -@@= skipped -0, +0 lines =@@ --regularExpressionScanning.ts(3,7): error TS1501: This regular expression flag is only available when targeting 'es2024' or later. --regularExpressionScanning.ts(3,9): error TS1501: This regular expression flag is only available when targeting 'es2018' or later. --regularExpressionScanning.ts(3,10): error TS1502: The Unicode (u) flag and the Unicode Sets (v) flag cannot be set simultaneously. --regularExpressionScanning.ts(3,11): error TS1499: Unknown regular expression flag. --regularExpressionScanning.ts(3,12): error TS1499: Unknown regular expression flag. --regularExpressionScanning.ts(3,13): error TS1500: Duplicate regular expression flag. --regularExpressionScanning.ts(3,14): error TS1499: Unknown regular expression flag. --regularExpressionScanning.ts(3,15): error TS1502: The Unicode (u) flag and the Unicode Sets (v) flag cannot be set simultaneously. --regularExpressionScanning.ts(3,16): error TS1501: This regular expression flag is only available when targeting 'es2022' or later. --regularExpressionScanning.ts(3,17): error TS1500: Duplicate regular expression flag. --regularExpressionScanning.ts(3,18): error TS1499: Unknown regular expression flag. --regularExpressionScanning.ts(3,19): error TS1499: Unknown regular expression flag. --regularExpressionScanning.ts(3,20): error TS1499: Unknown regular expression flag. --regularExpressionScanning.ts(3,21): error TS1500: Duplicate regular expression flag. --regularExpressionScanning.ts(3,22): error TS1499: Unknown regular expression flag. --regularExpressionScanning.ts(5,6): error TS1499: Unknown regular expression flag. --regularExpressionScanning.ts(5,7): error TS1509: This regular expression flag cannot be toggled within a subpattern. --regularExpressionScanning.ts(5,10): error TS1509: This regular expression flag cannot be toggled within a subpattern. --regularExpressionScanning.ts(5,11): error TS1500: Duplicate regular expression flag. --regularExpressionScanning.ts(8,4): error TS1534: This backreference refers to a group that does not exist. There are no capturing groups in this regular expression. --regularExpressionScanning.ts(9,4): error TS1534: This backreference refers to a group that does not exist. There are no capturing groups in this regular expression. --regularExpressionScanning.ts(12,9): error TS1533: This backreference refers to a group that does not exist. There are only 4 capturing groups in this regular expression. --regularExpressionScanning.ts(12,24): error TS1536: Octal escape sequences and backreferences are not allowed in a character class. If this was intended as an escape sequence, use the syntax '\x01' instead. --regularExpressionScanning.ts(12,26): error TS1487: Octal escape sequences are not allowed. Use the syntax '\x01'. --regularExpressionScanning.ts(12,29): error TS1536: Octal escape sequences and backreferences are not allowed in a character class. If this was intended as an escape sequence, use the syntax '\x53' instead. --regularExpressionScanning.ts(12,33): error TS1487: Octal escape sequences are not allowed. Use the syntax '\x00'. --regularExpressionScanning.ts(12,36): error TS1537: Decimal escape sequences and backreferences are not allowed in a character class. --regularExpressionScanning.ts(12,42): error TS1487: Octal escape sequences are not allowed. Use the syntax '\x03'. --regularExpressionScanning.ts(12,47): error TS1533: This backreference refers to a group that does not exist. There are only 4 capturing groups in this regular expression. --regularExpressionScanning.ts(12,48): error TS1487: Octal escape sequences are not allowed. Use the syntax '\x05'. --regularExpressionScanning.ts(12,53): error TS1533: This backreference refers to a group that does not exist. There are only 4 capturing groups in this regular expression. --regularExpressionScanning.ts(12,54): error TS1487: Octal escape sequences are not allowed. Use the syntax '\x00'. --regularExpressionScanning.ts(13,9): error TS1533: This backreference refers to a group that does not exist. There are only 4 capturing groups in this regular expression. --regularExpressionScanning.ts(13,24): error TS1536: Octal escape sequences and backreferences are not allowed in a character class. If this was intended as an escape sequence, use the syntax '\x01' instead. --regularExpressionScanning.ts(13,26): error TS1487: Octal escape sequences are not allowed. Use the syntax '\x01'. --regularExpressionScanning.ts(13,29): error TS1536: Octal escape sequences and backreferences are not allowed in a character class. If this was intended as an escape sequence, use the syntax '\x53' instead. --regularExpressionScanning.ts(13,33): error TS1487: Octal escape sequences are not allowed. Use the syntax '\x00'. --regularExpressionScanning.ts(13,36): error TS1537: Decimal escape sequences and backreferences are not allowed in a character class. --regularExpressionScanning.ts(13,42): error TS1487: Octal escape sequences are not allowed. Use the syntax '\x03'. --regularExpressionScanning.ts(13,47): error TS1533: This backreference refers to a group that does not exist. There are only 4 capturing groups in this regular expression. --regularExpressionScanning.ts(13,48): error TS1487: Octal escape sequences are not allowed. Use the syntax '\x05'. --regularExpressionScanning.ts(13,53): error TS1533: This backreference refers to a group that does not exist. There are only 4 capturing groups in this regular expression. --regularExpressionScanning.ts(13,54): error TS1487: Octal escape sequences are not allowed. Use the syntax '\x00'. --regularExpressionScanning.ts(14,5): error TS1503: Named capturing groups are only available when targeting 'ES2018' or later. --regularExpressionScanning.ts(14,14): error TS1503: Named capturing groups are only available when targeting 'ES2018' or later. --regularExpressionScanning.ts(14,29): error TS1503: Named capturing groups are only available when targeting 'ES2018' or later. --regularExpressionScanning.ts(14,45): error TS1503: Named capturing groups are only available when targeting 'ES2018' or later. --regularExpressionScanning.ts(14,57): error TS1503: Named capturing groups are only available when targeting 'ES2018' or later. --regularExpressionScanning.ts(15,15): error TS1532: There is no capturing group named 'absent' in this regular expression. --regularExpressionScanning.ts(15,24): error TS1503: Named capturing groups are only available when targeting 'ES2018' or later. --regularExpressionScanning.ts(15,36): error TS1503: Named capturing groups are only available when targeting 'ES2018' or later. --regularExpressionScanning.ts(15,45): error TS1503: Named capturing groups are only available when targeting 'ES2018' or later. --regularExpressionScanning.ts(15,58): error TS1503: Named capturing groups are only available when targeting 'ES2018' or later. --regularExpressionScanning.ts(15,59): error TS1515: Named capturing groups with the same name must be mutually exclusive to each other. --regularExpressionScanning.ts(17,31): error TS1507: There is nothing available for repetition. --regularExpressionScanning.ts(17,32): error TS1506: Numbers out of order in quantifier. --regularExpressionScanning.ts(17,40): error TS1507: There is nothing available for repetition. --regularExpressionScanning.ts(19,12): error TS1517: Range out of order in character class. --regularExpressionScanning.ts(19,15): error TS1517: Range out of order in character class. --regularExpressionScanning.ts(19,28): error TS1517: Range out of order in character class. --regularExpressionScanning.ts(20,3): error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. --regularExpressionScanning.ts(20,8): error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. --regularExpressionScanning.ts(20,16): error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. --regularExpressionScanning.ts(20,25): error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. --regularExpressionScanning.ts(20,28): error TS1529: Unknown Unicode property name or value. --regularExpressionScanning.ts(20,37): error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. --regularExpressionScanning.ts(20,42): error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. --regularExpressionScanning.ts(20,50): error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. --regularExpressionScanning.ts(20,59): error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. --regularExpressionScanning.ts(20,62): error TS1529: Unknown Unicode property name or value. --regularExpressionScanning.ts(21,28): error TS1529: Unknown Unicode property name or value. --regularExpressionScanning.ts(21,62): error TS1529: Unknown Unicode property name or value. --regularExpressionScanning.ts(22,28): error TS1529: Unknown Unicode property name or value. --regularExpressionScanning.ts(22,62): error TS1529: Unknown Unicode property name or value. --regularExpressionScanning.ts(22,72): error TS1501: This regular expression flag is only available when targeting 'es2024' or later. --regularExpressionScanning.ts(23,3): error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. --regularExpressionScanning.ts(23,6): error TS1524: Unknown Unicode property name. --regularExpressionScanning.ts(23,28): error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. --regularExpressionScanning.ts(23,31): error TS1523: Expected a Unicode property name. --regularExpressionScanning.ts(23,32): error TS1525: Expected a Unicode property value. --regularExpressionScanning.ts(23,33): error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. --regularExpressionScanning.ts(23,39): error TS1525: Expected a Unicode property value. --regularExpressionScanning.ts(23,40): error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. --regularExpressionScanning.ts(23,43): error TS1523: Expected a Unicode property name. --regularExpressionScanning.ts(23,49): error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. --regularExpressionScanning.ts(23,52): error TS1527: Expected a Unicode property name or value. --regularExpressionScanning.ts(23,59): error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. --regularExpressionScanning.ts(23,62): error TS1527: Expected a Unicode property name or value. --regularExpressionScanning.ts(23,63): error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. --regularExpressionScanning.ts(23,66): error TS1527: Expected a Unicode property name or value. --regularExpressionScanning.ts(24,6): error TS1524: Unknown Unicode property name. --regularExpressionScanning.ts(24,31): error TS1523: Expected a Unicode property name. --regularExpressionScanning.ts(24,32): error TS1525: Expected a Unicode property value. --regularExpressionScanning.ts(24,39): error TS1525: Expected a Unicode property value. --regularExpressionScanning.ts(24,43): error TS1523: Expected a Unicode property name. --regularExpressionScanning.ts(24,52): error TS1527: Expected a Unicode property name or value. --regularExpressionScanning.ts(24,53): error TS1531: '\p' must be followed by a Unicode property value expression enclosed in braces. --regularExpressionScanning.ts(24,57): error TS1531: '\P' must be followed by a Unicode property value expression enclosed in braces. --regularExpressionScanning.ts(24,62): error TS1527: Expected a Unicode property name or value. --regularExpressionScanning.ts(24,66): error TS1527: Expected a Unicode property name or value. --regularExpressionScanning.ts(25,6): error TS1524: Unknown Unicode property name. --regularExpressionScanning.ts(25,31): error TS1523: Expected a Unicode property name. --regularExpressionScanning.ts(25,32): error TS1525: Expected a Unicode property value. --regularExpressionScanning.ts(25,39): error TS1525: Expected a Unicode property value. --regularExpressionScanning.ts(25,43): error TS1523: Expected a Unicode property name. --regularExpressionScanning.ts(25,52): error TS1527: Expected a Unicode property name or value. --regularExpressionScanning.ts(25,53): error TS1531: '\p' must be followed by a Unicode property value expression enclosed in braces. --regularExpressionScanning.ts(25,57): error TS1531: '\P' must be followed by a Unicode property value expression enclosed in braces. --regularExpressionScanning.ts(25,62): error TS1527: Expected a Unicode property name or value. --regularExpressionScanning.ts(25,66): error TS1527: Expected a Unicode property name or value. --regularExpressionScanning.ts(25,67): error TS1501: This regular expression flag is only available when targeting 'es2024' or later. --regularExpressionScanning.ts(26,3): error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. --regularExpressionScanning.ts(26,6): error TS1528: Any Unicode property that would possibly match more than a single character is only available when the Unicode Sets (v) flag is set. --regularExpressionScanning.ts(26,16): error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. --regularExpressionScanning.ts(26,19): error TS1528: Any Unicode property that would possibly match more than a single character is only available when the Unicode Sets (v) flag is set. --regularExpressionScanning.ts(26,31): error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. --regularExpressionScanning.ts(26,34): error TS1528: Any Unicode property that would possibly match more than a single character is only available when the Unicode Sets (v) flag is set. --regularExpressionScanning.ts(26,44): error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. --regularExpressionScanning.ts(26,47): error TS1528: Any Unicode property that would possibly match more than a single character is only available when the Unicode Sets (v) flag is set. --regularExpressionScanning.ts(27,6): error TS1528: Any Unicode property that would possibly match more than a single character is only available when the Unicode Sets (v) flag is set. --regularExpressionScanning.ts(27,19): error TS1528: Any Unicode property that would possibly match more than a single character is only available when the Unicode Sets (v) flag is set. --regularExpressionScanning.ts(27,34): error TS1528: Any Unicode property that would possibly match more than a single character is only available when the Unicode Sets (v) flag is set. --regularExpressionScanning.ts(27,47): error TS1528: Any Unicode property that would possibly match more than a single character is only available when the Unicode Sets (v) flag is set. --regularExpressionScanning.ts(28,19): error TS1518: Anything that would possibly match more than a single character is invalid inside a negated character class. --regularExpressionScanning.ts(28,31): error TS1518: Anything that would possibly match more than a single character is invalid inside a negated character class. --regularExpressionScanning.ts(28,47): error TS1518: Anything that would possibly match more than a single character is invalid inside a negated character class. --regularExpressionScanning.ts(28,59): error TS1501: This regular expression flag is only available when targeting 'es2024' or later. --regularExpressionScanning.ts(31,3): error TS1512: '\c' must be followed by an ASCII letter. --regularExpressionScanning.ts(31,6): error TS1512: '\c' must be followed by an ASCII letter. --regularExpressionScanning.ts(31,15): error TS1512: '\c' must be followed by an ASCII letter. --regularExpressionScanning.ts(31,17): error TS1535: This character cannot be escaped in a regular expression. --regularExpressionScanning.ts(31,20): error TS1512: '\c' must be followed by an ASCII letter. --regularExpressionScanning.ts(31,23): error TS1535: This character cannot be escaped in a regular expression. --regularExpressionScanning.ts(33,3): error TS1535: This character cannot be escaped in a regular expression. --regularExpressionScanning.ts(33,7): error TS1535: This character cannot be escaped in a regular expression. --regularExpressionScanning.ts(33,10): error TS1535: This character cannot be escaped in a regular expression. --regularExpressionScanning.ts(33,14): error TS1535: This character cannot be escaped in a regular expression. --regularExpressionScanning.ts(33,17): error TS1535: This character cannot be escaped in a regular expression. --regularExpressionScanning.ts(33,21): error TS1535: This character cannot be escaped in a regular expression. --regularExpressionScanning.ts(33,24): error TS1535: This character cannot be escaped in a regular expression. --regularExpressionScanning.ts(33,39): error TS1535: This character cannot be escaped in a regular expression. --regularExpressionScanning.ts(33,41): error TS1508: Unexpected '{'. Did you mean to escape it with backslash? --regularExpressionScanning.ts(33,42): error TS1508: Unexpected ']'. Did you mean to escape it with backslash? --regularExpressionScanning.ts(33,43): error TS1535: This character cannot be escaped in a regular expression. --regularExpressionScanning.ts(33,45): error TS1508: Unexpected '{'. Did you mean to escape it with backslash? --regularExpressionScanning.ts(34,3): error TS1511: '\q' is only available inside character class. --regularExpressionScanning.ts(34,7): error TS1535: This character cannot be escaped in a regular expression. --regularExpressionScanning.ts(34,10): error TS1521: '\q' must be followed by string alternatives enclosed in braces. --regularExpressionScanning.ts(34,17): error TS1535: This character cannot be escaped in a regular expression. --regularExpressionScanning.ts(34,21): error TS1535: This character cannot be escaped in a regular expression. --regularExpressionScanning.ts(34,23): error TS1508: Unexpected '{'. Did you mean to escape it with backslash? --regularExpressionScanning.ts(34,38): error TS1508: Unexpected ']'. Did you mean to escape it with backslash? --regularExpressionScanning.ts(34,39): error TS1535: This character cannot be escaped in a regular expression. --regularExpressionScanning.ts(34,41): error TS1508: Unexpected '{'. Did you mean to escape it with backslash? --regularExpressionScanning.ts(34,42): error TS1508: Unexpected ']'. Did you mean to escape it with backslash? --regularExpressionScanning.ts(34,43): error TS1535: This character cannot be escaped in a regular expression. --regularExpressionScanning.ts(34,45): error TS1508: Unexpected '{'. Did you mean to escape it with backslash? --regularExpressionScanning.ts(34,46): error TS1005: '}' expected. --regularExpressionScanning.ts(34,47): error TS1501: This regular expression flag is only available when targeting 'es2024' or later. --regularExpressionScanning.ts(36,4): error TS1517: Range out of order in character class. --regularExpressionScanning.ts(36,8): error TS1517: Range out of order in character class. --regularExpressionScanning.ts(36,34): error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. --regularExpressionScanning.ts(36,42): error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. --regularExpressionScanning.ts(36,63): error TS1517: Range out of order in character class. --regularExpressionScanning.ts(37,4): error TS1517: Range out of order in character class. --regularExpressionScanning.ts(37,8): error TS1517: Range out of order in character class. --regularExpressionScanning.ts(37,19): error TS1508: Unexpected ']'. Did you mean to escape it with backslash? --regularExpressionScanning.ts(37,50): error TS1508: Unexpected ']'. Did you mean to escape it with backslash? --regularExpressionScanning.ts(37,51): error TS1508: Unexpected ']'. Did you mean to escape it with backslash? --regularExpressionScanning.ts(37,55): error TS1535: This character cannot be escaped in a regular expression. --regularExpressionScanning.ts(37,57): error TS1508: Unexpected '{'. Did you mean to escape it with backslash? --regularExpressionScanning.ts(37,61): error TS1508: Unexpected '}'. Did you mean to escape it with backslash? --regularExpressionScanning.ts(37,63): error TS1517: Range out of order in character class. --regularExpressionScanning.ts(37,76): error TS1535: This character cannot be escaped in a regular expression. --regularExpressionScanning.ts(38,8): error TS1005: '--' expected. --regularExpressionScanning.ts(38,9): error TS1520: Expected a class set operand. --regularExpressionScanning.ts(38,11): error TS1520: Expected a class set operand. --regularExpressionScanning.ts(38,12): error TS1005: '--' expected. --regularExpressionScanning.ts(38,15): error TS1522: A character class must not contain a reserved double punctuator. Did you mean to escape it with backslash? --regularExpressionScanning.ts(38,20): error TS1519: Operators must not be mixed within a character class. Wrap it in a nested class instead. --regularExpressionScanning.ts(38,28): error TS1519: Operators must not be mixed within a character class. Wrap it in a nested class instead. --regularExpressionScanning.ts(38,40): error TS1519: Operators must not be mixed within a character class. Wrap it in a nested class instead. --regularExpressionScanning.ts(38,47): error TS1519: Operators must not be mixed within a character class. Wrap it in a nested class instead. --regularExpressionScanning.ts(38,49): error TS1519: Operators must not be mixed within a character class. Wrap it in a nested class instead. --regularExpressionScanning.ts(38,50): error TS1520: Expected a class set operand. --regularExpressionScanning.ts(38,55): error TS1511: '\q' is only available inside character class. --regularExpressionScanning.ts(38,57): error TS1508: Unexpected '{'. Did you mean to escape it with backslash? --regularExpressionScanning.ts(38,61): error TS1508: Unexpected '}'. Did you mean to escape it with backslash? --regularExpressionScanning.ts(38,66): error TS1508: Unexpected '-'. Did you mean to escape it with backslash? --regularExpressionScanning.ts(38,67): error TS1005: '--' expected. --regularExpressionScanning.ts(38,70): error TS1520: Expected a class set operand. --regularExpressionScanning.ts(38,75): error TS1508: Unexpected '&'. Did you mean to escape it with backslash? --regularExpressionScanning.ts(38,85): error TS1520: Expected a class set operand. --regularExpressionScanning.ts(38,87): error TS1501: This regular expression flag is only available when targeting 'es2024' or later. --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,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,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,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,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. --regularExpressionScanning.ts(46,5): error TS1518: Anything that would possibly match more than a single character is invalid inside a negated character class. --regularExpressionScanning.ts(46,79): error TS1518: Anything that would possibly match more than a single character is invalid inside a negated character class. --regularExpressionScanning.ts(46,91): error TS1501: This regular expression flag is only available when targeting 'es2024' or later. --regularExpressionScanning.ts(47,5): error TS1518: Anything that would possibly match more than a single character is invalid inside a negated character class. --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(47,101): error TS1501: This regular expression flag is only available when targeting 'es2024' or later. -- -- --==== regularExpressionScanning.ts (219 errors) ==== -- const regexes: RegExp[] = [ -- // Flags -- /foo/visualstudiocode, -- ~ --!!! error TS1501: This regular expression flag is only available when targeting 'es2024' or later. -- ~ --!!! error TS1501: This regular expression flag is only available when targeting 'es2018' or later. -- ~ --!!! error TS1502: The Unicode (u) flag and the Unicode Sets (v) flag cannot be set simultaneously. -- ~ --!!! error TS1499: Unknown regular expression flag. -- ~ --!!! error TS1499: Unknown regular expression flag. -- ~ --!!! error TS1500: Duplicate regular expression flag. -- ~ --!!! error TS1499: Unknown regular expression flag. -- ~ --!!! error TS1502: The Unicode (u) flag and the Unicode Sets (v) flag cannot be set simultaneously. -- ~ --!!! error TS1501: This regular expression flag is only available when targeting 'es2022' or later. -- ~ --!!! error TS1500: Duplicate regular expression flag. -- ~ --!!! error TS1499: Unknown regular expression flag. -- ~ --!!! error TS1499: Unknown regular expression flag. -- ~ --!!! error TS1499: Unknown regular expression flag. -- ~ --!!! error TS1500: Duplicate regular expression flag. -- ~ --!!! error TS1499: Unknown regular expression flag. -- // Pattern modifiers -- /(?med-ium:bar)/, -- ~ --!!! error TS1499: Unknown regular expression flag. -- ~ --!!! error TS1509: This regular expression flag cannot be toggled within a subpattern. -- ~ --!!! error TS1509: This regular expression flag cannot be toggled within a subpattern. -- ~ --!!! error TS1500: Duplicate regular expression flag. -- // Capturing groups -- /\0/, -- /\1/, -- ~ --!!! error TS1534: This backreference refers to a group that does not exist. There are no capturing groups in this regular expression. -- /\2/, -- ~ --!!! error TS1534: This backreference refers to a group that does not exist. There are no capturing groups in this regular expression. -- /(hi)\1/, -- /(hi) (hello) \2/, -- /\2()(\12)(foo)\1\0[\0\1\01\123\08\8](\3\03)\5\005\9\009/, -- ~~ --!!! error TS1533: This backreference refers to a group that does not exist. There are only 4 capturing groups in this regular expression. -- ~~ --!!! error TS1536: Octal escape sequences and backreferences are not allowed in a character class. If this was intended as an escape sequence, use the syntax '\x01' instead. -- ~~~ --!!! error TS1487: Octal escape sequences are not allowed. Use the syntax '\x01'. -- ~~~~ --!!! error TS1536: Octal escape sequences and backreferences are not allowed in a character class. If this was intended as an escape sequence, use the syntax '\x53' instead. -- ~~ --!!! error TS1487: Octal escape sequences are not allowed. Use the syntax '\x00'. -- ~~ --!!! error TS1537: Decimal escape sequences and backreferences are not allowed in a character class. -- ~~~ --!!! error TS1487: Octal escape sequences are not allowed. Use the syntax '\x03'. -- ~ --!!! error TS1533: This backreference refers to a group that does not exist. There are only 4 capturing groups in this regular expression. -- ~~~~ --!!! error TS1487: Octal escape sequences are not allowed. Use the syntax '\x05'. -- ~ --!!! error TS1533: This backreference refers to a group that does not exist. There are only 4 capturing groups in this regular expression. -- ~~~ --!!! error TS1487: Octal escape sequences are not allowed. Use the syntax '\x00'. -- /\2()(\12)(foo)\1\0[\0\1\01\123\08\8](\3\03)\5\005\9\009/u, -- ~~ --!!! error TS1533: This backreference refers to a group that does not exist. There are only 4 capturing groups in this regular expression. -- ~~ --!!! error TS1536: Octal escape sequences and backreferences are not allowed in a character class. If this was intended as an escape sequence, use the syntax '\x01' instead. -- ~~~ --!!! error TS1487: Octal escape sequences are not allowed. Use the syntax '\x01'. -- ~~~~ --!!! error TS1536: Octal escape sequences and backreferences are not allowed in a character class. If this was intended as an escape sequence, use the syntax '\x53' instead. -- ~~ --!!! error TS1487: Octal escape sequences are not allowed. Use the syntax '\x00'. -- ~~ --!!! error TS1537: Decimal escape sequences and backreferences are not allowed in a character class. -- ~~~ --!!! error TS1487: Octal escape sequences are not allowed. Use the syntax '\x03'. -- ~ --!!! error TS1533: This backreference refers to a group that does not exist. There are only 4 capturing groups in this regular expression. -- ~~~~ --!!! error TS1487: Octal escape sequences are not allowed. Use the syntax '\x05'. -- ~ --!!! error TS1533: This backreference refers to a group that does not exist. There are only 4 capturing groups in this regular expression. -- ~~~ --!!! error TS1487: Octal escape sequences are not allowed. Use the syntax '\x00'. -- /(?)((?bar)bar)(?baz)|(foo(?foo))(?)/, -- ~~~~~ --!!! error TS1503: Named capturing groups are only available when targeting 'ES2018' or later. -- ~~~~~ --!!! error TS1503: Named capturing groups are only available when targeting 'ES2018' or later. -- ~~~~~ --!!! error TS1503: Named capturing groups are only available when targeting 'ES2018' or later. -- ~~~~~ --!!! error TS1503: Named capturing groups are only available when targeting 'ES2018' or later. -- ~~~~~ --!!! error TS1503: Named capturing groups are only available when targeting 'ES2018' or later. -- /(\k)\k(?foo)|(?)((?)|(bar(?bar)))/, -- ~~~~~~ --!!! error TS1532: There is no capturing group named 'absent' in this regular expression. -- ~~~~~ --!!! error TS1503: Named capturing groups are only available when targeting 'ES2018' or later. -- ~~~~~ --!!! error TS1503: Named capturing groups are only available when targeting 'ES2018' or later. -- ~~~~~ --!!! error TS1503: Named capturing groups are only available when targeting 'ES2018' or later. -- ~~~~~ --!!! error TS1503: Named capturing groups are only available when targeting 'ES2018' or later. -- ~~~ --!!! error TS1515: Named capturing groups with the same name must be mutually exclusive to each other. -- // Quantifiers -- /{}{1,2}_{3}.{4,}?(foo){008}${32,16}\b{064,128}.+&*?\???\n{,256}{\\{,/, -- ~~~~~~~ --!!! error TS1507: There is nothing available for repetition. -- ~~~~~ --!!! error TS1506: Numbers out of order in quantifier. -- ~~~~~~~~~ --!!! error TS1507: There is nothing available for repetition. -- // Character classes -- /[-A-Za-z-z-aZ-A\d_-\d-.-.\r-\n\w-\W]/, -- ~~~ --!!! error TS1517: Range out of order in character class. -- ~~~ --!!! error TS1517: Range out of order in character class. -- ~~~~~ --!!! error TS1517: Range out of order in character class. -- /\p{L}\p{gc=L}\p{ASCII}\p{Invalid}[\p{L}\p{gc=L}\P{ASCII}\p{Invalid}]/, -- ~~~~~ --!!! error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. -- ~~~~~~~~ --!!! error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. -- ~~~~~~~~~ --!!! error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. -- ~~~~~~~~~~~ --!!! error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. -- ~~~~~~~ --!!! error TS1529: Unknown Unicode property name or value. -- ~~~~~ --!!! error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. -- ~~~~~~~~ --!!! error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. -- ~~~~~~~~~ --!!! error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. -- ~~~~~~~~~~~ --!!! error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. -- ~~~~~~~ --!!! error TS1529: Unknown Unicode property name or value. -- /\p{L}\p{gc=L}\p{ASCII}\p{Invalid}[\p{L}\p{gc=L}\P{ASCII}\p{Invalid}]/u, -- ~~~~~~~ --!!! error TS1529: Unknown Unicode property name or value. -- ~~~~~~~ --!!! error TS1529: Unknown Unicode property name or value. -- /\p{L}\p{gc=L}\p{ASCII}\p{Invalid}[\p{L}\p{gc=L}\P{ASCII}\p{Invalid}]/v, -- ~~~~~~~ --!!! error TS1529: Unknown Unicode property name or value. -- ~~~~~~~ --!!! error TS1529: Unknown Unicode property name or value. -- ~ --!!! error TS1501: This regular expression flag is only available when targeting 'es2024' or later. -- /\p{InvalidProperty=Value}\p{=}\p{sc=}\P{=foo}[\p{}\p\\\P\P{]\p{/, -- ~~~~~~~~~~~~~~~~~~~~~~~~~ --!!! error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. -- ~~~~~~~~~~~~~~~ --!!! error TS1524: Unknown Unicode property name. -- ~~~~~ --!!! error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. -- --!!! error TS1523: Expected a Unicode property name. -- --!!! error TS1525: Expected a Unicode property value. -- ~~~~~~~ --!!! error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. -- --!!! error TS1525: Expected a Unicode property value. -- ~~~~~~~~ --!!! error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. -- --!!! error TS1523: Expected a Unicode property name. -- ~~~~ --!!! error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. -- --!!! error TS1527: Expected a Unicode property name or value. -- ~~~ --!!! error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. -- --!!! error TS1527: Expected a Unicode property name or value. -- ~~~ --!!! error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. -- --!!! error TS1527: Expected a Unicode property name or value. -- /\p{InvalidProperty=Value}\p{=}\p{sc=}\P{=foo}[\p{}\p\\\P\P{]\p{/u, -- ~~~~~~~~~~~~~~~ --!!! error TS1524: Unknown Unicode property name. -- --!!! error TS1523: Expected a Unicode property name. -- --!!! error TS1525: Expected a Unicode property value. -- --!!! error TS1525: Expected a Unicode property value. -- --!!! error TS1523: Expected a Unicode property name. -- --!!! error TS1527: Expected a Unicode property name or value. -- ~~ --!!! error TS1531: '\p' must be followed by a Unicode property value expression enclosed in braces. -- ~~ --!!! error TS1531: '\P' must be followed by a Unicode property value expression enclosed in braces. -- --!!! error TS1527: Expected a Unicode property name or value. -- --!!! error TS1527: Expected a Unicode property name or value. -- /\p{InvalidProperty=Value}\p{=}\p{sc=}\P{=foo}[\p{}\p\\\P\P{]\p{/v, -- ~~~~~~~~~~~~~~~ --!!! error TS1524: Unknown Unicode property name. -- --!!! error TS1523: Expected a Unicode property name. -- --!!! error TS1525: Expected a Unicode property value. -- --!!! error TS1525: Expected a Unicode property value. -- --!!! error TS1523: Expected a Unicode property name. -- --!!! error TS1527: Expected a Unicode property name or value. -- ~~ --!!! error TS1531: '\p' must be followed by a Unicode property value expression enclosed in braces. -- ~~ --!!! error TS1531: '\P' must be followed by a Unicode property value expression enclosed in braces. -- --!!! error TS1527: Expected a Unicode property name or value. -- --!!! error TS1527: Expected a Unicode property name or value. -- ~ --!!! error TS1501: This regular expression flag is only available when targeting 'es2024' or later. -- /\p{RGI_Emoji}\P{RGI_Emoji}[^\p{RGI_Emoji}\P{RGI_Emoji}]/, -- ~~~~~~~~~~~~~ --!!! error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. -- ~~~~~~~~~ --!!! error TS1528: Any Unicode property that would possibly match more than a single character is only available when the Unicode Sets (v) flag is set. -- ~~~~~~~~~~~~~ --!!! error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. -- ~~~~~~~~~ --!!! error TS1528: Any Unicode property that would possibly match more than a single character is only available when the Unicode Sets (v) flag is set. -- ~~~~~~~~~~~~~ --!!! error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. -- ~~~~~~~~~ --!!! error TS1528: Any Unicode property that would possibly match more than a single character is only available when the Unicode Sets (v) flag is set. -- ~~~~~~~~~~~~~ --!!! error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. -- ~~~~~~~~~ --!!! error TS1528: Any Unicode property that would possibly match more than a single character is only available when the Unicode Sets (v) flag is set. -- /\p{RGI_Emoji}\P{RGI_Emoji}[^\p{RGI_Emoji}\P{RGI_Emoji}]/u, -- ~~~~~~~~~ --!!! error TS1528: Any Unicode property that would possibly match more than a single character is only available when the Unicode Sets (v) flag is set. -- ~~~~~~~~~ --!!! error TS1528: Any Unicode property that would possibly match more than a single character is only available when the Unicode Sets (v) flag is set. -- ~~~~~~~~~ --!!! error TS1528: Any Unicode property that would possibly match more than a single character is only available when the Unicode Sets (v) flag is set. -- ~~~~~~~~~ --!!! error TS1528: Any Unicode property that would possibly match more than a single character is only available when the Unicode Sets (v) flag is set. -- /\p{RGI_Emoji}\P{RGI_Emoji}[^\p{RGI_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 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 TS1501: This regular expression flag is only available when targeting 'es2024' or later. -- // Character escapes -- /\c[\c0\ca\cQ\c\C]\c1\C/, -- /\c[\c0\ca\cQ\c\C]\c1\C/u, -- ~~ --!!! error TS1512: '\c' must be followed by an ASCII letter. -- ~~ --!!! error TS1512: '\c' must be followed by an ASCII letter. -- ~~ --!!! error TS1512: '\c' must be followed by an ASCII letter. -- ~~ --!!! error TS1535: This character cannot be escaped in a regular expression. -- ~~ --!!! error TS1512: '\c' must be followed by an ASCII letter. -- ~~ --!!! error TS1535: This character cannot be escaped in a regular expression. -- /\q\\\`[\q\\\`[\Q\\\Q{\q{foo|bar|baz]\q{]\q{/, -- /\q\\\`[\q\\\`[\Q\\\Q{\q{foo|bar|baz]\q{]\q{/u, -- ~~ --!!! error TS1535: This character cannot be escaped in a regular expression. -- ~~ --!!! error TS1535: This character cannot be escaped in a regular expression. -- ~~ --!!! error TS1535: This character cannot be escaped in a regular expression. -- ~~ --!!! error TS1535: This character cannot be escaped in a regular expression. -- ~~ --!!! error TS1535: This character cannot be escaped in a regular expression. -- ~~ --!!! error TS1535: This character cannot be escaped in a regular expression. -- ~~ --!!! error TS1535: This character cannot be escaped in a regular expression. -- ~~ --!!! error TS1535: This character cannot be escaped in a regular expression. -- ~ --!!! error TS1508: Unexpected '{'. Did you mean to escape it with backslash? -- ~ --!!! error TS1508: Unexpected ']'. Did you mean to escape it with backslash? -- ~~ --!!! error TS1535: This character cannot be escaped in a regular expression. -- ~ --!!! error TS1508: Unexpected '{'. Did you mean to escape it with backslash? -- /\q\\\`[\q\\\`[\Q\\\Q{\q{foo|bar|baz]\q{]\q{/v, -- ~~ --!!! error TS1511: '\q' is only available inside character class. -- ~~ --!!! error TS1535: This character cannot be escaped in a regular expression. -- ~~ --!!! error TS1521: '\q' must be followed by string alternatives enclosed in braces. -- ~~ --!!! error TS1535: This character cannot be escaped in a regular expression. -- ~~ --!!! error TS1535: This character cannot be escaped in a regular expression. -- ~ --!!! error TS1508: Unexpected '{'. Did you mean to escape it with backslash? -- ~ --!!! error TS1508: Unexpected ']'. Did you mean to escape it with backslash? -- ~~ --!!! error TS1535: This character cannot be escaped in a regular expression. -- ~ --!!! error TS1508: Unexpected '{'. Did you mean to escape it with backslash? -- ~ --!!! error TS1508: Unexpected ']'. Did you mean to escape it with backslash? -- ~~ --!!! error TS1535: This character cannot be escaped in a regular expression. -- ~ --!!! error TS1508: Unexpected '{'. Did you mean to escape it with backslash? -- --!!! error TS1005: '}' expected. -- ~ --!!! error TS1501: This regular expression flag is only available when targeting 'es2024' or later. -- // Unicode sets notation -- /[a--b[--][\d++[]]&&[[&0-9--]&&[\p{L}]--\P{L}-_-]]&&&\q{foo}[0---9][&&q&&&\q{bar}&&]/, -- ~~~ --!!! error TS1517: Range out of order in character class. -- ~~~ --!!! error TS1517: Range out of order in character class. -- ~~~~~ --!!! error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. -- ~~~~~ --!!! error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. -- ~~~ --!!! error TS1517: Range out of order in character class. -- /[a--b[--][\d++[]]&&[[&0-9--]&&[\p{L}]--\P{L}-_-]]&&&\q{foo}[0---9][&&q&&&\q{bar}&&]/u, -- ~~~ --!!! error TS1517: Range out of order in character class. -- ~~~ --!!! error TS1517: Range out of order in character class. -- ~ --!!! error TS1508: Unexpected ']'. Did you mean to escape it with backslash? -- ~ --!!! error TS1508: Unexpected ']'. Did you mean to escape it with backslash? -- ~ --!!! error TS1508: Unexpected ']'. Did you mean to escape it with backslash? -- ~~ --!!! error TS1535: This character cannot be escaped in a regular expression. -- ~ --!!! error TS1508: Unexpected '{'. Did you mean to escape it with backslash? -- ~ --!!! error TS1508: Unexpected '}'. Did you mean to escape it with backslash? -- ~~~ --!!! error TS1517: Range out of order in character class. -- ~~ --!!! error TS1535: This character cannot be escaped in a regular expression. -- /[a--b[--][\d++[]]&&[[&0-9--]&&[\p{L}]--\P{L}-_-]]&&&\q{foo}[0---9][&&q&&&\q{bar}&&]/v, -- --!!! error TS1005: '--' expected. -- --!!! error TS1520: Expected a class set operand. -- --!!! error TS1520: Expected a class set operand. -- --!!! error TS1005: '--' expected. -- ~~ --!!! error TS1522: A character class must not contain a reserved double punctuator. Did you mean to escape it with backslash? -- ~~ --!!! error TS1519: Operators must not be mixed within a character class. Wrap it in a nested class instead. -- ~~ --!!! error TS1519: Operators must not be mixed within a character class. Wrap it in a nested class instead. -- ~~ --!!! error TS1519: Operators must not be mixed within a character class. Wrap it in a nested class instead. -- ~ --!!! error TS1519: Operators must not be mixed within a character class. Wrap it in a nested class instead. -- ~ --!!! error TS1519: Operators must not be mixed within a character class. Wrap it in a nested class instead. -- --!!! error TS1520: Expected a class set operand. -- ~~ --!!! error TS1511: '\q' is only available inside character class. -- ~ --!!! error TS1508: Unexpected '{'. Did you mean to escape it with backslash? -- ~ --!!! error TS1508: Unexpected '}'. Did you mean to escape it with backslash? -- ~ --!!! error TS1508: Unexpected '-'. Did you mean to escape it with backslash? -- --!!! error TS1005: '--' expected. -- --!!! error TS1520: Expected a class set operand. -- ~ --!!! error TS1508: Unexpected '&'. Did you mean to escape it with backslash? -- --!!! error TS1520: Expected a class set operand. -- ~ --!!! error TS1501: This regular expression flag is only available when targeting 'es2024' or later. -- /[[^\P{Decimal_Number}&&[0-9]]&&\p{L}&&\p{ID_Continue}--\p{ASCII}\p{CWCF}]/v, -- ~~ --!!! error TS1519: Operators must not be mixed within a character class. Wrap it in a nested class instead. -- --!!! error TS1005: '&&' expected. -- ~ --!!! 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 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, -- ~~~~~~~~~~~~~ --!!! 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 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. -- ~ --!!! 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 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, -- ~~~~~~~~~~~~~~~~~ --!!! 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 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. -- ~ --!!! error TS1501: This regular expression flag is only available when targeting 'es2024' or later. -- /[^\q{foo|bar|baz}--\q{foo}--\q{bar}--\q{baz}][^\p{L}--\q{foo}--[\q{bar}]--[^[\q{baz}]]]/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 TS1501: This regular expression flag is only available when targeting 'es2024' or later. -- /[^[[\q{foo|bar|baz}]]--\q{foo}--\q{bar}--\q{baz}][^[^[^\p{L}]]--\q{foo}--[\q{bar}]--[^[\q{baz}]]]/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 TS1501: This regular expression flag is only available when targeting 'es2024' or later. -- ]; -- -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/regularExpressionScanning(target=es5).errors.txt b/testdata/baselines/reference/submodule/compiler/regularExpressionScanning(target=es5).errors.txt new file mode 100644 index 0000000000..a32fb1567c --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/regularExpressionScanning(target=es5).errors.txt @@ -0,0 +1,709 @@ +regularExpressionScanning.ts(3,7): error TS1501: This regular expression flag is only available when targeting 'es2024' or later. +regularExpressionScanning.ts(3,9): error TS1501: This regular expression flag is only available when targeting 'es2018' or later. +regularExpressionScanning.ts(3,10): error TS1502: The Unicode (u) flag and the Unicode Sets (v) flag cannot be set simultaneously. +regularExpressionScanning.ts(3,11): error TS1499: Unknown regular expression flag. +regularExpressionScanning.ts(3,12): error TS1499: Unknown regular expression flag. +regularExpressionScanning.ts(3,13): error TS1500: Duplicate regular expression flag. +regularExpressionScanning.ts(3,14): error TS1499: Unknown regular expression flag. +regularExpressionScanning.ts(3,15): error TS1502: The Unicode (u) flag and the Unicode Sets (v) flag cannot be set simultaneously. +regularExpressionScanning.ts(3,16): error TS1501: This regular expression flag is only available when targeting 'es2022' or later. +regularExpressionScanning.ts(3,17): error TS1500: Duplicate regular expression flag. +regularExpressionScanning.ts(3,18): error TS1499: Unknown regular expression flag. +regularExpressionScanning.ts(3,19): error TS1499: Unknown regular expression flag. +regularExpressionScanning.ts(3,20): error TS1499: Unknown regular expression flag. +regularExpressionScanning.ts(3,21): error TS1500: Duplicate regular expression flag. +regularExpressionScanning.ts(3,22): error TS1499: Unknown regular expression flag. +regularExpressionScanning.ts(5,6): error TS1499: Unknown regular expression flag. +regularExpressionScanning.ts(5,7): error TS1509: This regular expression flag cannot be toggled within a subpattern. +regularExpressionScanning.ts(5,10): error TS1509: This regular expression flag cannot be toggled within a subpattern. +regularExpressionScanning.ts(5,11): error TS1500: Duplicate regular expression flag. +regularExpressionScanning.ts(8,4): error TS1534: This backreference refers to a group that does not exist. There are no capturing groups in this regular expression. +regularExpressionScanning.ts(9,4): error TS1534: This backreference refers to a group that does not exist. There are no capturing groups in this regular expression. +regularExpressionScanning.ts(12,9): error TS1533: This backreference refers to a group that does not exist. There are only 4 capturing groups in this regular expression. +regularExpressionScanning.ts(12,24): error TS1536: Octal escape sequences and backreferences are not allowed in a character class. If this was intended as an escape sequence, use the syntax '\x01' instead. +regularExpressionScanning.ts(12,26): error TS1487: Octal escape sequences are not allowed. Use the syntax '\x01'. +regularExpressionScanning.ts(12,29): error TS1536: Octal escape sequences and backreferences are not allowed in a character class. If this was intended as an escape sequence, use the syntax '\x53' instead. +regularExpressionScanning.ts(12,33): error TS1487: Octal escape sequences are not allowed. Use the syntax '\x00'. +regularExpressionScanning.ts(12,36): error TS1537: Decimal escape sequences and backreferences are not allowed in a character class. +regularExpressionScanning.ts(12,42): error TS1487: Octal escape sequences are not allowed. Use the syntax '\x03'. +regularExpressionScanning.ts(12,47): error TS1533: This backreference refers to a group that does not exist. There are only 4 capturing groups in this regular expression. +regularExpressionScanning.ts(12,48): error TS1487: Octal escape sequences are not allowed. Use the syntax '\x05'. +regularExpressionScanning.ts(12,53): error TS1533: This backreference refers to a group that does not exist. There are only 4 capturing groups in this regular expression. +regularExpressionScanning.ts(12,54): error TS1487: Octal escape sequences are not allowed. Use the syntax '\x00'. +regularExpressionScanning.ts(13,9): error TS1533: This backreference refers to a group that does not exist. There are only 4 capturing groups in this regular expression. +regularExpressionScanning.ts(13,24): error TS1536: Octal escape sequences and backreferences are not allowed in a character class. If this was intended as an escape sequence, use the syntax '\x01' instead. +regularExpressionScanning.ts(13,26): error TS1487: Octal escape sequences are not allowed. Use the syntax '\x01'. +regularExpressionScanning.ts(13,29): error TS1536: Octal escape sequences and backreferences are not allowed in a character class. If this was intended as an escape sequence, use the syntax '\x53' instead. +regularExpressionScanning.ts(13,33): error TS1487: Octal escape sequences are not allowed. Use the syntax '\x00'. +regularExpressionScanning.ts(13,36): error TS1537: Decimal escape sequences and backreferences are not allowed in a character class. +regularExpressionScanning.ts(13,42): error TS1487: Octal escape sequences are not allowed. Use the syntax '\x03'. +regularExpressionScanning.ts(13,47): error TS1533: This backreference refers to a group that does not exist. There are only 4 capturing groups in this regular expression. +regularExpressionScanning.ts(13,48): error TS1487: Octal escape sequences are not allowed. Use the syntax '\x05'. +regularExpressionScanning.ts(13,53): error TS1533: This backreference refers to a group that does not exist. There are only 4 capturing groups in this regular expression. +regularExpressionScanning.ts(13,54): error TS1487: Octal escape sequences are not allowed. Use the syntax '\x00'. +regularExpressionScanning.ts(14,5): error TS1503: Named capturing groups are only available when targeting 'ES2018' or later. +regularExpressionScanning.ts(14,14): error TS1503: Named capturing groups are only available when targeting 'ES2018' or later. +regularExpressionScanning.ts(14,29): error TS1503: Named capturing groups are only available when targeting 'ES2018' or later. +regularExpressionScanning.ts(14,45): error TS1503: Named capturing groups are only available when targeting 'ES2018' or later. +regularExpressionScanning.ts(14,57): error TS1503: Named capturing groups are only available when targeting 'ES2018' or later. +regularExpressionScanning.ts(15,15): error TS1532: There is no capturing group named 'absent' in this regular expression. +regularExpressionScanning.ts(15,24): error TS1503: Named capturing groups are only available when targeting 'ES2018' or later. +regularExpressionScanning.ts(15,36): error TS1503: Named capturing groups are only available when targeting 'ES2018' or later. +regularExpressionScanning.ts(15,45): error TS1503: Named capturing groups are only available when targeting 'ES2018' or later. +regularExpressionScanning.ts(15,58): error TS1503: Named capturing groups are only available when targeting 'ES2018' or later. +regularExpressionScanning.ts(15,59): error TS1515: Named capturing groups with the same name must be mutually exclusive to each other. +regularExpressionScanning.ts(17,31): error TS1507: There is nothing available for repetition. +regularExpressionScanning.ts(17,32): error TS1506: Numbers out of order in quantifier. +regularExpressionScanning.ts(17,40): error TS1507: There is nothing available for repetition. +regularExpressionScanning.ts(19,12): error TS1517: Range out of order in character class. +regularExpressionScanning.ts(19,15): error TS1517: Range out of order in character class. +regularExpressionScanning.ts(19,28): error TS1517: Range out of order in character class. +regularExpressionScanning.ts(20,3): error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. +regularExpressionScanning.ts(20,8): error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. +regularExpressionScanning.ts(20,16): error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. +regularExpressionScanning.ts(20,25): error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. +regularExpressionScanning.ts(20,28): error TS1529: Unknown Unicode property name or value. +regularExpressionScanning.ts(20,37): error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. +regularExpressionScanning.ts(20,42): error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. +regularExpressionScanning.ts(20,50): error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. +regularExpressionScanning.ts(20,59): error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. +regularExpressionScanning.ts(20,62): error TS1529: Unknown Unicode property name or value. +regularExpressionScanning.ts(21,28): error TS1529: Unknown Unicode property name or value. +regularExpressionScanning.ts(21,62): error TS1529: Unknown Unicode property name or value. +regularExpressionScanning.ts(22,28): error TS1529: Unknown Unicode property name or value. +regularExpressionScanning.ts(22,62): error TS1529: Unknown Unicode property name or value. +regularExpressionScanning.ts(22,72): error TS1501: This regular expression flag is only available when targeting 'es2024' or later. +regularExpressionScanning.ts(23,3): error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. +regularExpressionScanning.ts(23,6): error TS1524: Unknown Unicode property name. +regularExpressionScanning.ts(23,28): error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. +regularExpressionScanning.ts(23,31): error TS1523: Expected a Unicode property name. +regularExpressionScanning.ts(23,32): error TS1525: Expected a Unicode property value. +regularExpressionScanning.ts(23,33): error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. +regularExpressionScanning.ts(23,39): error TS1525: Expected a Unicode property value. +regularExpressionScanning.ts(23,40): error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. +regularExpressionScanning.ts(23,43): error TS1523: Expected a Unicode property name. +regularExpressionScanning.ts(23,49): error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. +regularExpressionScanning.ts(23,52): error TS1527: Expected a Unicode property name or value. +regularExpressionScanning.ts(23,59): error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. +regularExpressionScanning.ts(23,62): error TS1527: Expected a Unicode property name or value. +regularExpressionScanning.ts(23,63): error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. +regularExpressionScanning.ts(23,66): error TS1527: Expected a Unicode property name or value. +regularExpressionScanning.ts(24,6): error TS1524: Unknown Unicode property name. +regularExpressionScanning.ts(24,31): error TS1523: Expected a Unicode property name. +regularExpressionScanning.ts(24,32): error TS1525: Expected a Unicode property value. +regularExpressionScanning.ts(24,39): error TS1525: Expected a Unicode property value. +regularExpressionScanning.ts(24,43): error TS1523: Expected a Unicode property name. +regularExpressionScanning.ts(24,52): error TS1527: Expected a Unicode property name or value. +regularExpressionScanning.ts(24,53): error TS1531: '\p' must be followed by a Unicode property value expression enclosed in braces. +regularExpressionScanning.ts(24,57): error TS1531: '\P' must be followed by a Unicode property value expression enclosed in braces. +regularExpressionScanning.ts(24,62): error TS1527: Expected a Unicode property name or value. +regularExpressionScanning.ts(24,66): error TS1527: Expected a Unicode property name or value. +regularExpressionScanning.ts(25,6): error TS1524: Unknown Unicode property name. +regularExpressionScanning.ts(25,31): error TS1523: Expected a Unicode property name. +regularExpressionScanning.ts(25,32): error TS1525: Expected a Unicode property value. +regularExpressionScanning.ts(25,39): error TS1525: Expected a Unicode property value. +regularExpressionScanning.ts(25,43): error TS1523: Expected a Unicode property name. +regularExpressionScanning.ts(25,52): error TS1527: Expected a Unicode property name or value. +regularExpressionScanning.ts(25,53): error TS1531: '\p' must be followed by a Unicode property value expression enclosed in braces. +regularExpressionScanning.ts(25,57): error TS1531: '\P' must be followed by a Unicode property value expression enclosed in braces. +regularExpressionScanning.ts(25,62): error TS1527: Expected a Unicode property name or value. +regularExpressionScanning.ts(25,66): error TS1527: Expected a Unicode property name or value. +regularExpressionScanning.ts(25,67): error TS1501: This regular expression flag is only available when targeting 'es2024' or later. +regularExpressionScanning.ts(26,3): error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. +regularExpressionScanning.ts(26,6): error TS1528: Any Unicode property that would possibly match more than a single character is only available when the Unicode Sets (v) flag is set. +regularExpressionScanning.ts(26,16): error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. +regularExpressionScanning.ts(26,19): error TS1528: Any Unicode property that would possibly match more than a single character is only available when the Unicode Sets (v) flag is set. +regularExpressionScanning.ts(26,31): error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. +regularExpressionScanning.ts(26,34): error TS1528: Any Unicode property that would possibly match more than a single character is only available when the Unicode Sets (v) flag is set. +regularExpressionScanning.ts(26,44): error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. +regularExpressionScanning.ts(26,47): error TS1528: Any Unicode property that would possibly match more than a single character is only available when the Unicode Sets (v) flag is set. +regularExpressionScanning.ts(27,6): error TS1528: Any Unicode property that would possibly match more than a single character is only available when the Unicode Sets (v) flag is set. +regularExpressionScanning.ts(27,19): error TS1528: Any Unicode property that would possibly match more than a single character is only available when the Unicode Sets (v) flag is set. +regularExpressionScanning.ts(27,34): error TS1528: Any Unicode property that would possibly match more than a single character is only available when the Unicode Sets (v) flag is set. +regularExpressionScanning.ts(27,47): error TS1528: Any Unicode property that would possibly match more than a single character is only available when the Unicode Sets (v) flag is set. +regularExpressionScanning.ts(28,19): error TS1518: Anything that would possibly match more than a single character is invalid inside a negated character class. +regularExpressionScanning.ts(28,31): error TS1518: Anything that would possibly match more than a single character is invalid inside a negated character class. +regularExpressionScanning.ts(28,47): error TS1518: Anything that would possibly match more than a single character is invalid inside a negated character class. +regularExpressionScanning.ts(28,59): error TS1501: This regular expression flag is only available when targeting 'es2024' or later. +regularExpressionScanning.ts(31,3): error TS1512: '\c' must be followed by an ASCII letter. +regularExpressionScanning.ts(31,6): error TS1512: '\c' must be followed by an ASCII letter. +regularExpressionScanning.ts(31,15): error TS1512: '\c' must be followed by an ASCII letter. +regularExpressionScanning.ts(31,17): error TS1535: This character cannot be escaped in a regular expression. +regularExpressionScanning.ts(31,20): error TS1512: '\c' must be followed by an ASCII letter. +regularExpressionScanning.ts(31,23): error TS1535: This character cannot be escaped in a regular expression. +regularExpressionScanning.ts(33,3): error TS1535: This character cannot be escaped in a regular expression. +regularExpressionScanning.ts(33,7): error TS1535: This character cannot be escaped in a regular expression. +regularExpressionScanning.ts(33,10): error TS1535: This character cannot be escaped in a regular expression. +regularExpressionScanning.ts(33,14): error TS1535: This character cannot be escaped in a regular expression. +regularExpressionScanning.ts(33,17): error TS1535: This character cannot be escaped in a regular expression. +regularExpressionScanning.ts(33,21): error TS1535: This character cannot be escaped in a regular expression. +regularExpressionScanning.ts(33,24): error TS1535: This character cannot be escaped in a regular expression. +regularExpressionScanning.ts(33,39): error TS1535: This character cannot be escaped in a regular expression. +regularExpressionScanning.ts(33,41): error TS1508: Unexpected '{'. Did you mean to escape it with backslash? +regularExpressionScanning.ts(33,42): error TS1508: Unexpected ']'. Did you mean to escape it with backslash? +regularExpressionScanning.ts(33,43): error TS1535: This character cannot be escaped in a regular expression. +regularExpressionScanning.ts(33,45): error TS1508: Unexpected '{'. Did you mean to escape it with backslash? +regularExpressionScanning.ts(34,3): error TS1511: '\q' is only available inside character class. +regularExpressionScanning.ts(34,7): error TS1535: This character cannot be escaped in a regular expression. +regularExpressionScanning.ts(34,10): error TS1521: '\q' must be followed by string alternatives enclosed in braces. +regularExpressionScanning.ts(34,17): error TS1535: This character cannot be escaped in a regular expression. +regularExpressionScanning.ts(34,21): error TS1535: This character cannot be escaped in a regular expression. +regularExpressionScanning.ts(34,23): error TS1508: Unexpected '{'. Did you mean to escape it with backslash? +regularExpressionScanning.ts(34,38): error TS1508: Unexpected ']'. Did you mean to escape it with backslash? +regularExpressionScanning.ts(34,39): error TS1535: This character cannot be escaped in a regular expression. +regularExpressionScanning.ts(34,41): error TS1508: Unexpected '{'. Did you mean to escape it with backslash? +regularExpressionScanning.ts(34,42): error TS1508: Unexpected ']'. Did you mean to escape it with backslash? +regularExpressionScanning.ts(34,43): error TS1535: This character cannot be escaped in a regular expression. +regularExpressionScanning.ts(34,45): error TS1508: Unexpected '{'. Did you mean to escape it with backslash? +regularExpressionScanning.ts(34,46): error TS1005: '}' expected. +regularExpressionScanning.ts(34,47): error TS1501: This regular expression flag is only available when targeting 'es2024' or later. +regularExpressionScanning.ts(36,4): error TS1517: Range out of order in character class. +regularExpressionScanning.ts(36,8): error TS1517: Range out of order in character class. +regularExpressionScanning.ts(36,34): error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. +regularExpressionScanning.ts(36,42): error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. +regularExpressionScanning.ts(36,63): error TS1517: Range out of order in character class. +regularExpressionScanning.ts(37,4): error TS1517: Range out of order in character class. +regularExpressionScanning.ts(37,8): error TS1517: Range out of order in character class. +regularExpressionScanning.ts(37,19): error TS1508: Unexpected ']'. Did you mean to escape it with backslash? +regularExpressionScanning.ts(37,50): error TS1508: Unexpected ']'. Did you mean to escape it with backslash? +regularExpressionScanning.ts(37,51): error TS1508: Unexpected ']'. Did you mean to escape it with backslash? +regularExpressionScanning.ts(37,55): error TS1535: This character cannot be escaped in a regular expression. +regularExpressionScanning.ts(37,57): error TS1508: Unexpected '{'. Did you mean to escape it with backslash? +regularExpressionScanning.ts(37,61): error TS1508: Unexpected '}'. Did you mean to escape it with backslash? +regularExpressionScanning.ts(37,63): error TS1517: Range out of order in character class. +regularExpressionScanning.ts(37,76): error TS1535: This character cannot be escaped in a regular expression. +regularExpressionScanning.ts(38,8): error TS1005: '--' expected. +regularExpressionScanning.ts(38,9): error TS1520: Expected a class set operand. +regularExpressionScanning.ts(38,11): error TS1520: Expected a class set operand. +regularExpressionScanning.ts(38,12): error TS1005: '--' expected. +regularExpressionScanning.ts(38,15): error TS1522: A character class must not contain a reserved double punctuator. Did you mean to escape it with backslash? +regularExpressionScanning.ts(38,20): error TS1519: Operators must not be mixed within a character class. Wrap it in a nested class instead. +regularExpressionScanning.ts(38,28): error TS1519: Operators must not be mixed within a character class. Wrap it in a nested class instead. +regularExpressionScanning.ts(38,40): error TS1519: Operators must not be mixed within a character class. Wrap it in a nested class instead. +regularExpressionScanning.ts(38,47): error TS1519: Operators must not be mixed within a character class. Wrap it in a nested class instead. +regularExpressionScanning.ts(38,49): error TS1519: Operators must not be mixed within a character class. Wrap it in a nested class instead. +regularExpressionScanning.ts(38,50): error TS1520: Expected a class set operand. +regularExpressionScanning.ts(38,55): error TS1511: '\q' is only available inside character class. +regularExpressionScanning.ts(38,57): error TS1508: Unexpected '{'. Did you mean to escape it with backslash? +regularExpressionScanning.ts(38,61): error TS1508: Unexpected '}'. Did you mean to escape it with backslash? +regularExpressionScanning.ts(38,66): error TS1508: Unexpected '-'. Did you mean to escape it with backslash? +regularExpressionScanning.ts(38,67): error TS1005: '--' expected. +regularExpressionScanning.ts(38,70): error TS1520: Expected a class set operand. +regularExpressionScanning.ts(38,75): error TS1508: Unexpected '&'. Did you mean to escape it with backslash? +regularExpressionScanning.ts(38,85): error TS1520: Expected a class set operand. +regularExpressionScanning.ts(38,87): error TS1501: This regular expression flag is only available when targeting 'es2024' or later. +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,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,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,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,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. +regularExpressionScanning.ts(46,5): error TS1518: Anything that would possibly match more than a single character is invalid inside a negated character class. +regularExpressionScanning.ts(46,79): error TS1518: Anything that would possibly match more than a single character is invalid inside a negated character class. +regularExpressionScanning.ts(46,91): error TS1501: This regular expression flag is only available when targeting 'es2024' or later. +regularExpressionScanning.ts(47,5): error TS1518: Anything that would possibly match more than a single character is invalid inside a negated character class. +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(47,101): error TS1501: This regular expression flag is only available when targeting 'es2024' or later. + + +==== regularExpressionScanning.ts (219 errors) ==== + const regexes: RegExp[] = [ + // Flags + /foo/visualstudiocode, + ~ +!!! error TS1501: This regular expression flag is only available when targeting 'es2024' or later. + ~ +!!! error TS1501: This regular expression flag is only available when targeting 'es2018' or later. + ~ +!!! error TS1502: The Unicode (u) flag and the Unicode Sets (v) flag cannot be set simultaneously. + ~ +!!! error TS1499: Unknown regular expression flag. + ~ +!!! error TS1499: Unknown regular expression flag. + ~ +!!! error TS1500: Duplicate regular expression flag. + ~ +!!! error TS1499: Unknown regular expression flag. + ~ +!!! error TS1502: The Unicode (u) flag and the Unicode Sets (v) flag cannot be set simultaneously. + ~ +!!! error TS1501: This regular expression flag is only available when targeting 'es2022' or later. + ~ +!!! error TS1500: Duplicate regular expression flag. + ~ +!!! error TS1499: Unknown regular expression flag. + ~ +!!! error TS1499: Unknown regular expression flag. + ~ +!!! error TS1499: Unknown regular expression flag. + ~ +!!! error TS1500: Duplicate regular expression flag. + ~ +!!! error TS1499: Unknown regular expression flag. + // Pattern modifiers + /(?med-ium:bar)/, + ~ +!!! error TS1499: Unknown regular expression flag. + ~ +!!! error TS1509: This regular expression flag cannot be toggled within a subpattern. + ~ +!!! error TS1509: This regular expression flag cannot be toggled within a subpattern. + ~ +!!! error TS1500: Duplicate regular expression flag. + // Capturing groups + /\0/, + /\1/, + ~ +!!! error TS1534: This backreference refers to a group that does not exist. There are no capturing groups in this regular expression. + /\2/, + ~ +!!! error TS1534: This backreference refers to a group that does not exist. There are no capturing groups in this regular expression. + /(hi)\1/, + /(hi) (hello) \2/, + /\2()(\12)(foo)\1\0[\0\1\01\123\08\8](\3\03)\5\005\9\009/, + ~~ +!!! error TS1533: This backreference refers to a group that does not exist. There are only 4 capturing groups in this regular expression. + ~~ +!!! error TS1536: Octal escape sequences and backreferences are not allowed in a character class. If this was intended as an escape sequence, use the syntax '\x01' instead. + ~~~ +!!! error TS1487: Octal escape sequences are not allowed. Use the syntax '\x01'. + ~~~~ +!!! error TS1536: Octal escape sequences and backreferences are not allowed in a character class. If this was intended as an escape sequence, use the syntax '\x53' instead. + ~~ +!!! error TS1487: Octal escape sequences are not allowed. Use the syntax '\x00'. + ~~ +!!! error TS1537: Decimal escape sequences and backreferences are not allowed in a character class. + ~~~ +!!! error TS1487: Octal escape sequences are not allowed. Use the syntax '\x03'. + ~ +!!! error TS1533: This backreference refers to a group that does not exist. There are only 4 capturing groups in this regular expression. + ~~~~ +!!! error TS1487: Octal escape sequences are not allowed. Use the syntax '\x05'. + ~ +!!! error TS1533: This backreference refers to a group that does not exist. There are only 4 capturing groups in this regular expression. + ~~~ +!!! error TS1487: Octal escape sequences are not allowed. Use the syntax '\x00'. + /\2()(\12)(foo)\1\0[\0\1\01\123\08\8](\3\03)\5\005\9\009/u, + ~~ +!!! error TS1533: This backreference refers to a group that does not exist. There are only 4 capturing groups in this regular expression. + ~~ +!!! error TS1536: Octal escape sequences and backreferences are not allowed in a character class. If this was intended as an escape sequence, use the syntax '\x01' instead. + ~~~ +!!! error TS1487: Octal escape sequences are not allowed. Use the syntax '\x01'. + ~~~~ +!!! error TS1536: Octal escape sequences and backreferences are not allowed in a character class. If this was intended as an escape sequence, use the syntax '\x53' instead. + ~~ +!!! error TS1487: Octal escape sequences are not allowed. Use the syntax '\x00'. + ~~ +!!! error TS1537: Decimal escape sequences and backreferences are not allowed in a character class. + ~~~ +!!! error TS1487: Octal escape sequences are not allowed. Use the syntax '\x03'. + ~ +!!! error TS1533: This backreference refers to a group that does not exist. There are only 4 capturing groups in this regular expression. + ~~~~ +!!! error TS1487: Octal escape sequences are not allowed. Use the syntax '\x05'. + ~ +!!! error TS1533: This backreference refers to a group that does not exist. There are only 4 capturing groups in this regular expression. + ~~~ +!!! error TS1487: Octal escape sequences are not allowed. Use the syntax '\x00'. + /(?)((?bar)bar)(?baz)|(foo(?foo))(?)/, + ~~~~~ +!!! error TS1503: Named capturing groups are only available when targeting 'ES2018' or later. + ~~~~~ +!!! error TS1503: Named capturing groups are only available when targeting 'ES2018' or later. + ~~~~~ +!!! error TS1503: Named capturing groups are only available when targeting 'ES2018' or later. + ~~~~~ +!!! error TS1503: Named capturing groups are only available when targeting 'ES2018' or later. + ~~~~~ +!!! error TS1503: Named capturing groups are only available when targeting 'ES2018' or later. + /(\k)\k(?foo)|(?)((?)|(bar(?bar)))/, + ~~~~~~ +!!! error TS1532: There is no capturing group named 'absent' in this regular expression. + ~~~~~ +!!! error TS1503: Named capturing groups are only available when targeting 'ES2018' or later. + ~~~~~ +!!! error TS1503: Named capturing groups are only available when targeting 'ES2018' or later. + ~~~~~ +!!! error TS1503: Named capturing groups are only available when targeting 'ES2018' or later. + ~~~~~ +!!! error TS1503: Named capturing groups are only available when targeting 'ES2018' or later. + ~~~ +!!! error TS1515: Named capturing groups with the same name must be mutually exclusive to each other. + // Quantifiers + /{}{1,2}_{3}.{4,}?(foo){008}${32,16}\b{064,128}.+&*?\???\n{,256}{\\{,/, + ~~~~~~~ +!!! error TS1507: There is nothing available for repetition. + ~~~~~ +!!! error TS1506: Numbers out of order in quantifier. + ~~~~~~~~~ +!!! error TS1507: There is nothing available for repetition. + // Character classes + /[-A-Za-z-z-aZ-A\d_-\d-.-.\r-\n\w-\W]/, + ~~~ +!!! error TS1517: Range out of order in character class. + ~~~ +!!! error TS1517: Range out of order in character class. + ~~~~~ +!!! error TS1517: Range out of order in character class. + /\p{L}\p{gc=L}\p{ASCII}\p{Invalid}[\p{L}\p{gc=L}\P{ASCII}\p{Invalid}]/, + ~~~~~ +!!! error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. + ~~~~~~~~ +!!! error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. + ~~~~~~~~~ +!!! error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. + ~~~~~~~~~~~ +!!! error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. + ~~~~~~~ +!!! error TS1529: Unknown Unicode property name or value. + ~~~~~ +!!! error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. + ~~~~~~~~ +!!! error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. + ~~~~~~~~~ +!!! error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. + ~~~~~~~~~~~ +!!! error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. + ~~~~~~~ +!!! error TS1529: Unknown Unicode property name or value. + /\p{L}\p{gc=L}\p{ASCII}\p{Invalid}[\p{L}\p{gc=L}\P{ASCII}\p{Invalid}]/u, + ~~~~~~~ +!!! error TS1529: Unknown Unicode property name or value. + ~~~~~~~ +!!! error TS1529: Unknown Unicode property name or value. + /\p{L}\p{gc=L}\p{ASCII}\p{Invalid}[\p{L}\p{gc=L}\P{ASCII}\p{Invalid}]/v, + ~~~~~~~ +!!! error TS1529: Unknown Unicode property name or value. + ~~~~~~~ +!!! error TS1529: Unknown Unicode property name or value. + ~ +!!! error TS1501: This regular expression flag is only available when targeting 'es2024' or later. + /\p{InvalidProperty=Value}\p{=}\p{sc=}\P{=foo}[\p{}\p\\\P\P{]\p{/, + ~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. + ~~~~~~~~~~~~~~~ +!!! error TS1524: Unknown Unicode property name. + ~~~~~ +!!! error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. + +!!! error TS1523: Expected a Unicode property name. + +!!! error TS1525: Expected a Unicode property value. + ~~~~~~~ +!!! error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. + +!!! error TS1525: Expected a Unicode property value. + ~~~~~~~~ +!!! error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. + +!!! error TS1523: Expected a Unicode property name. + ~~~~ +!!! error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. + +!!! error TS1527: Expected a Unicode property name or value. + ~~~ +!!! error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. + +!!! error TS1527: Expected a Unicode property name or value. + ~~~ +!!! error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. + +!!! error TS1527: Expected a Unicode property name or value. + /\p{InvalidProperty=Value}\p{=}\p{sc=}\P{=foo}[\p{}\p\\\P\P{]\p{/u, + ~~~~~~~~~~~~~~~ +!!! error TS1524: Unknown Unicode property name. + +!!! error TS1523: Expected a Unicode property name. + +!!! error TS1525: Expected a Unicode property value. + +!!! error TS1525: Expected a Unicode property value. + +!!! error TS1523: Expected a Unicode property name. + +!!! error TS1527: Expected a Unicode property name or value. + ~~ +!!! error TS1531: '\p' must be followed by a Unicode property value expression enclosed in braces. + ~~ +!!! error TS1531: '\P' must be followed by a Unicode property value expression enclosed in braces. + +!!! error TS1527: Expected a Unicode property name or value. + +!!! error TS1527: Expected a Unicode property name or value. + /\p{InvalidProperty=Value}\p{=}\p{sc=}\P{=foo}[\p{}\p\\\P\P{]\p{/v, + ~~~~~~~~~~~~~~~ +!!! error TS1524: Unknown Unicode property name. + +!!! error TS1523: Expected a Unicode property name. + +!!! error TS1525: Expected a Unicode property value. + +!!! error TS1525: Expected a Unicode property value. + +!!! error TS1523: Expected a Unicode property name. + +!!! error TS1527: Expected a Unicode property name or value. + ~~ +!!! error TS1531: '\p' must be followed by a Unicode property value expression enclosed in braces. + ~~ +!!! error TS1531: '\P' must be followed by a Unicode property value expression enclosed in braces. + +!!! error TS1527: Expected a Unicode property name or value. + +!!! error TS1527: Expected a Unicode property name or value. + ~ +!!! error TS1501: This regular expression flag is only available when targeting 'es2024' or later. + /\p{RGI_Emoji}\P{RGI_Emoji}[^\p{RGI_Emoji}\P{RGI_Emoji}]/, + ~~~~~~~~~~~~~ +!!! error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. + ~~~~~~~~~ +!!! error TS1528: Any Unicode property that would possibly match more than a single character is only available when the Unicode Sets (v) flag is set. + ~~~~~~~~~~~~~ +!!! error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. + ~~~~~~~~~ +!!! error TS1528: Any Unicode property that would possibly match more than a single character is only available when the Unicode Sets (v) flag is set. + ~~~~~~~~~~~~~ +!!! error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. + ~~~~~~~~~ +!!! error TS1528: Any Unicode property that would possibly match more than a single character is only available when the Unicode Sets (v) flag is set. + ~~~~~~~~~~~~~ +!!! error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. + ~~~~~~~~~ +!!! error TS1528: Any Unicode property that would possibly match more than a single character is only available when the Unicode Sets (v) flag is set. + /\p{RGI_Emoji}\P{RGI_Emoji}[^\p{RGI_Emoji}\P{RGI_Emoji}]/u, + ~~~~~~~~~ +!!! error TS1528: Any Unicode property that would possibly match more than a single character is only available when the Unicode Sets (v) flag is set. + ~~~~~~~~~ +!!! error TS1528: Any Unicode property that would possibly match more than a single character is only available when the Unicode Sets (v) flag is set. + ~~~~~~~~~ +!!! error TS1528: Any Unicode property that would possibly match more than a single character is only available when the Unicode Sets (v) flag is set. + ~~~~~~~~~ +!!! error TS1528: Any Unicode property that would possibly match more than a single character is only available when the Unicode Sets (v) flag is set. + /\p{RGI_Emoji}\P{RGI_Emoji}[^\p{RGI_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 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 TS1501: This regular expression flag is only available when targeting 'es2024' or later. + // Character escapes + /\c[\c0\ca\cQ\c\C]\c1\C/, + /\c[\c0\ca\cQ\c\C]\c1\C/u, + ~~ +!!! error TS1512: '\c' must be followed by an ASCII letter. + ~~ +!!! error TS1512: '\c' must be followed by an ASCII letter. + ~~ +!!! error TS1512: '\c' must be followed by an ASCII letter. + ~~ +!!! error TS1535: This character cannot be escaped in a regular expression. + ~~ +!!! error TS1512: '\c' must be followed by an ASCII letter. + ~~ +!!! error TS1535: This character cannot be escaped in a regular expression. + /\q\\\`[\q\\\`[\Q\\\Q{\q{foo|bar|baz]\q{]\q{/, + /\q\\\`[\q\\\`[\Q\\\Q{\q{foo|bar|baz]\q{]\q{/u, + ~~ +!!! error TS1535: This character cannot be escaped in a regular expression. + ~~ +!!! error TS1535: This character cannot be escaped in a regular expression. + ~~ +!!! error TS1535: This character cannot be escaped in a regular expression. + ~~ +!!! error TS1535: This character cannot be escaped in a regular expression. + ~~ +!!! error TS1535: This character cannot be escaped in a regular expression. + ~~ +!!! error TS1535: This character cannot be escaped in a regular expression. + ~~ +!!! error TS1535: This character cannot be escaped in a regular expression. + ~~ +!!! error TS1535: This character cannot be escaped in a regular expression. + ~ +!!! error TS1508: Unexpected '{'. Did you mean to escape it with backslash? + ~ +!!! error TS1508: Unexpected ']'. Did you mean to escape it with backslash? + ~~ +!!! error TS1535: This character cannot be escaped in a regular expression. + ~ +!!! error TS1508: Unexpected '{'. Did you mean to escape it with backslash? + /\q\\\`[\q\\\`[\Q\\\Q{\q{foo|bar|baz]\q{]\q{/v, + ~~ +!!! error TS1511: '\q' is only available inside character class. + ~~ +!!! error TS1535: This character cannot be escaped in a regular expression. + ~~ +!!! error TS1521: '\q' must be followed by string alternatives enclosed in braces. + ~~ +!!! error TS1535: This character cannot be escaped in a regular expression. + ~~ +!!! error TS1535: This character cannot be escaped in a regular expression. + ~ +!!! error TS1508: Unexpected '{'. Did you mean to escape it with backslash? + ~ +!!! error TS1508: Unexpected ']'. Did you mean to escape it with backslash? + ~~ +!!! error TS1535: This character cannot be escaped in a regular expression. + ~ +!!! error TS1508: Unexpected '{'. Did you mean to escape it with backslash? + ~ +!!! error TS1508: Unexpected ']'. Did you mean to escape it with backslash? + ~~ +!!! error TS1535: This character cannot be escaped in a regular expression. + ~ +!!! error TS1508: Unexpected '{'. Did you mean to escape it with backslash? + +!!! error TS1005: '}' expected. + ~ +!!! error TS1501: This regular expression flag is only available when targeting 'es2024' or later. + // Unicode sets notation + /[a--b[--][\d++[]]&&[[&0-9--]&&[\p{L}]--\P{L}-_-]]&&&\q{foo}[0---9][&&q&&&\q{bar}&&]/, + ~~~ +!!! error TS1517: Range out of order in character class. + ~~~ +!!! error TS1517: Range out of order in character class. + ~~~~~ +!!! error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. + ~~~~~ +!!! error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. + ~~~ +!!! error TS1517: Range out of order in character class. + /[a--b[--][\d++[]]&&[[&0-9--]&&[\p{L}]--\P{L}-_-]]&&&\q{foo}[0---9][&&q&&&\q{bar}&&]/u, + ~~~ +!!! error TS1517: Range out of order in character class. + ~~~ +!!! error TS1517: Range out of order in character class. + ~ +!!! error TS1508: Unexpected ']'. Did you mean to escape it with backslash? + ~ +!!! error TS1508: Unexpected ']'. Did you mean to escape it with backslash? + ~ +!!! error TS1508: Unexpected ']'. Did you mean to escape it with backslash? + ~~ +!!! error TS1535: This character cannot be escaped in a regular expression. + ~ +!!! error TS1508: Unexpected '{'. Did you mean to escape it with backslash? + ~ +!!! error TS1508: Unexpected '}'. Did you mean to escape it with backslash? + ~~~ +!!! error TS1517: Range out of order in character class. + ~~ +!!! error TS1535: This character cannot be escaped in a regular expression. + /[a--b[--][\d++[]]&&[[&0-9--]&&[\p{L}]--\P{L}-_-]]&&&\q{foo}[0---9][&&q&&&\q{bar}&&]/v, + +!!! error TS1005: '--' expected. + +!!! error TS1520: Expected a class set operand. + +!!! error TS1520: Expected a class set operand. + +!!! error TS1005: '--' expected. + ~~ +!!! error TS1522: A character class must not contain a reserved double punctuator. Did you mean to escape it with backslash? + ~~ +!!! error TS1519: Operators must not be mixed within a character class. Wrap it in a nested class instead. + ~~ +!!! error TS1519: Operators must not be mixed within a character class. Wrap it in a nested class instead. + ~~ +!!! error TS1519: Operators must not be mixed within a character class. Wrap it in a nested class instead. + ~ +!!! error TS1519: Operators must not be mixed within a character class. Wrap it in a nested class instead. + ~ +!!! error TS1519: Operators must not be mixed within a character class. Wrap it in a nested class instead. + +!!! error TS1520: Expected a class set operand. + ~~ +!!! error TS1511: '\q' is only available inside character class. + ~ +!!! error TS1508: Unexpected '{'. Did you mean to escape it with backslash? + ~ +!!! error TS1508: Unexpected '}'. Did you mean to escape it with backslash? + ~ +!!! error TS1508: Unexpected '-'. Did you mean to escape it with backslash? + +!!! error TS1005: '--' expected. + +!!! error TS1520: Expected a class set operand. + ~ +!!! error TS1508: Unexpected '&'. Did you mean to escape it with backslash? + +!!! error TS1520: Expected a class set operand. + ~ +!!! error TS1501: This regular expression flag is only available when targeting 'es2024' or later. + /[[^\P{Decimal_Number}&&[0-9]]&&\p{L}&&\p{ID_Continue}--\p{ASCII}\p{CWCF}]/v, + ~~ +!!! error TS1519: Operators must not be mixed within a character class. Wrap it in a nested class instead. + +!!! error TS1005: '&&' expected. + ~ +!!! 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 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, + ~~~~~~~~~~~~~ +!!! 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 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. + ~ +!!! 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 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, + ~~~~~~~~~~~~~~~~~ +!!! 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 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. + ~ +!!! error TS1501: This regular expression flag is only available when targeting 'es2024' or later. + /[^\q{foo|bar|baz}--\q{foo}--\q{bar}--\q{baz}][^\p{L}--\q{foo}--[\q{bar}]--[^[\q{baz}]]]/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 TS1501: This regular expression flag is only available when targeting 'es2024' or later. + /[^[[\q{foo|bar|baz}]]--\q{foo}--\q{bar}--\q{baz}][^[^[^\p{L}]]--\q{foo}--[\q{bar}]--[^[\q{baz}]]]/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 TS1501: This regular expression flag is only available when targeting 'es2024' or later. + ]; + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/regularExpressionScanning(target=es5).errors.txt.diff b/testdata/baselines/reference/submodule/compiler/regularExpressionScanning(target=es5).errors.txt.diff deleted file mode 100644 index b91bf47cf6..0000000000 --- a/testdata/baselines/reference/submodule/compiler/regularExpressionScanning(target=es5).errors.txt.diff +++ /dev/null @@ -1,713 +0,0 @@ ---- old.regularExpressionScanning(target=es5).errors.txt -+++ new.regularExpressionScanning(target=es5).errors.txt -@@= skipped -0, +0 lines =@@ --regularExpressionScanning.ts(3,7): error TS1501: This regular expression flag is only available when targeting 'es2024' or later. --regularExpressionScanning.ts(3,9): error TS1501: This regular expression flag is only available when targeting 'es2018' or later. --regularExpressionScanning.ts(3,10): error TS1502: The Unicode (u) flag and the Unicode Sets (v) flag cannot be set simultaneously. --regularExpressionScanning.ts(3,11): error TS1499: Unknown regular expression flag. --regularExpressionScanning.ts(3,12): error TS1499: Unknown regular expression flag. --regularExpressionScanning.ts(3,13): error TS1500: Duplicate regular expression flag. --regularExpressionScanning.ts(3,14): error TS1499: Unknown regular expression flag. --regularExpressionScanning.ts(3,15): error TS1502: The Unicode (u) flag and the Unicode Sets (v) flag cannot be set simultaneously. --regularExpressionScanning.ts(3,16): error TS1501: This regular expression flag is only available when targeting 'es2022' or later. --regularExpressionScanning.ts(3,17): error TS1500: Duplicate regular expression flag. --regularExpressionScanning.ts(3,18): error TS1499: Unknown regular expression flag. --regularExpressionScanning.ts(3,19): error TS1499: Unknown regular expression flag. --regularExpressionScanning.ts(3,20): error TS1499: Unknown regular expression flag. --regularExpressionScanning.ts(3,21): error TS1500: Duplicate regular expression flag. --regularExpressionScanning.ts(3,22): error TS1499: Unknown regular expression flag. --regularExpressionScanning.ts(5,6): error TS1499: Unknown regular expression flag. --regularExpressionScanning.ts(5,7): error TS1509: This regular expression flag cannot be toggled within a subpattern. --regularExpressionScanning.ts(5,10): error TS1509: This regular expression flag cannot be toggled within a subpattern. --regularExpressionScanning.ts(5,11): error TS1500: Duplicate regular expression flag. --regularExpressionScanning.ts(8,4): error TS1534: This backreference refers to a group that does not exist. There are no capturing groups in this regular expression. --regularExpressionScanning.ts(9,4): error TS1534: This backreference refers to a group that does not exist. There are no capturing groups in this regular expression. --regularExpressionScanning.ts(12,9): error TS1533: This backreference refers to a group that does not exist. There are only 4 capturing groups in this regular expression. --regularExpressionScanning.ts(12,24): error TS1536: Octal escape sequences and backreferences are not allowed in a character class. If this was intended as an escape sequence, use the syntax '\x01' instead. --regularExpressionScanning.ts(12,26): error TS1487: Octal escape sequences are not allowed. Use the syntax '\x01'. --regularExpressionScanning.ts(12,29): error TS1536: Octal escape sequences and backreferences are not allowed in a character class. If this was intended as an escape sequence, use the syntax '\x53' instead. --regularExpressionScanning.ts(12,33): error TS1487: Octal escape sequences are not allowed. Use the syntax '\x00'. --regularExpressionScanning.ts(12,36): error TS1537: Decimal escape sequences and backreferences are not allowed in a character class. --regularExpressionScanning.ts(12,42): error TS1487: Octal escape sequences are not allowed. Use the syntax '\x03'. --regularExpressionScanning.ts(12,47): error TS1533: This backreference refers to a group that does not exist. There are only 4 capturing groups in this regular expression. --regularExpressionScanning.ts(12,48): error TS1487: Octal escape sequences are not allowed. Use the syntax '\x05'. --regularExpressionScanning.ts(12,53): error TS1533: This backreference refers to a group that does not exist. There are only 4 capturing groups in this regular expression. --regularExpressionScanning.ts(12,54): error TS1487: Octal escape sequences are not allowed. Use the syntax '\x00'. --regularExpressionScanning.ts(13,9): error TS1533: This backreference refers to a group that does not exist. There are only 4 capturing groups in this regular expression. --regularExpressionScanning.ts(13,24): error TS1536: Octal escape sequences and backreferences are not allowed in a character class. If this was intended as an escape sequence, use the syntax '\x01' instead. --regularExpressionScanning.ts(13,26): error TS1487: Octal escape sequences are not allowed. Use the syntax '\x01'. --regularExpressionScanning.ts(13,29): error TS1536: Octal escape sequences and backreferences are not allowed in a character class. If this was intended as an escape sequence, use the syntax '\x53' instead. --regularExpressionScanning.ts(13,33): error TS1487: Octal escape sequences are not allowed. Use the syntax '\x00'. --regularExpressionScanning.ts(13,36): error TS1537: Decimal escape sequences and backreferences are not allowed in a character class. --regularExpressionScanning.ts(13,42): error TS1487: Octal escape sequences are not allowed. Use the syntax '\x03'. --regularExpressionScanning.ts(13,47): error TS1533: This backreference refers to a group that does not exist. There are only 4 capturing groups in this regular expression. --regularExpressionScanning.ts(13,48): error TS1487: Octal escape sequences are not allowed. Use the syntax '\x05'. --regularExpressionScanning.ts(13,53): error TS1533: This backreference refers to a group that does not exist. There are only 4 capturing groups in this regular expression. --regularExpressionScanning.ts(13,54): error TS1487: Octal escape sequences are not allowed. Use the syntax '\x00'. --regularExpressionScanning.ts(14,5): error TS1503: Named capturing groups are only available when targeting 'ES2018' or later. --regularExpressionScanning.ts(14,14): error TS1503: Named capturing groups are only available when targeting 'ES2018' or later. --regularExpressionScanning.ts(14,29): error TS1503: Named capturing groups are only available when targeting 'ES2018' or later. --regularExpressionScanning.ts(14,45): error TS1503: Named capturing groups are only available when targeting 'ES2018' or later. --regularExpressionScanning.ts(14,57): error TS1503: Named capturing groups are only available when targeting 'ES2018' or later. --regularExpressionScanning.ts(15,15): error TS1532: There is no capturing group named 'absent' in this regular expression. --regularExpressionScanning.ts(15,24): error TS1503: Named capturing groups are only available when targeting 'ES2018' or later. --regularExpressionScanning.ts(15,36): error TS1503: Named capturing groups are only available when targeting 'ES2018' or later. --regularExpressionScanning.ts(15,45): error TS1503: Named capturing groups are only available when targeting 'ES2018' or later. --regularExpressionScanning.ts(15,58): error TS1503: Named capturing groups are only available when targeting 'ES2018' or later. --regularExpressionScanning.ts(15,59): error TS1515: Named capturing groups with the same name must be mutually exclusive to each other. --regularExpressionScanning.ts(17,31): error TS1507: There is nothing available for repetition. --regularExpressionScanning.ts(17,32): error TS1506: Numbers out of order in quantifier. --regularExpressionScanning.ts(17,40): error TS1507: There is nothing available for repetition. --regularExpressionScanning.ts(19,12): error TS1517: Range out of order in character class. --regularExpressionScanning.ts(19,15): error TS1517: Range out of order in character class. --regularExpressionScanning.ts(19,28): error TS1517: Range out of order in character class. --regularExpressionScanning.ts(20,3): error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. --regularExpressionScanning.ts(20,8): error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. --regularExpressionScanning.ts(20,16): error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. --regularExpressionScanning.ts(20,25): error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. --regularExpressionScanning.ts(20,28): error TS1529: Unknown Unicode property name or value. --regularExpressionScanning.ts(20,37): error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. --regularExpressionScanning.ts(20,42): error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. --regularExpressionScanning.ts(20,50): error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. --regularExpressionScanning.ts(20,59): error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. --regularExpressionScanning.ts(20,62): error TS1529: Unknown Unicode property name or value. --regularExpressionScanning.ts(21,28): error TS1529: Unknown Unicode property name or value. --regularExpressionScanning.ts(21,62): error TS1529: Unknown Unicode property name or value. --regularExpressionScanning.ts(22,28): error TS1529: Unknown Unicode property name or value. --regularExpressionScanning.ts(22,62): error TS1529: Unknown Unicode property name or value. --regularExpressionScanning.ts(22,72): error TS1501: This regular expression flag is only available when targeting 'es2024' or later. --regularExpressionScanning.ts(23,3): error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. --regularExpressionScanning.ts(23,6): error TS1524: Unknown Unicode property name. --regularExpressionScanning.ts(23,28): error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. --regularExpressionScanning.ts(23,31): error TS1523: Expected a Unicode property name. --regularExpressionScanning.ts(23,32): error TS1525: Expected a Unicode property value. --regularExpressionScanning.ts(23,33): error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. --regularExpressionScanning.ts(23,39): error TS1525: Expected a Unicode property value. --regularExpressionScanning.ts(23,40): error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. --regularExpressionScanning.ts(23,43): error TS1523: Expected a Unicode property name. --regularExpressionScanning.ts(23,49): error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. --regularExpressionScanning.ts(23,52): error TS1527: Expected a Unicode property name or value. --regularExpressionScanning.ts(23,59): error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. --regularExpressionScanning.ts(23,62): error TS1527: Expected a Unicode property name or value. --regularExpressionScanning.ts(23,63): error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. --regularExpressionScanning.ts(23,66): error TS1527: Expected a Unicode property name or value. --regularExpressionScanning.ts(24,6): error TS1524: Unknown Unicode property name. --regularExpressionScanning.ts(24,31): error TS1523: Expected a Unicode property name. --regularExpressionScanning.ts(24,32): error TS1525: Expected a Unicode property value. --regularExpressionScanning.ts(24,39): error TS1525: Expected a Unicode property value. --regularExpressionScanning.ts(24,43): error TS1523: Expected a Unicode property name. --regularExpressionScanning.ts(24,52): error TS1527: Expected a Unicode property name or value. --regularExpressionScanning.ts(24,53): error TS1531: '\p' must be followed by a Unicode property value expression enclosed in braces. --regularExpressionScanning.ts(24,57): error TS1531: '\P' must be followed by a Unicode property value expression enclosed in braces. --regularExpressionScanning.ts(24,62): error TS1527: Expected a Unicode property name or value. --regularExpressionScanning.ts(24,66): error TS1527: Expected a Unicode property name or value. --regularExpressionScanning.ts(25,6): error TS1524: Unknown Unicode property name. --regularExpressionScanning.ts(25,31): error TS1523: Expected a Unicode property name. --regularExpressionScanning.ts(25,32): error TS1525: Expected a Unicode property value. --regularExpressionScanning.ts(25,39): error TS1525: Expected a Unicode property value. --regularExpressionScanning.ts(25,43): error TS1523: Expected a Unicode property name. --regularExpressionScanning.ts(25,52): error TS1527: Expected a Unicode property name or value. --regularExpressionScanning.ts(25,53): error TS1531: '\p' must be followed by a Unicode property value expression enclosed in braces. --regularExpressionScanning.ts(25,57): error TS1531: '\P' must be followed by a Unicode property value expression enclosed in braces. --regularExpressionScanning.ts(25,62): error TS1527: Expected a Unicode property name or value. --regularExpressionScanning.ts(25,66): error TS1527: Expected a Unicode property name or value. --regularExpressionScanning.ts(25,67): error TS1501: This regular expression flag is only available when targeting 'es2024' or later. --regularExpressionScanning.ts(26,3): error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. --regularExpressionScanning.ts(26,6): error TS1528: Any Unicode property that would possibly match more than a single character is only available when the Unicode Sets (v) flag is set. --regularExpressionScanning.ts(26,16): error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. --regularExpressionScanning.ts(26,19): error TS1528: Any Unicode property that would possibly match more than a single character is only available when the Unicode Sets (v) flag is set. --regularExpressionScanning.ts(26,31): error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. --regularExpressionScanning.ts(26,34): error TS1528: Any Unicode property that would possibly match more than a single character is only available when the Unicode Sets (v) flag is set. --regularExpressionScanning.ts(26,44): error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. --regularExpressionScanning.ts(26,47): error TS1528: Any Unicode property that would possibly match more than a single character is only available when the Unicode Sets (v) flag is set. --regularExpressionScanning.ts(27,6): error TS1528: Any Unicode property that would possibly match more than a single character is only available when the Unicode Sets (v) flag is set. --regularExpressionScanning.ts(27,19): error TS1528: Any Unicode property that would possibly match more than a single character is only available when the Unicode Sets (v) flag is set. --regularExpressionScanning.ts(27,34): error TS1528: Any Unicode property that would possibly match more than a single character is only available when the Unicode Sets (v) flag is set. --regularExpressionScanning.ts(27,47): error TS1528: Any Unicode property that would possibly match more than a single character is only available when the Unicode Sets (v) flag is set. --regularExpressionScanning.ts(28,19): error TS1518: Anything that would possibly match more than a single character is invalid inside a negated character class. --regularExpressionScanning.ts(28,31): error TS1518: Anything that would possibly match more than a single character is invalid inside a negated character class. --regularExpressionScanning.ts(28,47): error TS1518: Anything that would possibly match more than a single character is invalid inside a negated character class. --regularExpressionScanning.ts(28,59): error TS1501: This regular expression flag is only available when targeting 'es2024' or later. --regularExpressionScanning.ts(31,3): error TS1512: '\c' must be followed by an ASCII letter. --regularExpressionScanning.ts(31,6): error TS1512: '\c' must be followed by an ASCII letter. --regularExpressionScanning.ts(31,15): error TS1512: '\c' must be followed by an ASCII letter. --regularExpressionScanning.ts(31,17): error TS1535: This character cannot be escaped in a regular expression. --regularExpressionScanning.ts(31,20): error TS1512: '\c' must be followed by an ASCII letter. --regularExpressionScanning.ts(31,23): error TS1535: This character cannot be escaped in a regular expression. --regularExpressionScanning.ts(33,3): error TS1535: This character cannot be escaped in a regular expression. --regularExpressionScanning.ts(33,7): error TS1535: This character cannot be escaped in a regular expression. --regularExpressionScanning.ts(33,10): error TS1535: This character cannot be escaped in a regular expression. --regularExpressionScanning.ts(33,14): error TS1535: This character cannot be escaped in a regular expression. --regularExpressionScanning.ts(33,17): error TS1535: This character cannot be escaped in a regular expression. --regularExpressionScanning.ts(33,21): error TS1535: This character cannot be escaped in a regular expression. --regularExpressionScanning.ts(33,24): error TS1535: This character cannot be escaped in a regular expression. --regularExpressionScanning.ts(33,39): error TS1535: This character cannot be escaped in a regular expression. --regularExpressionScanning.ts(33,41): error TS1508: Unexpected '{'. Did you mean to escape it with backslash? --regularExpressionScanning.ts(33,42): error TS1508: Unexpected ']'. Did you mean to escape it with backslash? --regularExpressionScanning.ts(33,43): error TS1535: This character cannot be escaped in a regular expression. --regularExpressionScanning.ts(33,45): error TS1508: Unexpected '{'. Did you mean to escape it with backslash? --regularExpressionScanning.ts(34,3): error TS1511: '\q' is only available inside character class. --regularExpressionScanning.ts(34,7): error TS1535: This character cannot be escaped in a regular expression. --regularExpressionScanning.ts(34,10): error TS1521: '\q' must be followed by string alternatives enclosed in braces. --regularExpressionScanning.ts(34,17): error TS1535: This character cannot be escaped in a regular expression. --regularExpressionScanning.ts(34,21): error TS1535: This character cannot be escaped in a regular expression. --regularExpressionScanning.ts(34,23): error TS1508: Unexpected '{'. Did you mean to escape it with backslash? --regularExpressionScanning.ts(34,38): error TS1508: Unexpected ']'. Did you mean to escape it with backslash? --regularExpressionScanning.ts(34,39): error TS1535: This character cannot be escaped in a regular expression. --regularExpressionScanning.ts(34,41): error TS1508: Unexpected '{'. Did you mean to escape it with backslash? --regularExpressionScanning.ts(34,42): error TS1508: Unexpected ']'. Did you mean to escape it with backslash? --regularExpressionScanning.ts(34,43): error TS1535: This character cannot be escaped in a regular expression. --regularExpressionScanning.ts(34,45): error TS1508: Unexpected '{'. Did you mean to escape it with backslash? --regularExpressionScanning.ts(34,46): error TS1005: '}' expected. --regularExpressionScanning.ts(34,47): error TS1501: This regular expression flag is only available when targeting 'es2024' or later. --regularExpressionScanning.ts(36,4): error TS1517: Range out of order in character class. --regularExpressionScanning.ts(36,8): error TS1517: Range out of order in character class. --regularExpressionScanning.ts(36,34): error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. --regularExpressionScanning.ts(36,42): error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. --regularExpressionScanning.ts(36,63): error TS1517: Range out of order in character class. --regularExpressionScanning.ts(37,4): error TS1517: Range out of order in character class. --regularExpressionScanning.ts(37,8): error TS1517: Range out of order in character class. --regularExpressionScanning.ts(37,19): error TS1508: Unexpected ']'. Did you mean to escape it with backslash? --regularExpressionScanning.ts(37,50): error TS1508: Unexpected ']'. Did you mean to escape it with backslash? --regularExpressionScanning.ts(37,51): error TS1508: Unexpected ']'. Did you mean to escape it with backslash? --regularExpressionScanning.ts(37,55): error TS1535: This character cannot be escaped in a regular expression. --regularExpressionScanning.ts(37,57): error TS1508: Unexpected '{'. Did you mean to escape it with backslash? --regularExpressionScanning.ts(37,61): error TS1508: Unexpected '}'. Did you mean to escape it with backslash? --regularExpressionScanning.ts(37,63): error TS1517: Range out of order in character class. --regularExpressionScanning.ts(37,76): error TS1535: This character cannot be escaped in a regular expression. --regularExpressionScanning.ts(38,8): error TS1005: '--' expected. --regularExpressionScanning.ts(38,9): error TS1520: Expected a class set operand. --regularExpressionScanning.ts(38,11): error TS1520: Expected a class set operand. --regularExpressionScanning.ts(38,12): error TS1005: '--' expected. --regularExpressionScanning.ts(38,15): error TS1522: A character class must not contain a reserved double punctuator. Did you mean to escape it with backslash? --regularExpressionScanning.ts(38,20): error TS1519: Operators must not be mixed within a character class. Wrap it in a nested class instead. --regularExpressionScanning.ts(38,28): error TS1519: Operators must not be mixed within a character class. Wrap it in a nested class instead. --regularExpressionScanning.ts(38,40): error TS1519: Operators must not be mixed within a character class. Wrap it in a nested class instead. --regularExpressionScanning.ts(38,47): error TS1519: Operators must not be mixed within a character class. Wrap it in a nested class instead. --regularExpressionScanning.ts(38,49): error TS1519: Operators must not be mixed within a character class. Wrap it in a nested class instead. --regularExpressionScanning.ts(38,50): error TS1520: Expected a class set operand. --regularExpressionScanning.ts(38,55): error TS1511: '\q' is only available inside character class. --regularExpressionScanning.ts(38,57): error TS1508: Unexpected '{'. Did you mean to escape it with backslash? --regularExpressionScanning.ts(38,61): error TS1508: Unexpected '}'. Did you mean to escape it with backslash? --regularExpressionScanning.ts(38,66): error TS1508: Unexpected '-'. Did you mean to escape it with backslash? --regularExpressionScanning.ts(38,67): error TS1005: '--' expected. --regularExpressionScanning.ts(38,70): error TS1520: Expected a class set operand. --regularExpressionScanning.ts(38,75): error TS1508: Unexpected '&'. Did you mean to escape it with backslash? --regularExpressionScanning.ts(38,85): error TS1520: Expected a class set operand. --regularExpressionScanning.ts(38,87): error TS1501: This regular expression flag is only available when targeting 'es2024' or later. --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,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,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,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,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. --regularExpressionScanning.ts(46,5): error TS1518: Anything that would possibly match more than a single character is invalid inside a negated character class. --regularExpressionScanning.ts(46,79): error TS1518: Anything that would possibly match more than a single character is invalid inside a negated character class. --regularExpressionScanning.ts(46,91): error TS1501: This regular expression flag is only available when targeting 'es2024' or later. --regularExpressionScanning.ts(47,5): error TS1518: Anything that would possibly match more than a single character is invalid inside a negated character class. --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(47,101): error TS1501: This regular expression flag is only available when targeting 'es2024' or later. -- -- --==== regularExpressionScanning.ts (219 errors) ==== -- const regexes: RegExp[] = [ -- // Flags -- /foo/visualstudiocode, -- ~ --!!! error TS1501: This regular expression flag is only available when targeting 'es2024' or later. -- ~ --!!! error TS1501: This regular expression flag is only available when targeting 'es2018' or later. -- ~ --!!! error TS1502: The Unicode (u) flag and the Unicode Sets (v) flag cannot be set simultaneously. -- ~ --!!! error TS1499: Unknown regular expression flag. -- ~ --!!! error TS1499: Unknown regular expression flag. -- ~ --!!! error TS1500: Duplicate regular expression flag. -- ~ --!!! error TS1499: Unknown regular expression flag. -- ~ --!!! error TS1502: The Unicode (u) flag and the Unicode Sets (v) flag cannot be set simultaneously. -- ~ --!!! error TS1501: This regular expression flag is only available when targeting 'es2022' or later. -- ~ --!!! error TS1500: Duplicate regular expression flag. -- ~ --!!! error TS1499: Unknown regular expression flag. -- ~ --!!! error TS1499: Unknown regular expression flag. -- ~ --!!! error TS1499: Unknown regular expression flag. -- ~ --!!! error TS1500: Duplicate regular expression flag. -- ~ --!!! error TS1499: Unknown regular expression flag. -- // Pattern modifiers -- /(?med-ium:bar)/, -- ~ --!!! error TS1499: Unknown regular expression flag. -- ~ --!!! error TS1509: This regular expression flag cannot be toggled within a subpattern. -- ~ --!!! error TS1509: This regular expression flag cannot be toggled within a subpattern. -- ~ --!!! error TS1500: Duplicate regular expression flag. -- // Capturing groups -- /\0/, -- /\1/, -- ~ --!!! error TS1534: This backreference refers to a group that does not exist. There are no capturing groups in this regular expression. -- /\2/, -- ~ --!!! error TS1534: This backreference refers to a group that does not exist. There are no capturing groups in this regular expression. -- /(hi)\1/, -- /(hi) (hello) \2/, -- /\2()(\12)(foo)\1\0[\0\1\01\123\08\8](\3\03)\5\005\9\009/, -- ~~ --!!! error TS1533: This backreference refers to a group that does not exist. There are only 4 capturing groups in this regular expression. -- ~~ --!!! error TS1536: Octal escape sequences and backreferences are not allowed in a character class. If this was intended as an escape sequence, use the syntax '\x01' instead. -- ~~~ --!!! error TS1487: Octal escape sequences are not allowed. Use the syntax '\x01'. -- ~~~~ --!!! error TS1536: Octal escape sequences and backreferences are not allowed in a character class. If this was intended as an escape sequence, use the syntax '\x53' instead. -- ~~ --!!! error TS1487: Octal escape sequences are not allowed. Use the syntax '\x00'. -- ~~ --!!! error TS1537: Decimal escape sequences and backreferences are not allowed in a character class. -- ~~~ --!!! error TS1487: Octal escape sequences are not allowed. Use the syntax '\x03'. -- ~ --!!! error TS1533: This backreference refers to a group that does not exist. There are only 4 capturing groups in this regular expression. -- ~~~~ --!!! error TS1487: Octal escape sequences are not allowed. Use the syntax '\x05'. -- ~ --!!! error TS1533: This backreference refers to a group that does not exist. There are only 4 capturing groups in this regular expression. -- ~~~ --!!! error TS1487: Octal escape sequences are not allowed. Use the syntax '\x00'. -- /\2()(\12)(foo)\1\0[\0\1\01\123\08\8](\3\03)\5\005\9\009/u, -- ~~ --!!! error TS1533: This backreference refers to a group that does not exist. There are only 4 capturing groups in this regular expression. -- ~~ --!!! error TS1536: Octal escape sequences and backreferences are not allowed in a character class. If this was intended as an escape sequence, use the syntax '\x01' instead. -- ~~~ --!!! error TS1487: Octal escape sequences are not allowed. Use the syntax '\x01'. -- ~~~~ --!!! error TS1536: Octal escape sequences and backreferences are not allowed in a character class. If this was intended as an escape sequence, use the syntax '\x53' instead. -- ~~ --!!! error TS1487: Octal escape sequences are not allowed. Use the syntax '\x00'. -- ~~ --!!! error TS1537: Decimal escape sequences and backreferences are not allowed in a character class. -- ~~~ --!!! error TS1487: Octal escape sequences are not allowed. Use the syntax '\x03'. -- ~ --!!! error TS1533: This backreference refers to a group that does not exist. There are only 4 capturing groups in this regular expression. -- ~~~~ --!!! error TS1487: Octal escape sequences are not allowed. Use the syntax '\x05'. -- ~ --!!! error TS1533: This backreference refers to a group that does not exist. There are only 4 capturing groups in this regular expression. -- ~~~ --!!! error TS1487: Octal escape sequences are not allowed. Use the syntax '\x00'. -- /(?)((?bar)bar)(?baz)|(foo(?foo))(?)/, -- ~~~~~ --!!! error TS1503: Named capturing groups are only available when targeting 'ES2018' or later. -- ~~~~~ --!!! error TS1503: Named capturing groups are only available when targeting 'ES2018' or later. -- ~~~~~ --!!! error TS1503: Named capturing groups are only available when targeting 'ES2018' or later. -- ~~~~~ --!!! error TS1503: Named capturing groups are only available when targeting 'ES2018' or later. -- ~~~~~ --!!! error TS1503: Named capturing groups are only available when targeting 'ES2018' or later. -- /(\k)\k(?foo)|(?)((?)|(bar(?bar)))/, -- ~~~~~~ --!!! error TS1532: There is no capturing group named 'absent' in this regular expression. -- ~~~~~ --!!! error TS1503: Named capturing groups are only available when targeting 'ES2018' or later. -- ~~~~~ --!!! error TS1503: Named capturing groups are only available when targeting 'ES2018' or later. -- ~~~~~ --!!! error TS1503: Named capturing groups are only available when targeting 'ES2018' or later. -- ~~~~~ --!!! error TS1503: Named capturing groups are only available when targeting 'ES2018' or later. -- ~~~ --!!! error TS1515: Named capturing groups with the same name must be mutually exclusive to each other. -- // Quantifiers -- /{}{1,2}_{3}.{4,}?(foo){008}${32,16}\b{064,128}.+&*?\???\n{,256}{\\{,/, -- ~~~~~~~ --!!! error TS1507: There is nothing available for repetition. -- ~~~~~ --!!! error TS1506: Numbers out of order in quantifier. -- ~~~~~~~~~ --!!! error TS1507: There is nothing available for repetition. -- // Character classes -- /[-A-Za-z-z-aZ-A\d_-\d-.-.\r-\n\w-\W]/, -- ~~~ --!!! error TS1517: Range out of order in character class. -- ~~~ --!!! error TS1517: Range out of order in character class. -- ~~~~~ --!!! error TS1517: Range out of order in character class. -- /\p{L}\p{gc=L}\p{ASCII}\p{Invalid}[\p{L}\p{gc=L}\P{ASCII}\p{Invalid}]/, -- ~~~~~ --!!! error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. -- ~~~~~~~~ --!!! error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. -- ~~~~~~~~~ --!!! error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. -- ~~~~~~~~~~~ --!!! error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. -- ~~~~~~~ --!!! error TS1529: Unknown Unicode property name or value. -- ~~~~~ --!!! error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. -- ~~~~~~~~ --!!! error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. -- ~~~~~~~~~ --!!! error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. -- ~~~~~~~~~~~ --!!! error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. -- ~~~~~~~ --!!! error TS1529: Unknown Unicode property name or value. -- /\p{L}\p{gc=L}\p{ASCII}\p{Invalid}[\p{L}\p{gc=L}\P{ASCII}\p{Invalid}]/u, -- ~~~~~~~ --!!! error TS1529: Unknown Unicode property name or value. -- ~~~~~~~ --!!! error TS1529: Unknown Unicode property name or value. -- /\p{L}\p{gc=L}\p{ASCII}\p{Invalid}[\p{L}\p{gc=L}\P{ASCII}\p{Invalid}]/v, -- ~~~~~~~ --!!! error TS1529: Unknown Unicode property name or value. -- ~~~~~~~ --!!! error TS1529: Unknown Unicode property name or value. -- ~ --!!! error TS1501: This regular expression flag is only available when targeting 'es2024' or later. -- /\p{InvalidProperty=Value}\p{=}\p{sc=}\P{=foo}[\p{}\p\\\P\P{]\p{/, -- ~~~~~~~~~~~~~~~~~~~~~~~~~ --!!! error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. -- ~~~~~~~~~~~~~~~ --!!! error TS1524: Unknown Unicode property name. -- ~~~~~ --!!! error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. -- --!!! error TS1523: Expected a Unicode property name. -- --!!! error TS1525: Expected a Unicode property value. -- ~~~~~~~ --!!! error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. -- --!!! error TS1525: Expected a Unicode property value. -- ~~~~~~~~ --!!! error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. -- --!!! error TS1523: Expected a Unicode property name. -- ~~~~ --!!! error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. -- --!!! error TS1527: Expected a Unicode property name or value. -- ~~~ --!!! error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. -- --!!! error TS1527: Expected a Unicode property name or value. -- ~~~ --!!! error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. -- --!!! error TS1527: Expected a Unicode property name or value. -- /\p{InvalidProperty=Value}\p{=}\p{sc=}\P{=foo}[\p{}\p\\\P\P{]\p{/u, -- ~~~~~~~~~~~~~~~ --!!! error TS1524: Unknown Unicode property name. -- --!!! error TS1523: Expected a Unicode property name. -- --!!! error TS1525: Expected a Unicode property value. -- --!!! error TS1525: Expected a Unicode property value. -- --!!! error TS1523: Expected a Unicode property name. -- --!!! error TS1527: Expected a Unicode property name or value. -- ~~ --!!! error TS1531: '\p' must be followed by a Unicode property value expression enclosed in braces. -- ~~ --!!! error TS1531: '\P' must be followed by a Unicode property value expression enclosed in braces. -- --!!! error TS1527: Expected a Unicode property name or value. -- --!!! error TS1527: Expected a Unicode property name or value. -- /\p{InvalidProperty=Value}\p{=}\p{sc=}\P{=foo}[\p{}\p\\\P\P{]\p{/v, -- ~~~~~~~~~~~~~~~ --!!! error TS1524: Unknown Unicode property name. -- --!!! error TS1523: Expected a Unicode property name. -- --!!! error TS1525: Expected a Unicode property value. -- --!!! error TS1525: Expected a Unicode property value. -- --!!! error TS1523: Expected a Unicode property name. -- --!!! error TS1527: Expected a Unicode property name or value. -- ~~ --!!! error TS1531: '\p' must be followed by a Unicode property value expression enclosed in braces. -- ~~ --!!! error TS1531: '\P' must be followed by a Unicode property value expression enclosed in braces. -- --!!! error TS1527: Expected a Unicode property name or value. -- --!!! error TS1527: Expected a Unicode property name or value. -- ~ --!!! error TS1501: This regular expression flag is only available when targeting 'es2024' or later. -- /\p{RGI_Emoji}\P{RGI_Emoji}[^\p{RGI_Emoji}\P{RGI_Emoji}]/, -- ~~~~~~~~~~~~~ --!!! error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. -- ~~~~~~~~~ --!!! error TS1528: Any Unicode property that would possibly match more than a single character is only available when the Unicode Sets (v) flag is set. -- ~~~~~~~~~~~~~ --!!! error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. -- ~~~~~~~~~ --!!! error TS1528: Any Unicode property that would possibly match more than a single character is only available when the Unicode Sets (v) flag is set. -- ~~~~~~~~~~~~~ --!!! error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. -- ~~~~~~~~~ --!!! error TS1528: Any Unicode property that would possibly match more than a single character is only available when the Unicode Sets (v) flag is set. -- ~~~~~~~~~~~~~ --!!! error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. -- ~~~~~~~~~ --!!! error TS1528: Any Unicode property that would possibly match more than a single character is only available when the Unicode Sets (v) flag is set. -- /\p{RGI_Emoji}\P{RGI_Emoji}[^\p{RGI_Emoji}\P{RGI_Emoji}]/u, -- ~~~~~~~~~ --!!! error TS1528: Any Unicode property that would possibly match more than a single character is only available when the Unicode Sets (v) flag is set. -- ~~~~~~~~~ --!!! error TS1528: Any Unicode property that would possibly match more than a single character is only available when the Unicode Sets (v) flag is set. -- ~~~~~~~~~ --!!! error TS1528: Any Unicode property that would possibly match more than a single character is only available when the Unicode Sets (v) flag is set. -- ~~~~~~~~~ --!!! error TS1528: Any Unicode property that would possibly match more than a single character is only available when the Unicode Sets (v) flag is set. -- /\p{RGI_Emoji}\P{RGI_Emoji}[^\p{RGI_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 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 TS1501: This regular expression flag is only available when targeting 'es2024' or later. -- // Character escapes -- /\c[\c0\ca\cQ\c\C]\c1\C/, -- /\c[\c0\ca\cQ\c\C]\c1\C/u, -- ~~ --!!! error TS1512: '\c' must be followed by an ASCII letter. -- ~~ --!!! error TS1512: '\c' must be followed by an ASCII letter. -- ~~ --!!! error TS1512: '\c' must be followed by an ASCII letter. -- ~~ --!!! error TS1535: This character cannot be escaped in a regular expression. -- ~~ --!!! error TS1512: '\c' must be followed by an ASCII letter. -- ~~ --!!! error TS1535: This character cannot be escaped in a regular expression. -- /\q\\\`[\q\\\`[\Q\\\Q{\q{foo|bar|baz]\q{]\q{/, -- /\q\\\`[\q\\\`[\Q\\\Q{\q{foo|bar|baz]\q{]\q{/u, -- ~~ --!!! error TS1535: This character cannot be escaped in a regular expression. -- ~~ --!!! error TS1535: This character cannot be escaped in a regular expression. -- ~~ --!!! error TS1535: This character cannot be escaped in a regular expression. -- ~~ --!!! error TS1535: This character cannot be escaped in a regular expression. -- ~~ --!!! error TS1535: This character cannot be escaped in a regular expression. -- ~~ --!!! error TS1535: This character cannot be escaped in a regular expression. -- ~~ --!!! error TS1535: This character cannot be escaped in a regular expression. -- ~~ --!!! error TS1535: This character cannot be escaped in a regular expression. -- ~ --!!! error TS1508: Unexpected '{'. Did you mean to escape it with backslash? -- ~ --!!! error TS1508: Unexpected ']'. Did you mean to escape it with backslash? -- ~~ --!!! error TS1535: This character cannot be escaped in a regular expression. -- ~ --!!! error TS1508: Unexpected '{'. Did you mean to escape it with backslash? -- /\q\\\`[\q\\\`[\Q\\\Q{\q{foo|bar|baz]\q{]\q{/v, -- ~~ --!!! error TS1511: '\q' is only available inside character class. -- ~~ --!!! error TS1535: This character cannot be escaped in a regular expression. -- ~~ --!!! error TS1521: '\q' must be followed by string alternatives enclosed in braces. -- ~~ --!!! error TS1535: This character cannot be escaped in a regular expression. -- ~~ --!!! error TS1535: This character cannot be escaped in a regular expression. -- ~ --!!! error TS1508: Unexpected '{'. Did you mean to escape it with backslash? -- ~ --!!! error TS1508: Unexpected ']'. Did you mean to escape it with backslash? -- ~~ --!!! error TS1535: This character cannot be escaped in a regular expression. -- ~ --!!! error TS1508: Unexpected '{'. Did you mean to escape it with backslash? -- ~ --!!! error TS1508: Unexpected ']'. Did you mean to escape it with backslash? -- ~~ --!!! error TS1535: This character cannot be escaped in a regular expression. -- ~ --!!! error TS1508: Unexpected '{'. Did you mean to escape it with backslash? -- --!!! error TS1005: '}' expected. -- ~ --!!! error TS1501: This regular expression flag is only available when targeting 'es2024' or later. -- // Unicode sets notation -- /[a--b[--][\d++[]]&&[[&0-9--]&&[\p{L}]--\P{L}-_-]]&&&\q{foo}[0---9][&&q&&&\q{bar}&&]/, -- ~~~ --!!! error TS1517: Range out of order in character class. -- ~~~ --!!! error TS1517: Range out of order in character class. -- ~~~~~ --!!! error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. -- ~~~~~ --!!! error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. -- ~~~ --!!! error TS1517: Range out of order in character class. -- /[a--b[--][\d++[]]&&[[&0-9--]&&[\p{L}]--\P{L}-_-]]&&&\q{foo}[0---9][&&q&&&\q{bar}&&]/u, -- ~~~ --!!! error TS1517: Range out of order in character class. -- ~~~ --!!! error TS1517: Range out of order in character class. -- ~ --!!! error TS1508: Unexpected ']'. Did you mean to escape it with backslash? -- ~ --!!! error TS1508: Unexpected ']'. Did you mean to escape it with backslash? -- ~ --!!! error TS1508: Unexpected ']'. Did you mean to escape it with backslash? -- ~~ --!!! error TS1535: This character cannot be escaped in a regular expression. -- ~ --!!! error TS1508: Unexpected '{'. Did you mean to escape it with backslash? -- ~ --!!! error TS1508: Unexpected '}'. Did you mean to escape it with backslash? -- ~~~ --!!! error TS1517: Range out of order in character class. -- ~~ --!!! error TS1535: This character cannot be escaped in a regular expression. -- /[a--b[--][\d++[]]&&[[&0-9--]&&[\p{L}]--\P{L}-_-]]&&&\q{foo}[0---9][&&q&&&\q{bar}&&]/v, -- --!!! error TS1005: '--' expected. -- --!!! error TS1520: Expected a class set operand. -- --!!! error TS1520: Expected a class set operand. -- --!!! error TS1005: '--' expected. -- ~~ --!!! error TS1522: A character class must not contain a reserved double punctuator. Did you mean to escape it with backslash? -- ~~ --!!! error TS1519: Operators must not be mixed within a character class. Wrap it in a nested class instead. -- ~~ --!!! error TS1519: Operators must not be mixed within a character class. Wrap it in a nested class instead. -- ~~ --!!! error TS1519: Operators must not be mixed within a character class. Wrap it in a nested class instead. -- ~ --!!! error TS1519: Operators must not be mixed within a character class. Wrap it in a nested class instead. -- ~ --!!! error TS1519: Operators must not be mixed within a character class. Wrap it in a nested class instead. -- --!!! error TS1520: Expected a class set operand. -- ~~ --!!! error TS1511: '\q' is only available inside character class. -- ~ --!!! error TS1508: Unexpected '{'. Did you mean to escape it with backslash? -- ~ --!!! error TS1508: Unexpected '}'. Did you mean to escape it with backslash? -- ~ --!!! error TS1508: Unexpected '-'. Did you mean to escape it with backslash? -- --!!! error TS1005: '--' expected. -- --!!! error TS1520: Expected a class set operand. -- ~ --!!! error TS1508: Unexpected '&'. Did you mean to escape it with backslash? -- --!!! error TS1520: Expected a class set operand. -- ~ --!!! error TS1501: This regular expression flag is only available when targeting 'es2024' or later. -- /[[^\P{Decimal_Number}&&[0-9]]&&\p{L}&&\p{ID_Continue}--\p{ASCII}\p{CWCF}]/v, -- ~~ --!!! error TS1519: Operators must not be mixed within a character class. Wrap it in a nested class instead. -- --!!! error TS1005: '&&' expected. -- ~ --!!! 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 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, -- ~~~~~~~~~~~~~ --!!! 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 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. -- ~ --!!! 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 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, -- ~~~~~~~~~~~~~~~~~ --!!! 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 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. -- ~ --!!! error TS1501: This regular expression flag is only available when targeting 'es2024' or later. -- /[^\q{foo|bar|baz}--\q{foo}--\q{bar}--\q{baz}][^\p{L}--\q{foo}--[\q{bar}]--[^[\q{baz}]]]/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 TS1501: This regular expression flag is only available when targeting 'es2024' or later. -- /[^[[\q{foo|bar|baz}]]--\q{foo}--\q{bar}--\q{baz}][^[^[^\p{L}]]--\q{foo}--[\q{bar}]--[^[\q{baz}]]]/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 TS1501: This regular expression flag is only available when targeting 'es2024' or later. -- ]; -- -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/regularExpressionScanning(target=esnext).errors.txt b/testdata/baselines/reference/submodule/compiler/regularExpressionScanning(target=esnext).errors.txt new file mode 100644 index 0000000000..c2d144d42c --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/regularExpressionScanning(target=esnext).errors.txt @@ -0,0 +1,631 @@ +regularExpressionScanning.ts(3,10): error TS1502: The Unicode (u) flag and the Unicode Sets (v) flag cannot be set simultaneously. +regularExpressionScanning.ts(3,11): error TS1499: Unknown regular expression flag. +regularExpressionScanning.ts(3,12): error TS1499: Unknown regular expression flag. +regularExpressionScanning.ts(3,13): error TS1500: Duplicate regular expression flag. +regularExpressionScanning.ts(3,14): error TS1499: Unknown regular expression flag. +regularExpressionScanning.ts(3,15): error TS1502: The Unicode (u) flag and the Unicode Sets (v) flag cannot be set simultaneously. +regularExpressionScanning.ts(3,17): error TS1500: Duplicate regular expression flag. +regularExpressionScanning.ts(3,18): error TS1499: Unknown regular expression flag. +regularExpressionScanning.ts(3,19): error TS1499: Unknown regular expression flag. +regularExpressionScanning.ts(3,20): error TS1499: Unknown regular expression flag. +regularExpressionScanning.ts(3,21): error TS1500: Duplicate regular expression flag. +regularExpressionScanning.ts(3,22): error TS1499: Unknown regular expression flag. +regularExpressionScanning.ts(5,6): error TS1499: Unknown regular expression flag. +regularExpressionScanning.ts(5,7): error TS1509: This regular expression flag cannot be toggled within a subpattern. +regularExpressionScanning.ts(5,10): error TS1509: This regular expression flag cannot be toggled within a subpattern. +regularExpressionScanning.ts(5,11): error TS1500: Duplicate regular expression flag. +regularExpressionScanning.ts(8,4): error TS1534: This backreference refers to a group that does not exist. There are no capturing groups in this regular expression. +regularExpressionScanning.ts(9,4): error TS1534: This backreference refers to a group that does not exist. There are no capturing groups in this regular expression. +regularExpressionScanning.ts(12,9): error TS1533: This backreference refers to a group that does not exist. There are only 4 capturing groups in this regular expression. +regularExpressionScanning.ts(12,24): error TS1536: Octal escape sequences and backreferences are not allowed in a character class. If this was intended as an escape sequence, use the syntax '\x01' instead. +regularExpressionScanning.ts(12,26): error TS1487: Octal escape sequences are not allowed. Use the syntax '\x01'. +regularExpressionScanning.ts(12,29): error TS1536: Octal escape sequences and backreferences are not allowed in a character class. If this was intended as an escape sequence, use the syntax '\x53' instead. +regularExpressionScanning.ts(12,33): error TS1487: Octal escape sequences are not allowed. Use the syntax '\x00'. +regularExpressionScanning.ts(12,36): error TS1537: Decimal escape sequences and backreferences are not allowed in a character class. +regularExpressionScanning.ts(12,42): error TS1487: Octal escape sequences are not allowed. Use the syntax '\x03'. +regularExpressionScanning.ts(12,47): error TS1533: This backreference refers to a group that does not exist. There are only 4 capturing groups in this regular expression. +regularExpressionScanning.ts(12,48): error TS1487: Octal escape sequences are not allowed. Use the syntax '\x05'. +regularExpressionScanning.ts(12,53): error TS1533: This backreference refers to a group that does not exist. There are only 4 capturing groups in this regular expression. +regularExpressionScanning.ts(12,54): error TS1487: Octal escape sequences are not allowed. Use the syntax '\x00'. +regularExpressionScanning.ts(13,9): error TS1533: This backreference refers to a group that does not exist. There are only 4 capturing groups in this regular expression. +regularExpressionScanning.ts(13,24): error TS1536: Octal escape sequences and backreferences are not allowed in a character class. If this was intended as an escape sequence, use the syntax '\x01' instead. +regularExpressionScanning.ts(13,26): error TS1487: Octal escape sequences are not allowed. Use the syntax '\x01'. +regularExpressionScanning.ts(13,29): error TS1536: Octal escape sequences and backreferences are not allowed in a character class. If this was intended as an escape sequence, use the syntax '\x53' instead. +regularExpressionScanning.ts(13,33): error TS1487: Octal escape sequences are not allowed. Use the syntax '\x00'. +regularExpressionScanning.ts(13,36): error TS1537: Decimal escape sequences and backreferences are not allowed in a character class. +regularExpressionScanning.ts(13,42): error TS1487: Octal escape sequences are not allowed. Use the syntax '\x03'. +regularExpressionScanning.ts(13,47): error TS1533: This backreference refers to a group that does not exist. There are only 4 capturing groups in this regular expression. +regularExpressionScanning.ts(13,48): error TS1487: Octal escape sequences are not allowed. Use the syntax '\x05'. +regularExpressionScanning.ts(13,53): error TS1533: This backreference refers to a group that does not exist. There are only 4 capturing groups in this regular expression. +regularExpressionScanning.ts(13,54): error TS1487: Octal escape sequences are not allowed. Use the syntax '\x00'. +regularExpressionScanning.ts(15,15): error TS1532: There is no capturing group named 'absent' in this regular expression. +regularExpressionScanning.ts(15,59): error TS1515: Named capturing groups with the same name must be mutually exclusive to each other. +regularExpressionScanning.ts(17,31): error TS1507: There is nothing available for repetition. +regularExpressionScanning.ts(17,32): error TS1506: Numbers out of order in quantifier. +regularExpressionScanning.ts(17,40): error TS1507: There is nothing available for repetition. +regularExpressionScanning.ts(19,12): error TS1517: Range out of order in character class. +regularExpressionScanning.ts(19,15): error TS1517: Range out of order in character class. +regularExpressionScanning.ts(19,28): error TS1517: Range out of order in character class. +regularExpressionScanning.ts(20,3): error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. +regularExpressionScanning.ts(20,8): error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. +regularExpressionScanning.ts(20,16): error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. +regularExpressionScanning.ts(20,25): error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. +regularExpressionScanning.ts(20,28): error TS1529: Unknown Unicode property name or value. +regularExpressionScanning.ts(20,37): error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. +regularExpressionScanning.ts(20,42): error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. +regularExpressionScanning.ts(20,50): error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. +regularExpressionScanning.ts(20,59): error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. +regularExpressionScanning.ts(20,62): error TS1529: Unknown Unicode property name or value. +regularExpressionScanning.ts(21,28): error TS1529: Unknown Unicode property name or value. +regularExpressionScanning.ts(21,62): error TS1529: Unknown Unicode property name or value. +regularExpressionScanning.ts(22,28): error TS1529: Unknown Unicode property name or value. +regularExpressionScanning.ts(22,62): error TS1529: Unknown Unicode property name or value. +regularExpressionScanning.ts(23,3): error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. +regularExpressionScanning.ts(23,6): error TS1524: Unknown Unicode property name. +regularExpressionScanning.ts(23,28): error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. +regularExpressionScanning.ts(23,31): error TS1523: Expected a Unicode property name. +regularExpressionScanning.ts(23,32): error TS1525: Expected a Unicode property value. +regularExpressionScanning.ts(23,33): error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. +regularExpressionScanning.ts(23,39): error TS1525: Expected a Unicode property value. +regularExpressionScanning.ts(23,40): error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. +regularExpressionScanning.ts(23,43): error TS1523: Expected a Unicode property name. +regularExpressionScanning.ts(23,49): error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. +regularExpressionScanning.ts(23,52): error TS1527: Expected a Unicode property name or value. +regularExpressionScanning.ts(23,59): error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. +regularExpressionScanning.ts(23,62): error TS1527: Expected a Unicode property name or value. +regularExpressionScanning.ts(23,63): error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. +regularExpressionScanning.ts(23,66): error TS1527: Expected a Unicode property name or value. +regularExpressionScanning.ts(24,6): error TS1524: Unknown Unicode property name. +regularExpressionScanning.ts(24,31): error TS1523: Expected a Unicode property name. +regularExpressionScanning.ts(24,32): error TS1525: Expected a Unicode property value. +regularExpressionScanning.ts(24,39): error TS1525: Expected a Unicode property value. +regularExpressionScanning.ts(24,43): error TS1523: Expected a Unicode property name. +regularExpressionScanning.ts(24,52): error TS1527: Expected a Unicode property name or value. +regularExpressionScanning.ts(24,53): error TS1531: '\p' must be followed by a Unicode property value expression enclosed in braces. +regularExpressionScanning.ts(24,57): error TS1531: '\P' must be followed by a Unicode property value expression enclosed in braces. +regularExpressionScanning.ts(24,62): error TS1527: Expected a Unicode property name or value. +regularExpressionScanning.ts(24,66): error TS1527: Expected a Unicode property name or value. +regularExpressionScanning.ts(25,6): error TS1524: Unknown Unicode property name. +regularExpressionScanning.ts(25,31): error TS1523: Expected a Unicode property name. +regularExpressionScanning.ts(25,32): error TS1525: Expected a Unicode property value. +regularExpressionScanning.ts(25,39): error TS1525: Expected a Unicode property value. +regularExpressionScanning.ts(25,43): error TS1523: Expected a Unicode property name. +regularExpressionScanning.ts(25,52): error TS1527: Expected a Unicode property name or value. +regularExpressionScanning.ts(25,53): error TS1531: '\p' must be followed by a Unicode property value expression enclosed in braces. +regularExpressionScanning.ts(25,57): error TS1531: '\P' must be followed by a Unicode property value expression enclosed in braces. +regularExpressionScanning.ts(25,62): error TS1527: Expected a Unicode property name or value. +regularExpressionScanning.ts(25,66): error TS1527: Expected a Unicode property name or value. +regularExpressionScanning.ts(26,3): error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. +regularExpressionScanning.ts(26,6): error TS1528: Any Unicode property that would possibly match more than a single character is only available when the Unicode Sets (v) flag is set. +regularExpressionScanning.ts(26,16): error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. +regularExpressionScanning.ts(26,19): error TS1528: Any Unicode property that would possibly match more than a single character is only available when the Unicode Sets (v) flag is set. +regularExpressionScanning.ts(26,31): error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. +regularExpressionScanning.ts(26,34): error TS1528: Any Unicode property that would possibly match more than a single character is only available when the Unicode Sets (v) flag is set. +regularExpressionScanning.ts(26,44): error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. +regularExpressionScanning.ts(26,47): error TS1528: Any Unicode property that would possibly match more than a single character is only available when the Unicode Sets (v) flag is set. +regularExpressionScanning.ts(27,6): error TS1528: Any Unicode property that would possibly match more than a single character is only available when the Unicode Sets (v) flag is set. +regularExpressionScanning.ts(27,19): error TS1528: Any Unicode property that would possibly match more than a single character is only available when the Unicode Sets (v) flag is set. +regularExpressionScanning.ts(27,34): error TS1528: Any Unicode property that would possibly match more than a single character is only available when the Unicode Sets (v) flag is set. +regularExpressionScanning.ts(27,47): error TS1528: Any Unicode property that would possibly match more than a single character is only available when the Unicode Sets (v) flag is set. +regularExpressionScanning.ts(28,19): error TS1518: Anything that would possibly match more than a single character is invalid inside a negated character class. +regularExpressionScanning.ts(28,31): error TS1518: Anything that would possibly match more than a single character is invalid inside a negated character class. +regularExpressionScanning.ts(28,47): error TS1518: Anything that would possibly match more than a single character is invalid inside a negated character class. +regularExpressionScanning.ts(31,3): error TS1512: '\c' must be followed by an ASCII letter. +regularExpressionScanning.ts(31,6): error TS1512: '\c' must be followed by an ASCII letter. +regularExpressionScanning.ts(31,15): error TS1512: '\c' must be followed by an ASCII letter. +regularExpressionScanning.ts(31,17): error TS1535: This character cannot be escaped in a regular expression. +regularExpressionScanning.ts(31,20): error TS1512: '\c' must be followed by an ASCII letter. +regularExpressionScanning.ts(31,23): error TS1535: This character cannot be escaped in a regular expression. +regularExpressionScanning.ts(33,3): error TS1535: This character cannot be escaped in a regular expression. +regularExpressionScanning.ts(33,7): error TS1535: This character cannot be escaped in a regular expression. +regularExpressionScanning.ts(33,10): error TS1535: This character cannot be escaped in a regular expression. +regularExpressionScanning.ts(33,14): error TS1535: This character cannot be escaped in a regular expression. +regularExpressionScanning.ts(33,17): error TS1535: This character cannot be escaped in a regular expression. +regularExpressionScanning.ts(33,21): error TS1535: This character cannot be escaped in a regular expression. +regularExpressionScanning.ts(33,24): error TS1535: This character cannot be escaped in a regular expression. +regularExpressionScanning.ts(33,39): error TS1535: This character cannot be escaped in a regular expression. +regularExpressionScanning.ts(33,41): error TS1508: Unexpected '{'. Did you mean to escape it with backslash? +regularExpressionScanning.ts(33,42): error TS1508: Unexpected ']'. Did you mean to escape it with backslash? +regularExpressionScanning.ts(33,43): error TS1535: This character cannot be escaped in a regular expression. +regularExpressionScanning.ts(33,45): error TS1508: Unexpected '{'. Did you mean to escape it with backslash? +regularExpressionScanning.ts(34,3): error TS1511: '\q' is only available inside character class. +regularExpressionScanning.ts(34,7): error TS1535: This character cannot be escaped in a regular expression. +regularExpressionScanning.ts(34,10): error TS1521: '\q' must be followed by string alternatives enclosed in braces. +regularExpressionScanning.ts(34,17): error TS1535: This character cannot be escaped in a regular expression. +regularExpressionScanning.ts(34,21): error TS1535: This character cannot be escaped in a regular expression. +regularExpressionScanning.ts(34,23): error TS1508: Unexpected '{'. Did you mean to escape it with backslash? +regularExpressionScanning.ts(34,38): error TS1508: Unexpected ']'. Did you mean to escape it with backslash? +regularExpressionScanning.ts(34,39): error TS1535: This character cannot be escaped in a regular expression. +regularExpressionScanning.ts(34,41): error TS1508: Unexpected '{'. Did you mean to escape it with backslash? +regularExpressionScanning.ts(34,42): error TS1508: Unexpected ']'. Did you mean to escape it with backslash? +regularExpressionScanning.ts(34,43): error TS1535: This character cannot be escaped in a regular expression. +regularExpressionScanning.ts(34,45): error TS1508: Unexpected '{'. Did you mean to escape it with backslash? +regularExpressionScanning.ts(34,46): error TS1005: '}' expected. +regularExpressionScanning.ts(36,4): error TS1517: Range out of order in character class. +regularExpressionScanning.ts(36,8): error TS1517: Range out of order in character class. +regularExpressionScanning.ts(36,34): error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. +regularExpressionScanning.ts(36,42): error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. +regularExpressionScanning.ts(36,63): error TS1517: Range out of order in character class. +regularExpressionScanning.ts(37,4): error TS1517: Range out of order in character class. +regularExpressionScanning.ts(37,8): error TS1517: Range out of order in character class. +regularExpressionScanning.ts(37,19): error TS1508: Unexpected ']'. Did you mean to escape it with backslash? +regularExpressionScanning.ts(37,50): error TS1508: Unexpected ']'. Did you mean to escape it with backslash? +regularExpressionScanning.ts(37,51): error TS1508: Unexpected ']'. Did you mean to escape it with backslash? +regularExpressionScanning.ts(37,55): error TS1535: This character cannot be escaped in a regular expression. +regularExpressionScanning.ts(37,57): error TS1508: Unexpected '{'. Did you mean to escape it with backslash? +regularExpressionScanning.ts(37,61): error TS1508: Unexpected '}'. Did you mean to escape it with backslash? +regularExpressionScanning.ts(37,63): error TS1517: Range out of order in character class. +regularExpressionScanning.ts(37,76): error TS1535: This character cannot be escaped in a regular expression. +regularExpressionScanning.ts(38,8): error TS1005: '--' expected. +regularExpressionScanning.ts(38,9): error TS1520: Expected a class set operand. +regularExpressionScanning.ts(38,11): error TS1520: Expected a class set operand. +regularExpressionScanning.ts(38,12): error TS1005: '--' expected. +regularExpressionScanning.ts(38,15): error TS1522: A character class must not contain a reserved double punctuator. Did you mean to escape it with backslash? +regularExpressionScanning.ts(38,20): error TS1519: Operators must not be mixed within a character class. Wrap it in a nested class instead. +regularExpressionScanning.ts(38,28): error TS1519: Operators must not be mixed within a character class. Wrap it in a nested class instead. +regularExpressionScanning.ts(38,40): error TS1519: Operators must not be mixed within a character class. Wrap it in a nested class instead. +regularExpressionScanning.ts(38,47): error TS1519: Operators must not be mixed within a character class. Wrap it in a nested class instead. +regularExpressionScanning.ts(38,49): error TS1519: Operators must not be mixed within a character class. Wrap it in a nested class instead. +regularExpressionScanning.ts(38,50): error TS1520: Expected a class set operand. +regularExpressionScanning.ts(38,55): error TS1511: '\q' is only available inside character class. +regularExpressionScanning.ts(38,57): error TS1508: Unexpected '{'. Did you mean to escape it with backslash? +regularExpressionScanning.ts(38,61): error TS1508: Unexpected '}'. Did you mean to escape it with backslash? +regularExpressionScanning.ts(38,66): error TS1508: Unexpected '-'. Did you mean to escape it with backslash? +regularExpressionScanning.ts(38,67): error TS1005: '--' expected. +regularExpressionScanning.ts(38,70): error TS1520: Expected a class set operand. +regularExpressionScanning.ts(38,75): error TS1508: Unexpected '&'. Did you mean to escape it with backslash? +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(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,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(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,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. +regularExpressionScanning.ts(46,79): error TS1518: Anything that would possibly match more than a single character is invalid inside a negated character class. +regularExpressionScanning.ts(47,5): error TS1518: Anything that would possibly match more than a single character is invalid inside a negated character class. +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) ==== + const regexes: RegExp[] = [ + // Flags + /foo/visualstudiocode, + ~ +!!! error TS1502: The Unicode (u) flag and the Unicode Sets (v) flag cannot be set simultaneously. + ~ +!!! error TS1499: Unknown regular expression flag. + ~ +!!! error TS1499: Unknown regular expression flag. + ~ +!!! error TS1500: Duplicate regular expression flag. + ~ +!!! error TS1499: Unknown regular expression flag. + ~ +!!! error TS1502: The Unicode (u) flag and the Unicode Sets (v) flag cannot be set simultaneously. + ~ +!!! error TS1500: Duplicate regular expression flag. + ~ +!!! error TS1499: Unknown regular expression flag. + ~ +!!! error TS1499: Unknown regular expression flag. + ~ +!!! error TS1499: Unknown regular expression flag. + ~ +!!! error TS1500: Duplicate regular expression flag. + ~ +!!! error TS1499: Unknown regular expression flag. + // Pattern modifiers + /(?med-ium:bar)/, + ~ +!!! error TS1499: Unknown regular expression flag. + ~ +!!! error TS1509: This regular expression flag cannot be toggled within a subpattern. + ~ +!!! error TS1509: This regular expression flag cannot be toggled within a subpattern. + ~ +!!! error TS1500: Duplicate regular expression flag. + // Capturing groups + /\0/, + /\1/, + ~ +!!! error TS1534: This backreference refers to a group that does not exist. There are no capturing groups in this regular expression. + /\2/, + ~ +!!! error TS1534: This backreference refers to a group that does not exist. There are no capturing groups in this regular expression. + /(hi)\1/, + /(hi) (hello) \2/, + /\2()(\12)(foo)\1\0[\0\1\01\123\08\8](\3\03)\5\005\9\009/, + ~~ +!!! error TS1533: This backreference refers to a group that does not exist. There are only 4 capturing groups in this regular expression. + ~~ +!!! error TS1536: Octal escape sequences and backreferences are not allowed in a character class. If this was intended as an escape sequence, use the syntax '\x01' instead. + ~~~ +!!! error TS1487: Octal escape sequences are not allowed. Use the syntax '\x01'. + ~~~~ +!!! error TS1536: Octal escape sequences and backreferences are not allowed in a character class. If this was intended as an escape sequence, use the syntax '\x53' instead. + ~~ +!!! error TS1487: Octal escape sequences are not allowed. Use the syntax '\x00'. + ~~ +!!! error TS1537: Decimal escape sequences and backreferences are not allowed in a character class. + ~~~ +!!! error TS1487: Octal escape sequences are not allowed. Use the syntax '\x03'. + ~ +!!! error TS1533: This backreference refers to a group that does not exist. There are only 4 capturing groups in this regular expression. + ~~~~ +!!! error TS1487: Octal escape sequences are not allowed. Use the syntax '\x05'. + ~ +!!! error TS1533: This backreference refers to a group that does not exist. There are only 4 capturing groups in this regular expression. + ~~~ +!!! error TS1487: Octal escape sequences are not allowed. Use the syntax '\x00'. + /\2()(\12)(foo)\1\0[\0\1\01\123\08\8](\3\03)\5\005\9\009/u, + ~~ +!!! error TS1533: This backreference refers to a group that does not exist. There are only 4 capturing groups in this regular expression. + ~~ +!!! error TS1536: Octal escape sequences and backreferences are not allowed in a character class. If this was intended as an escape sequence, use the syntax '\x01' instead. + ~~~ +!!! error TS1487: Octal escape sequences are not allowed. Use the syntax '\x01'. + ~~~~ +!!! error TS1536: Octal escape sequences and backreferences are not allowed in a character class. If this was intended as an escape sequence, use the syntax '\x53' instead. + ~~ +!!! error TS1487: Octal escape sequences are not allowed. Use the syntax '\x00'. + ~~ +!!! error TS1537: Decimal escape sequences and backreferences are not allowed in a character class. + ~~~ +!!! error TS1487: Octal escape sequences are not allowed. Use the syntax '\x03'. + ~ +!!! error TS1533: This backreference refers to a group that does not exist. There are only 4 capturing groups in this regular expression. + ~~~~ +!!! error TS1487: Octal escape sequences are not allowed. Use the syntax '\x05'. + ~ +!!! error TS1533: This backreference refers to a group that does not exist. There are only 4 capturing groups in this regular expression. + ~~~ +!!! error TS1487: Octal escape sequences are not allowed. Use the syntax '\x00'. + /(?)((?bar)bar)(?baz)|(foo(?foo))(?)/, + /(\k)\k(?foo)|(?)((?)|(bar(?bar)))/, + ~~~~~~ +!!! error TS1532: There is no capturing group named 'absent' in this regular expression. + ~~~ +!!! error TS1515: Named capturing groups with the same name must be mutually exclusive to each other. + // Quantifiers + /{}{1,2}_{3}.{4,}?(foo){008}${32,16}\b{064,128}.+&*?\???\n{,256}{\\{,/, + ~~~~~~~ +!!! error TS1507: There is nothing available for repetition. + ~~~~~ +!!! error TS1506: Numbers out of order in quantifier. + ~~~~~~~~~ +!!! error TS1507: There is nothing available for repetition. + // Character classes + /[-A-Za-z-z-aZ-A\d_-\d-.-.\r-\n\w-\W]/, + ~~~ +!!! error TS1517: Range out of order in character class. + ~~~ +!!! error TS1517: Range out of order in character class. + ~~~~~ +!!! error TS1517: Range out of order in character class. + /\p{L}\p{gc=L}\p{ASCII}\p{Invalid}[\p{L}\p{gc=L}\P{ASCII}\p{Invalid}]/, + ~~~~~ +!!! error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. + ~~~~~~~~ +!!! error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. + ~~~~~~~~~ +!!! error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. + ~~~~~~~~~~~ +!!! error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. + ~~~~~~~ +!!! error TS1529: Unknown Unicode property name or value. + ~~~~~ +!!! error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. + ~~~~~~~~ +!!! error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. + ~~~~~~~~~ +!!! error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. + ~~~~~~~~~~~ +!!! error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. + ~~~~~~~ +!!! error TS1529: Unknown Unicode property name or value. + /\p{L}\p{gc=L}\p{ASCII}\p{Invalid}[\p{L}\p{gc=L}\P{ASCII}\p{Invalid}]/u, + ~~~~~~~ +!!! error TS1529: Unknown Unicode property name or value. + ~~~~~~~ +!!! error TS1529: Unknown Unicode property name or value. + /\p{L}\p{gc=L}\p{ASCII}\p{Invalid}[\p{L}\p{gc=L}\P{ASCII}\p{Invalid}]/v, + ~~~~~~~ +!!! error TS1529: Unknown Unicode property name or value. + ~~~~~~~ +!!! error TS1529: Unknown Unicode property name or value. + /\p{InvalidProperty=Value}\p{=}\p{sc=}\P{=foo}[\p{}\p\\\P\P{]\p{/, + ~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. + ~~~~~~~~~~~~~~~ +!!! error TS1524: Unknown Unicode property name. + ~~~~~ +!!! error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. + +!!! error TS1523: Expected a Unicode property name. + +!!! error TS1525: Expected a Unicode property value. + ~~~~~~~ +!!! error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. + +!!! error TS1525: Expected a Unicode property value. + ~~~~~~~~ +!!! error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. + +!!! error TS1523: Expected a Unicode property name. + ~~~~ +!!! error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. + +!!! error TS1527: Expected a Unicode property name or value. + ~~~ +!!! error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. + +!!! error TS1527: Expected a Unicode property name or value. + ~~~ +!!! error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. + +!!! error TS1527: Expected a Unicode property name or value. + /\p{InvalidProperty=Value}\p{=}\p{sc=}\P{=foo}[\p{}\p\\\P\P{]\p{/u, + ~~~~~~~~~~~~~~~ +!!! error TS1524: Unknown Unicode property name. + +!!! error TS1523: Expected a Unicode property name. + +!!! error TS1525: Expected a Unicode property value. + +!!! error TS1525: Expected a Unicode property value. + +!!! error TS1523: Expected a Unicode property name. + +!!! error TS1527: Expected a Unicode property name or value. + ~~ +!!! error TS1531: '\p' must be followed by a Unicode property value expression enclosed in braces. + ~~ +!!! error TS1531: '\P' must be followed by a Unicode property value expression enclosed in braces. + +!!! error TS1527: Expected a Unicode property name or value. + +!!! error TS1527: Expected a Unicode property name or value. + /\p{InvalidProperty=Value}\p{=}\p{sc=}\P{=foo}[\p{}\p\\\P\P{]\p{/v, + ~~~~~~~~~~~~~~~ +!!! error TS1524: Unknown Unicode property name. + +!!! error TS1523: Expected a Unicode property name. + +!!! error TS1525: Expected a Unicode property value. + +!!! error TS1525: Expected a Unicode property value. + +!!! error TS1523: Expected a Unicode property name. + +!!! error TS1527: Expected a Unicode property name or value. + ~~ +!!! error TS1531: '\p' must be followed by a Unicode property value expression enclosed in braces. + ~~ +!!! error TS1531: '\P' must be followed by a Unicode property value expression enclosed in braces. + +!!! error TS1527: Expected a Unicode property name or value. + +!!! error TS1527: Expected a Unicode property name or value. + /\p{RGI_Emoji}\P{RGI_Emoji}[^\p{RGI_Emoji}\P{RGI_Emoji}]/, + ~~~~~~~~~~~~~ +!!! error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. + ~~~~~~~~~ +!!! error TS1528: Any Unicode property that would possibly match more than a single character is only available when the Unicode Sets (v) flag is set. + ~~~~~~~~~~~~~ +!!! error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. + ~~~~~~~~~ +!!! error TS1528: Any Unicode property that would possibly match more than a single character is only available when the Unicode Sets (v) flag is set. + ~~~~~~~~~~~~~ +!!! error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. + ~~~~~~~~~ +!!! error TS1528: Any Unicode property that would possibly match more than a single character is only available when the Unicode Sets (v) flag is set. + ~~~~~~~~~~~~~ +!!! error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. + ~~~~~~~~~ +!!! error TS1528: Any Unicode property that would possibly match more than a single character is only available when the Unicode Sets (v) flag is set. + /\p{RGI_Emoji}\P{RGI_Emoji}[^\p{RGI_Emoji}\P{RGI_Emoji}]/u, + ~~~~~~~~~ +!!! error TS1528: Any Unicode property that would possibly match more than a single character is only available when the Unicode Sets (v) flag is set. + ~~~~~~~~~ +!!! error TS1528: Any Unicode property that would possibly match more than a single character is only available when the Unicode Sets (v) flag is set. + ~~~~~~~~~ +!!! error TS1528: Any Unicode property that would possibly match more than a single character is only available when the Unicode Sets (v) flag is set. + ~~~~~~~~~ +!!! error TS1528: Any Unicode property that would possibly match more than a single character is only available when the Unicode Sets (v) flag is set. + /\p{RGI_Emoji}\P{RGI_Emoji}[^\p{RGI_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 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. + // Character escapes + /\c[\c0\ca\cQ\c\C]\c1\C/, + /\c[\c0\ca\cQ\c\C]\c1\C/u, + ~~ +!!! error TS1512: '\c' must be followed by an ASCII letter. + ~~ +!!! error TS1512: '\c' must be followed by an ASCII letter. + ~~ +!!! error TS1512: '\c' must be followed by an ASCII letter. + ~~ +!!! error TS1535: This character cannot be escaped in a regular expression. + ~~ +!!! error TS1512: '\c' must be followed by an ASCII letter. + ~~ +!!! error TS1535: This character cannot be escaped in a regular expression. + /\q\\\`[\q\\\`[\Q\\\Q{\q{foo|bar|baz]\q{]\q{/, + /\q\\\`[\q\\\`[\Q\\\Q{\q{foo|bar|baz]\q{]\q{/u, + ~~ +!!! error TS1535: This character cannot be escaped in a regular expression. + ~~ +!!! error TS1535: This character cannot be escaped in a regular expression. + ~~ +!!! error TS1535: This character cannot be escaped in a regular expression. + ~~ +!!! error TS1535: This character cannot be escaped in a regular expression. + ~~ +!!! error TS1535: This character cannot be escaped in a regular expression. + ~~ +!!! error TS1535: This character cannot be escaped in a regular expression. + ~~ +!!! error TS1535: This character cannot be escaped in a regular expression. + ~~ +!!! error TS1535: This character cannot be escaped in a regular expression. + ~ +!!! error TS1508: Unexpected '{'. Did you mean to escape it with backslash? + ~ +!!! error TS1508: Unexpected ']'. Did you mean to escape it with backslash? + ~~ +!!! error TS1535: This character cannot be escaped in a regular expression. + ~ +!!! error TS1508: Unexpected '{'. Did you mean to escape it with backslash? + /\q\\\`[\q\\\`[\Q\\\Q{\q{foo|bar|baz]\q{]\q{/v, + ~~ +!!! error TS1511: '\q' is only available inside character class. + ~~ +!!! error TS1535: This character cannot be escaped in a regular expression. + ~~ +!!! error TS1521: '\q' must be followed by string alternatives enclosed in braces. + ~~ +!!! error TS1535: This character cannot be escaped in a regular expression. + ~~ +!!! error TS1535: This character cannot be escaped in a regular expression. + ~ +!!! error TS1508: Unexpected '{'. Did you mean to escape it with backslash? + ~ +!!! error TS1508: Unexpected ']'. Did you mean to escape it with backslash? + ~~ +!!! error TS1535: This character cannot be escaped in a regular expression. + ~ +!!! error TS1508: Unexpected '{'. Did you mean to escape it with backslash? + ~ +!!! error TS1508: Unexpected ']'. Did you mean to escape it with backslash? + ~~ +!!! error TS1535: This character cannot be escaped in a regular expression. + ~ +!!! error TS1508: Unexpected '{'. Did you mean to escape it with backslash? + +!!! error TS1005: '}' expected. + // Unicode sets notation + /[a--b[--][\d++[]]&&[[&0-9--]&&[\p{L}]--\P{L}-_-]]&&&\q{foo}[0---9][&&q&&&\q{bar}&&]/, + ~~~ +!!! error TS1517: Range out of order in character class. + ~~~ +!!! error TS1517: Range out of order in character class. + ~~~~~ +!!! error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. + ~~~~~ +!!! error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. + ~~~ +!!! error TS1517: Range out of order in character class. + /[a--b[--][\d++[]]&&[[&0-9--]&&[\p{L}]--\P{L}-_-]]&&&\q{foo}[0---9][&&q&&&\q{bar}&&]/u, + ~~~ +!!! error TS1517: Range out of order in character class. + ~~~ +!!! error TS1517: Range out of order in character class. + ~ +!!! error TS1508: Unexpected ']'. Did you mean to escape it with backslash? + ~ +!!! error TS1508: Unexpected ']'. Did you mean to escape it with backslash? + ~ +!!! error TS1508: Unexpected ']'. Did you mean to escape it with backslash? + ~~ +!!! error TS1535: This character cannot be escaped in a regular expression. + ~ +!!! error TS1508: Unexpected '{'. Did you mean to escape it with backslash? + ~ +!!! error TS1508: Unexpected '}'. Did you mean to escape it with backslash? + ~~~ +!!! error TS1517: Range out of order in character class. + ~~ +!!! error TS1535: This character cannot be escaped in a regular expression. + /[a--b[--][\d++[]]&&[[&0-9--]&&[\p{L}]--\P{L}-_-]]&&&\q{foo}[0---9][&&q&&&\q{bar}&&]/v, + +!!! error TS1005: '--' expected. + +!!! error TS1520: Expected a class set operand. + +!!! error TS1520: Expected a class set operand. + +!!! error TS1005: '--' expected. + ~~ +!!! error TS1522: A character class must not contain a reserved double punctuator. Did you mean to escape it with backslash? + ~~ +!!! error TS1519: Operators must not be mixed within a character class. Wrap it in a nested class instead. + ~~ +!!! error TS1519: Operators must not be mixed within a character class. Wrap it in a nested class instead. + ~~ +!!! error TS1519: Operators must not be mixed within a character class. Wrap it in a nested class instead. + ~ +!!! error TS1519: Operators must not be mixed within a character class. Wrap it in a nested class instead. + ~ +!!! error TS1519: Operators must not be mixed within a character class. Wrap it in a nested class instead. + +!!! error TS1520: Expected a class set operand. + ~~ +!!! error TS1511: '\q' is only available inside character class. + ~ +!!! error TS1508: Unexpected '{'. Did you mean to escape it with backslash? + ~ +!!! error TS1508: Unexpected '}'. Did you mean to escape it with backslash? + ~ +!!! error TS1508: Unexpected '-'. Did you mean to escape it with backslash? + +!!! error TS1005: '--' expected. + +!!! error TS1520: Expected a class set operand. + ~ +!!! error TS1508: Unexpected '&'. Did you mean to escape it with backslash? + +!!! error TS1520: Expected a class set operand. + /[[^\P{Decimal_Number}&&[0-9]]&&\p{L}&&\p{ID_Continue}--\p{ASCII}\p{CWCF}]/v, + ~~ +!!! error TS1519: Operators must not be mixed within a character class. Wrap it in a nested class instead. + +!!! error TS1005: '&&' expected. + /[^\p{Emoji}\p{RGI_Emoji}][^\p{Emoji}--\p{RGI_Emoji}][^\p{Emoji}&&\p{RGI_Emoji}]/v, + /[^\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. + ~~~~~~~~~~~~~ +!!! 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. + /[^\p{Emoji}[[\p{RGI_Emoji}]]][^\p{Emoji}--[[\p{RGI_Emoji}]]][^\p{Emoji}&&[[\p{RGI_Emoji}]]]/v, + /[^[[\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. + ~~~~~~~~~~~~~~~~~ +!!! 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. + /[^\q{foo|bar|baz}--\q{foo}--\q{bar}--\q{baz}][^\p{L}--\q{foo}--[\q{bar}]--[^[\q{baz}]]]/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. + /[^[[\q{foo|bar|baz}]]--\q{foo}--\q{bar}--\q{baz}][^[^[^\p{L}]]--\q{foo}--[\q{bar}]--[^[\q{baz}]]]/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. + ]; + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/regularExpressionScanning(target=esnext).errors.txt.diff b/testdata/baselines/reference/submodule/compiler/regularExpressionScanning(target=esnext).errors.txt.diff deleted file mode 100644 index 427334cc4b..0000000000 --- a/testdata/baselines/reference/submodule/compiler/regularExpressionScanning(target=esnext).errors.txt.diff +++ /dev/null @@ -1,635 +0,0 @@ ---- old.regularExpressionScanning(target=esnext).errors.txt -+++ new.regularExpressionScanning(target=esnext).errors.txt -@@= skipped -0, +0 lines =@@ --regularExpressionScanning.ts(3,10): error TS1502: The Unicode (u) flag and the Unicode Sets (v) flag cannot be set simultaneously. --regularExpressionScanning.ts(3,11): error TS1499: Unknown regular expression flag. --regularExpressionScanning.ts(3,12): error TS1499: Unknown regular expression flag. --regularExpressionScanning.ts(3,13): error TS1500: Duplicate regular expression flag. --regularExpressionScanning.ts(3,14): error TS1499: Unknown regular expression flag. --regularExpressionScanning.ts(3,15): error TS1502: The Unicode (u) flag and the Unicode Sets (v) flag cannot be set simultaneously. --regularExpressionScanning.ts(3,17): error TS1500: Duplicate regular expression flag. --regularExpressionScanning.ts(3,18): error TS1499: Unknown regular expression flag. --regularExpressionScanning.ts(3,19): error TS1499: Unknown regular expression flag. --regularExpressionScanning.ts(3,20): error TS1499: Unknown regular expression flag. --regularExpressionScanning.ts(3,21): error TS1500: Duplicate regular expression flag. --regularExpressionScanning.ts(3,22): error TS1499: Unknown regular expression flag. --regularExpressionScanning.ts(5,6): error TS1499: Unknown regular expression flag. --regularExpressionScanning.ts(5,7): error TS1509: This regular expression flag cannot be toggled within a subpattern. --regularExpressionScanning.ts(5,10): error TS1509: This regular expression flag cannot be toggled within a subpattern. --regularExpressionScanning.ts(5,11): error TS1500: Duplicate regular expression flag. --regularExpressionScanning.ts(8,4): error TS1534: This backreference refers to a group that does not exist. There are no capturing groups in this regular expression. --regularExpressionScanning.ts(9,4): error TS1534: This backreference refers to a group that does not exist. There are no capturing groups in this regular expression. --regularExpressionScanning.ts(12,9): error TS1533: This backreference refers to a group that does not exist. There are only 4 capturing groups in this regular expression. --regularExpressionScanning.ts(12,24): error TS1536: Octal escape sequences and backreferences are not allowed in a character class. If this was intended as an escape sequence, use the syntax '\x01' instead. --regularExpressionScanning.ts(12,26): error TS1487: Octal escape sequences are not allowed. Use the syntax '\x01'. --regularExpressionScanning.ts(12,29): error TS1536: Octal escape sequences and backreferences are not allowed in a character class. If this was intended as an escape sequence, use the syntax '\x53' instead. --regularExpressionScanning.ts(12,33): error TS1487: Octal escape sequences are not allowed. Use the syntax '\x00'. --regularExpressionScanning.ts(12,36): error TS1537: Decimal escape sequences and backreferences are not allowed in a character class. --regularExpressionScanning.ts(12,42): error TS1487: Octal escape sequences are not allowed. Use the syntax '\x03'. --regularExpressionScanning.ts(12,47): error TS1533: This backreference refers to a group that does not exist. There are only 4 capturing groups in this regular expression. --regularExpressionScanning.ts(12,48): error TS1487: Octal escape sequences are not allowed. Use the syntax '\x05'. --regularExpressionScanning.ts(12,53): error TS1533: This backreference refers to a group that does not exist. There are only 4 capturing groups in this regular expression. --regularExpressionScanning.ts(12,54): error TS1487: Octal escape sequences are not allowed. Use the syntax '\x00'. --regularExpressionScanning.ts(13,9): error TS1533: This backreference refers to a group that does not exist. There are only 4 capturing groups in this regular expression. --regularExpressionScanning.ts(13,24): error TS1536: Octal escape sequences and backreferences are not allowed in a character class. If this was intended as an escape sequence, use the syntax '\x01' instead. --regularExpressionScanning.ts(13,26): error TS1487: Octal escape sequences are not allowed. Use the syntax '\x01'. --regularExpressionScanning.ts(13,29): error TS1536: Octal escape sequences and backreferences are not allowed in a character class. If this was intended as an escape sequence, use the syntax '\x53' instead. --regularExpressionScanning.ts(13,33): error TS1487: Octal escape sequences are not allowed. Use the syntax '\x00'. --regularExpressionScanning.ts(13,36): error TS1537: Decimal escape sequences and backreferences are not allowed in a character class. --regularExpressionScanning.ts(13,42): error TS1487: Octal escape sequences are not allowed. Use the syntax '\x03'. --regularExpressionScanning.ts(13,47): error TS1533: This backreference refers to a group that does not exist. There are only 4 capturing groups in this regular expression. --regularExpressionScanning.ts(13,48): error TS1487: Octal escape sequences are not allowed. Use the syntax '\x05'. --regularExpressionScanning.ts(13,53): error TS1533: This backreference refers to a group that does not exist. There are only 4 capturing groups in this regular expression. --regularExpressionScanning.ts(13,54): error TS1487: Octal escape sequences are not allowed. Use the syntax '\x00'. --regularExpressionScanning.ts(15,15): error TS1532: There is no capturing group named 'absent' in this regular expression. --regularExpressionScanning.ts(15,59): error TS1515: Named capturing groups with the same name must be mutually exclusive to each other. --regularExpressionScanning.ts(17,31): error TS1507: There is nothing available for repetition. --regularExpressionScanning.ts(17,32): error TS1506: Numbers out of order in quantifier. --regularExpressionScanning.ts(17,40): error TS1507: There is nothing available for repetition. --regularExpressionScanning.ts(19,12): error TS1517: Range out of order in character class. --regularExpressionScanning.ts(19,15): error TS1517: Range out of order in character class. --regularExpressionScanning.ts(19,28): error TS1517: Range out of order in character class. --regularExpressionScanning.ts(20,3): error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. --regularExpressionScanning.ts(20,8): error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. --regularExpressionScanning.ts(20,16): error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. --regularExpressionScanning.ts(20,25): error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. --regularExpressionScanning.ts(20,28): error TS1529: Unknown Unicode property name or value. --regularExpressionScanning.ts(20,37): error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. --regularExpressionScanning.ts(20,42): error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. --regularExpressionScanning.ts(20,50): error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. --regularExpressionScanning.ts(20,59): error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. --regularExpressionScanning.ts(20,62): error TS1529: Unknown Unicode property name or value. --regularExpressionScanning.ts(21,28): error TS1529: Unknown Unicode property name or value. --regularExpressionScanning.ts(21,62): error TS1529: Unknown Unicode property name or value. --regularExpressionScanning.ts(22,28): error TS1529: Unknown Unicode property name or value. --regularExpressionScanning.ts(22,62): error TS1529: Unknown Unicode property name or value. --regularExpressionScanning.ts(23,3): error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. --regularExpressionScanning.ts(23,6): error TS1524: Unknown Unicode property name. --regularExpressionScanning.ts(23,28): error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. --regularExpressionScanning.ts(23,31): error TS1523: Expected a Unicode property name. --regularExpressionScanning.ts(23,32): error TS1525: Expected a Unicode property value. --regularExpressionScanning.ts(23,33): error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. --regularExpressionScanning.ts(23,39): error TS1525: Expected a Unicode property value. --regularExpressionScanning.ts(23,40): error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. --regularExpressionScanning.ts(23,43): error TS1523: Expected a Unicode property name. --regularExpressionScanning.ts(23,49): error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. --regularExpressionScanning.ts(23,52): error TS1527: Expected a Unicode property name or value. --regularExpressionScanning.ts(23,59): error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. --regularExpressionScanning.ts(23,62): error TS1527: Expected a Unicode property name or value. --regularExpressionScanning.ts(23,63): error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. --regularExpressionScanning.ts(23,66): error TS1527: Expected a Unicode property name or value. --regularExpressionScanning.ts(24,6): error TS1524: Unknown Unicode property name. --regularExpressionScanning.ts(24,31): error TS1523: Expected a Unicode property name. --regularExpressionScanning.ts(24,32): error TS1525: Expected a Unicode property value. --regularExpressionScanning.ts(24,39): error TS1525: Expected a Unicode property value. --regularExpressionScanning.ts(24,43): error TS1523: Expected a Unicode property name. --regularExpressionScanning.ts(24,52): error TS1527: Expected a Unicode property name or value. --regularExpressionScanning.ts(24,53): error TS1531: '\p' must be followed by a Unicode property value expression enclosed in braces. --regularExpressionScanning.ts(24,57): error TS1531: '\P' must be followed by a Unicode property value expression enclosed in braces. --regularExpressionScanning.ts(24,62): error TS1527: Expected a Unicode property name or value. --regularExpressionScanning.ts(24,66): error TS1527: Expected a Unicode property name or value. --regularExpressionScanning.ts(25,6): error TS1524: Unknown Unicode property name. --regularExpressionScanning.ts(25,31): error TS1523: Expected a Unicode property name. --regularExpressionScanning.ts(25,32): error TS1525: Expected a Unicode property value. --regularExpressionScanning.ts(25,39): error TS1525: Expected a Unicode property value. --regularExpressionScanning.ts(25,43): error TS1523: Expected a Unicode property name. --regularExpressionScanning.ts(25,52): error TS1527: Expected a Unicode property name or value. --regularExpressionScanning.ts(25,53): error TS1531: '\p' must be followed by a Unicode property value expression enclosed in braces. --regularExpressionScanning.ts(25,57): error TS1531: '\P' must be followed by a Unicode property value expression enclosed in braces. --regularExpressionScanning.ts(25,62): error TS1527: Expected a Unicode property name or value. --regularExpressionScanning.ts(25,66): error TS1527: Expected a Unicode property name or value. --regularExpressionScanning.ts(26,3): error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. --regularExpressionScanning.ts(26,6): error TS1528: Any Unicode property that would possibly match more than a single character is only available when the Unicode Sets (v) flag is set. --regularExpressionScanning.ts(26,16): error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. --regularExpressionScanning.ts(26,19): error TS1528: Any Unicode property that would possibly match more than a single character is only available when the Unicode Sets (v) flag is set. --regularExpressionScanning.ts(26,31): error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. --regularExpressionScanning.ts(26,34): error TS1528: Any Unicode property that would possibly match more than a single character is only available when the Unicode Sets (v) flag is set. --regularExpressionScanning.ts(26,44): error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. --regularExpressionScanning.ts(26,47): error TS1528: Any Unicode property that would possibly match more than a single character is only available when the Unicode Sets (v) flag is set. --regularExpressionScanning.ts(27,6): error TS1528: Any Unicode property that would possibly match more than a single character is only available when the Unicode Sets (v) flag is set. --regularExpressionScanning.ts(27,19): error TS1528: Any Unicode property that would possibly match more than a single character is only available when the Unicode Sets (v) flag is set. --regularExpressionScanning.ts(27,34): error TS1528: Any Unicode property that would possibly match more than a single character is only available when the Unicode Sets (v) flag is set. --regularExpressionScanning.ts(27,47): error TS1528: Any Unicode property that would possibly match more than a single character is only available when the Unicode Sets (v) flag is set. --regularExpressionScanning.ts(28,19): error TS1518: Anything that would possibly match more than a single character is invalid inside a negated character class. --regularExpressionScanning.ts(28,31): error TS1518: Anything that would possibly match more than a single character is invalid inside a negated character class. --regularExpressionScanning.ts(28,47): error TS1518: Anything that would possibly match more than a single character is invalid inside a negated character class. --regularExpressionScanning.ts(31,3): error TS1512: '\c' must be followed by an ASCII letter. --regularExpressionScanning.ts(31,6): error TS1512: '\c' must be followed by an ASCII letter. --regularExpressionScanning.ts(31,15): error TS1512: '\c' must be followed by an ASCII letter. --regularExpressionScanning.ts(31,17): error TS1535: This character cannot be escaped in a regular expression. --regularExpressionScanning.ts(31,20): error TS1512: '\c' must be followed by an ASCII letter. --regularExpressionScanning.ts(31,23): error TS1535: This character cannot be escaped in a regular expression. --regularExpressionScanning.ts(33,3): error TS1535: This character cannot be escaped in a regular expression. --regularExpressionScanning.ts(33,7): error TS1535: This character cannot be escaped in a regular expression. --regularExpressionScanning.ts(33,10): error TS1535: This character cannot be escaped in a regular expression. --regularExpressionScanning.ts(33,14): error TS1535: This character cannot be escaped in a regular expression. --regularExpressionScanning.ts(33,17): error TS1535: This character cannot be escaped in a regular expression. --regularExpressionScanning.ts(33,21): error TS1535: This character cannot be escaped in a regular expression. --regularExpressionScanning.ts(33,24): error TS1535: This character cannot be escaped in a regular expression. --regularExpressionScanning.ts(33,39): error TS1535: This character cannot be escaped in a regular expression. --regularExpressionScanning.ts(33,41): error TS1508: Unexpected '{'. Did you mean to escape it with backslash? --regularExpressionScanning.ts(33,42): error TS1508: Unexpected ']'. Did you mean to escape it with backslash? --regularExpressionScanning.ts(33,43): error TS1535: This character cannot be escaped in a regular expression. --regularExpressionScanning.ts(33,45): error TS1508: Unexpected '{'. Did you mean to escape it with backslash? --regularExpressionScanning.ts(34,3): error TS1511: '\q' is only available inside character class. --regularExpressionScanning.ts(34,7): error TS1535: This character cannot be escaped in a regular expression. --regularExpressionScanning.ts(34,10): error TS1521: '\q' must be followed by string alternatives enclosed in braces. --regularExpressionScanning.ts(34,17): error TS1535: This character cannot be escaped in a regular expression. --regularExpressionScanning.ts(34,21): error TS1535: This character cannot be escaped in a regular expression. --regularExpressionScanning.ts(34,23): error TS1508: Unexpected '{'. Did you mean to escape it with backslash? --regularExpressionScanning.ts(34,38): error TS1508: Unexpected ']'. Did you mean to escape it with backslash? --regularExpressionScanning.ts(34,39): error TS1535: This character cannot be escaped in a regular expression. --regularExpressionScanning.ts(34,41): error TS1508: Unexpected '{'. Did you mean to escape it with backslash? --regularExpressionScanning.ts(34,42): error TS1508: Unexpected ']'. Did you mean to escape it with backslash? --regularExpressionScanning.ts(34,43): error TS1535: This character cannot be escaped in a regular expression. --regularExpressionScanning.ts(34,45): error TS1508: Unexpected '{'. Did you mean to escape it with backslash? --regularExpressionScanning.ts(34,46): error TS1005: '}' expected. --regularExpressionScanning.ts(36,4): error TS1517: Range out of order in character class. --regularExpressionScanning.ts(36,8): error TS1517: Range out of order in character class. --regularExpressionScanning.ts(36,34): error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. --regularExpressionScanning.ts(36,42): error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. --regularExpressionScanning.ts(36,63): error TS1517: Range out of order in character class. --regularExpressionScanning.ts(37,4): error TS1517: Range out of order in character class. --regularExpressionScanning.ts(37,8): error TS1517: Range out of order in character class. --regularExpressionScanning.ts(37,19): error TS1508: Unexpected ']'. Did you mean to escape it with backslash? --regularExpressionScanning.ts(37,50): error TS1508: Unexpected ']'. Did you mean to escape it with backslash? --regularExpressionScanning.ts(37,51): error TS1508: Unexpected ']'. Did you mean to escape it with backslash? --regularExpressionScanning.ts(37,55): error TS1535: This character cannot be escaped in a regular expression. --regularExpressionScanning.ts(37,57): error TS1508: Unexpected '{'. Did you mean to escape it with backslash? --regularExpressionScanning.ts(37,61): error TS1508: Unexpected '}'. Did you mean to escape it with backslash? --regularExpressionScanning.ts(37,63): error TS1517: Range out of order in character class. --regularExpressionScanning.ts(37,76): error TS1535: This character cannot be escaped in a regular expression. --regularExpressionScanning.ts(38,8): error TS1005: '--' expected. --regularExpressionScanning.ts(38,9): error TS1520: Expected a class set operand. --regularExpressionScanning.ts(38,11): error TS1520: Expected a class set operand. --regularExpressionScanning.ts(38,12): error TS1005: '--' expected. --regularExpressionScanning.ts(38,15): error TS1522: A character class must not contain a reserved double punctuator. Did you mean to escape it with backslash? --regularExpressionScanning.ts(38,20): error TS1519: Operators must not be mixed within a character class. Wrap it in a nested class instead. --regularExpressionScanning.ts(38,28): error TS1519: Operators must not be mixed within a character class. Wrap it in a nested class instead. --regularExpressionScanning.ts(38,40): error TS1519: Operators must not be mixed within a character class. Wrap it in a nested class instead. --regularExpressionScanning.ts(38,47): error TS1519: Operators must not be mixed within a character class. Wrap it in a nested class instead. --regularExpressionScanning.ts(38,49): error TS1519: Operators must not be mixed within a character class. Wrap it in a nested class instead. --regularExpressionScanning.ts(38,50): error TS1520: Expected a class set operand. --regularExpressionScanning.ts(38,55): error TS1511: '\q' is only available inside character class. --regularExpressionScanning.ts(38,57): error TS1508: Unexpected '{'. Did you mean to escape it with backslash? --regularExpressionScanning.ts(38,61): error TS1508: Unexpected '}'. Did you mean to escape it with backslash? --regularExpressionScanning.ts(38,66): error TS1508: Unexpected '-'. Did you mean to escape it with backslash? --regularExpressionScanning.ts(38,67): error TS1005: '--' expected. --regularExpressionScanning.ts(38,70): error TS1520: Expected a class set operand. --regularExpressionScanning.ts(38,75): error TS1508: Unexpected '&'. Did you mean to escape it with backslash? --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(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,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(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,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. --regularExpressionScanning.ts(46,79): error TS1518: Anything that would possibly match more than a single character is invalid inside a negated character class. --regularExpressionScanning.ts(47,5): error TS1518: Anything that would possibly match more than a single character is invalid inside a negated character class. --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) ==== -- const regexes: RegExp[] = [ -- // Flags -- /foo/visualstudiocode, -- ~ --!!! error TS1502: The Unicode (u) flag and the Unicode Sets (v) flag cannot be set simultaneously. -- ~ --!!! error TS1499: Unknown regular expression flag. -- ~ --!!! error TS1499: Unknown regular expression flag. -- ~ --!!! error TS1500: Duplicate regular expression flag. -- ~ --!!! error TS1499: Unknown regular expression flag. -- ~ --!!! error TS1502: The Unicode (u) flag and the Unicode Sets (v) flag cannot be set simultaneously. -- ~ --!!! error TS1500: Duplicate regular expression flag. -- ~ --!!! error TS1499: Unknown regular expression flag. -- ~ --!!! error TS1499: Unknown regular expression flag. -- ~ --!!! error TS1499: Unknown regular expression flag. -- ~ --!!! error TS1500: Duplicate regular expression flag. -- ~ --!!! error TS1499: Unknown regular expression flag. -- // Pattern modifiers -- /(?med-ium:bar)/, -- ~ --!!! error TS1499: Unknown regular expression flag. -- ~ --!!! error TS1509: This regular expression flag cannot be toggled within a subpattern. -- ~ --!!! error TS1509: This regular expression flag cannot be toggled within a subpattern. -- ~ --!!! error TS1500: Duplicate regular expression flag. -- // Capturing groups -- /\0/, -- /\1/, -- ~ --!!! error TS1534: This backreference refers to a group that does not exist. There are no capturing groups in this regular expression. -- /\2/, -- ~ --!!! error TS1534: This backreference refers to a group that does not exist. There are no capturing groups in this regular expression. -- /(hi)\1/, -- /(hi) (hello) \2/, -- /\2()(\12)(foo)\1\0[\0\1\01\123\08\8](\3\03)\5\005\9\009/, -- ~~ --!!! error TS1533: This backreference refers to a group that does not exist. There are only 4 capturing groups in this regular expression. -- ~~ --!!! error TS1536: Octal escape sequences and backreferences are not allowed in a character class. If this was intended as an escape sequence, use the syntax '\x01' instead. -- ~~~ --!!! error TS1487: Octal escape sequences are not allowed. Use the syntax '\x01'. -- ~~~~ --!!! error TS1536: Octal escape sequences and backreferences are not allowed in a character class. If this was intended as an escape sequence, use the syntax '\x53' instead. -- ~~ --!!! error TS1487: Octal escape sequences are not allowed. Use the syntax '\x00'. -- ~~ --!!! error TS1537: Decimal escape sequences and backreferences are not allowed in a character class. -- ~~~ --!!! error TS1487: Octal escape sequences are not allowed. Use the syntax '\x03'. -- ~ --!!! error TS1533: This backreference refers to a group that does not exist. There are only 4 capturing groups in this regular expression. -- ~~~~ --!!! error TS1487: Octal escape sequences are not allowed. Use the syntax '\x05'. -- ~ --!!! error TS1533: This backreference refers to a group that does not exist. There are only 4 capturing groups in this regular expression. -- ~~~ --!!! error TS1487: Octal escape sequences are not allowed. Use the syntax '\x00'. -- /\2()(\12)(foo)\1\0[\0\1\01\123\08\8](\3\03)\5\005\9\009/u, -- ~~ --!!! error TS1533: This backreference refers to a group that does not exist. There are only 4 capturing groups in this regular expression. -- ~~ --!!! error TS1536: Octal escape sequences and backreferences are not allowed in a character class. If this was intended as an escape sequence, use the syntax '\x01' instead. -- ~~~ --!!! error TS1487: Octal escape sequences are not allowed. Use the syntax '\x01'. -- ~~~~ --!!! error TS1536: Octal escape sequences and backreferences are not allowed in a character class. If this was intended as an escape sequence, use the syntax '\x53' instead. -- ~~ --!!! error TS1487: Octal escape sequences are not allowed. Use the syntax '\x00'. -- ~~ --!!! error TS1537: Decimal escape sequences and backreferences are not allowed in a character class. -- ~~~ --!!! error TS1487: Octal escape sequences are not allowed. Use the syntax '\x03'. -- ~ --!!! error TS1533: This backreference refers to a group that does not exist. There are only 4 capturing groups in this regular expression. -- ~~~~ --!!! error TS1487: Octal escape sequences are not allowed. Use the syntax '\x05'. -- ~ --!!! error TS1533: This backreference refers to a group that does not exist. There are only 4 capturing groups in this regular expression. -- ~~~ --!!! error TS1487: Octal escape sequences are not allowed. Use the syntax '\x00'. -- /(?)((?bar)bar)(?baz)|(foo(?foo))(?)/, -- /(\k)\k(?foo)|(?)((?)|(bar(?bar)))/, -- ~~~~~~ --!!! error TS1532: There is no capturing group named 'absent' in this regular expression. -- ~~~ --!!! error TS1515: Named capturing groups with the same name must be mutually exclusive to each other. -- // Quantifiers -- /{}{1,2}_{3}.{4,}?(foo){008}${32,16}\b{064,128}.+&*?\???\n{,256}{\\{,/, -- ~~~~~~~ --!!! error TS1507: There is nothing available for repetition. -- ~~~~~ --!!! error TS1506: Numbers out of order in quantifier. -- ~~~~~~~~~ --!!! error TS1507: There is nothing available for repetition. -- // Character classes -- /[-A-Za-z-z-aZ-A\d_-\d-.-.\r-\n\w-\W]/, -- ~~~ --!!! error TS1517: Range out of order in character class. -- ~~~ --!!! error TS1517: Range out of order in character class. -- ~~~~~ --!!! error TS1517: Range out of order in character class. -- /\p{L}\p{gc=L}\p{ASCII}\p{Invalid}[\p{L}\p{gc=L}\P{ASCII}\p{Invalid}]/, -- ~~~~~ --!!! error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. -- ~~~~~~~~ --!!! error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. -- ~~~~~~~~~ --!!! error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. -- ~~~~~~~~~~~ --!!! error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. -- ~~~~~~~ --!!! error TS1529: Unknown Unicode property name or value. -- ~~~~~ --!!! error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. -- ~~~~~~~~ --!!! error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. -- ~~~~~~~~~ --!!! error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. -- ~~~~~~~~~~~ --!!! error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. -- ~~~~~~~ --!!! error TS1529: Unknown Unicode property name or value. -- /\p{L}\p{gc=L}\p{ASCII}\p{Invalid}[\p{L}\p{gc=L}\P{ASCII}\p{Invalid}]/u, -- ~~~~~~~ --!!! error TS1529: Unknown Unicode property name or value. -- ~~~~~~~ --!!! error TS1529: Unknown Unicode property name or value. -- /\p{L}\p{gc=L}\p{ASCII}\p{Invalid}[\p{L}\p{gc=L}\P{ASCII}\p{Invalid}]/v, -- ~~~~~~~ --!!! error TS1529: Unknown Unicode property name or value. -- ~~~~~~~ --!!! error TS1529: Unknown Unicode property name or value. -- /\p{InvalidProperty=Value}\p{=}\p{sc=}\P{=foo}[\p{}\p\\\P\P{]\p{/, -- ~~~~~~~~~~~~~~~~~~~~~~~~~ --!!! error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. -- ~~~~~~~~~~~~~~~ --!!! error TS1524: Unknown Unicode property name. -- ~~~~~ --!!! error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. -- --!!! error TS1523: Expected a Unicode property name. -- --!!! error TS1525: Expected a Unicode property value. -- ~~~~~~~ --!!! error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. -- --!!! error TS1525: Expected a Unicode property value. -- ~~~~~~~~ --!!! error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. -- --!!! error TS1523: Expected a Unicode property name. -- ~~~~ --!!! error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. -- --!!! error TS1527: Expected a Unicode property name or value. -- ~~~ --!!! error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. -- --!!! error TS1527: Expected a Unicode property name or value. -- ~~~ --!!! error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. -- --!!! error TS1527: Expected a Unicode property name or value. -- /\p{InvalidProperty=Value}\p{=}\p{sc=}\P{=foo}[\p{}\p\\\P\P{]\p{/u, -- ~~~~~~~~~~~~~~~ --!!! error TS1524: Unknown Unicode property name. -- --!!! error TS1523: Expected a Unicode property name. -- --!!! error TS1525: Expected a Unicode property value. -- --!!! error TS1525: Expected a Unicode property value. -- --!!! error TS1523: Expected a Unicode property name. -- --!!! error TS1527: Expected a Unicode property name or value. -- ~~ --!!! error TS1531: '\p' must be followed by a Unicode property value expression enclosed in braces. -- ~~ --!!! error TS1531: '\P' must be followed by a Unicode property value expression enclosed in braces. -- --!!! error TS1527: Expected a Unicode property name or value. -- --!!! error TS1527: Expected a Unicode property name or value. -- /\p{InvalidProperty=Value}\p{=}\p{sc=}\P{=foo}[\p{}\p\\\P\P{]\p{/v, -- ~~~~~~~~~~~~~~~ --!!! error TS1524: Unknown Unicode property name. -- --!!! error TS1523: Expected a Unicode property name. -- --!!! error TS1525: Expected a Unicode property value. -- --!!! error TS1525: Expected a Unicode property value. -- --!!! error TS1523: Expected a Unicode property name. -- --!!! error TS1527: Expected a Unicode property name or value. -- ~~ --!!! error TS1531: '\p' must be followed by a Unicode property value expression enclosed in braces. -- ~~ --!!! error TS1531: '\P' must be followed by a Unicode property value expression enclosed in braces. -- --!!! error TS1527: Expected a Unicode property name or value. -- --!!! error TS1527: Expected a Unicode property name or value. -- /\p{RGI_Emoji}\P{RGI_Emoji}[^\p{RGI_Emoji}\P{RGI_Emoji}]/, -- ~~~~~~~~~~~~~ --!!! error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. -- ~~~~~~~~~ --!!! error TS1528: Any Unicode property that would possibly match more than a single character is only available when the Unicode Sets (v) flag is set. -- ~~~~~~~~~~~~~ --!!! error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. -- ~~~~~~~~~ --!!! error TS1528: Any Unicode property that would possibly match more than a single character is only available when the Unicode Sets (v) flag is set. -- ~~~~~~~~~~~~~ --!!! error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. -- ~~~~~~~~~ --!!! error TS1528: Any Unicode property that would possibly match more than a single character is only available when the Unicode Sets (v) flag is set. -- ~~~~~~~~~~~~~ --!!! error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. -- ~~~~~~~~~ --!!! error TS1528: Any Unicode property that would possibly match more than a single character is only available when the Unicode Sets (v) flag is set. -- /\p{RGI_Emoji}\P{RGI_Emoji}[^\p{RGI_Emoji}\P{RGI_Emoji}]/u, -- ~~~~~~~~~ --!!! error TS1528: Any Unicode property that would possibly match more than a single character is only available when the Unicode Sets (v) flag is set. -- ~~~~~~~~~ --!!! error TS1528: Any Unicode property that would possibly match more than a single character is only available when the Unicode Sets (v) flag is set. -- ~~~~~~~~~ --!!! error TS1528: Any Unicode property that would possibly match more than a single character is only available when the Unicode Sets (v) flag is set. -- ~~~~~~~~~ --!!! error TS1528: Any Unicode property that would possibly match more than a single character is only available when the Unicode Sets (v) flag is set. -- /\p{RGI_Emoji}\P{RGI_Emoji}[^\p{RGI_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 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. -- // Character escapes -- /\c[\c0\ca\cQ\c\C]\c1\C/, -- /\c[\c0\ca\cQ\c\C]\c1\C/u, -- ~~ --!!! error TS1512: '\c' must be followed by an ASCII letter. -- ~~ --!!! error TS1512: '\c' must be followed by an ASCII letter. -- ~~ --!!! error TS1512: '\c' must be followed by an ASCII letter. -- ~~ --!!! error TS1535: This character cannot be escaped in a regular expression. -- ~~ --!!! error TS1512: '\c' must be followed by an ASCII letter. -- ~~ --!!! error TS1535: This character cannot be escaped in a regular expression. -- /\q\\\`[\q\\\`[\Q\\\Q{\q{foo|bar|baz]\q{]\q{/, -- /\q\\\`[\q\\\`[\Q\\\Q{\q{foo|bar|baz]\q{]\q{/u, -- ~~ --!!! error TS1535: This character cannot be escaped in a regular expression. -- ~~ --!!! error TS1535: This character cannot be escaped in a regular expression. -- ~~ --!!! error TS1535: This character cannot be escaped in a regular expression. -- ~~ --!!! error TS1535: This character cannot be escaped in a regular expression. -- ~~ --!!! error TS1535: This character cannot be escaped in a regular expression. -- ~~ --!!! error TS1535: This character cannot be escaped in a regular expression. -- ~~ --!!! error TS1535: This character cannot be escaped in a regular expression. -- ~~ --!!! error TS1535: This character cannot be escaped in a regular expression. -- ~ --!!! error TS1508: Unexpected '{'. Did you mean to escape it with backslash? -- ~ --!!! error TS1508: Unexpected ']'. Did you mean to escape it with backslash? -- ~~ --!!! error TS1535: This character cannot be escaped in a regular expression. -- ~ --!!! error TS1508: Unexpected '{'. Did you mean to escape it with backslash? -- /\q\\\`[\q\\\`[\Q\\\Q{\q{foo|bar|baz]\q{]\q{/v, -- ~~ --!!! error TS1511: '\q' is only available inside character class. -- ~~ --!!! error TS1535: This character cannot be escaped in a regular expression. -- ~~ --!!! error TS1521: '\q' must be followed by string alternatives enclosed in braces. -- ~~ --!!! error TS1535: This character cannot be escaped in a regular expression. -- ~~ --!!! error TS1535: This character cannot be escaped in a regular expression. -- ~ --!!! error TS1508: Unexpected '{'. Did you mean to escape it with backslash? -- ~ --!!! error TS1508: Unexpected ']'. Did you mean to escape it with backslash? -- ~~ --!!! error TS1535: This character cannot be escaped in a regular expression. -- ~ --!!! error TS1508: Unexpected '{'. Did you mean to escape it with backslash? -- ~ --!!! error TS1508: Unexpected ']'. Did you mean to escape it with backslash? -- ~~ --!!! error TS1535: This character cannot be escaped in a regular expression. -- ~ --!!! error TS1508: Unexpected '{'. Did you mean to escape it with backslash? -- --!!! error TS1005: '}' expected. -- // Unicode sets notation -- /[a--b[--][\d++[]]&&[[&0-9--]&&[\p{L}]--\P{L}-_-]]&&&\q{foo}[0---9][&&q&&&\q{bar}&&]/, -- ~~~ --!!! error TS1517: Range out of order in character class. -- ~~~ --!!! error TS1517: Range out of order in character class. -- ~~~~~ --!!! error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. -- ~~~~~ --!!! error TS1530: Unicode property value expressions are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. -- ~~~ --!!! error TS1517: Range out of order in character class. -- /[a--b[--][\d++[]]&&[[&0-9--]&&[\p{L}]--\P{L}-_-]]&&&\q{foo}[0---9][&&q&&&\q{bar}&&]/u, -- ~~~ --!!! error TS1517: Range out of order in character class. -- ~~~ --!!! error TS1517: Range out of order in character class. -- ~ --!!! error TS1508: Unexpected ']'. Did you mean to escape it with backslash? -- ~ --!!! error TS1508: Unexpected ']'. Did you mean to escape it with backslash? -- ~ --!!! error TS1508: Unexpected ']'. Did you mean to escape it with backslash? -- ~~ --!!! error TS1535: This character cannot be escaped in a regular expression. -- ~ --!!! error TS1508: Unexpected '{'. Did you mean to escape it with backslash? -- ~ --!!! error TS1508: Unexpected '}'. Did you mean to escape it with backslash? -- ~~~ --!!! error TS1517: Range out of order in character class. -- ~~ --!!! error TS1535: This character cannot be escaped in a regular expression. -- /[a--b[--][\d++[]]&&[[&0-9--]&&[\p{L}]--\P{L}-_-]]&&&\q{foo}[0---9][&&q&&&\q{bar}&&]/v, -- --!!! error TS1005: '--' expected. -- --!!! error TS1520: Expected a class set operand. -- --!!! error TS1520: Expected a class set operand. -- --!!! error TS1005: '--' expected. -- ~~ --!!! error TS1522: A character class must not contain a reserved double punctuator. Did you mean to escape it with backslash? -- ~~ --!!! error TS1519: Operators must not be mixed within a character class. Wrap it in a nested class instead. -- ~~ --!!! error TS1519: Operators must not be mixed within a character class. Wrap it in a nested class instead. -- ~~ --!!! error TS1519: Operators must not be mixed within a character class. Wrap it in a nested class instead. -- ~ --!!! error TS1519: Operators must not be mixed within a character class. Wrap it in a nested class instead. -- ~ --!!! error TS1519: Operators must not be mixed within a character class. Wrap it in a nested class instead. -- --!!! error TS1520: Expected a class set operand. -- ~~ --!!! error TS1511: '\q' is only available inside character class. -- ~ --!!! error TS1508: Unexpected '{'. Did you mean to escape it with backslash? -- ~ --!!! error TS1508: Unexpected '}'. Did you mean to escape it with backslash? -- ~ --!!! error TS1508: Unexpected '-'. Did you mean to escape it with backslash? -- --!!! error TS1005: '--' expected. -- --!!! error TS1520: Expected a class set operand. -- ~ --!!! error TS1508: Unexpected '&'. Did you mean to escape it with backslash? -- --!!! error TS1520: Expected a class set operand. -- /[[^\P{Decimal_Number}&&[0-9]]&&\p{L}&&\p{ID_Continue}--\p{ASCII}\p{CWCF}]/v, -- ~~ --!!! error TS1519: Operators must not be mixed within a character class. Wrap it in a nested class instead. -- --!!! error TS1005: '&&' expected. -- /[^\p{Emoji}\p{RGI_Emoji}][^\p{Emoji}--\p{RGI_Emoji}][^\p{Emoji}&&\p{RGI_Emoji}]/v, -- /[^\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. -- ~~~~~~~~~~~~~ --!!! 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. -- /[^\p{Emoji}[[\p{RGI_Emoji}]]][^\p{Emoji}--[[\p{RGI_Emoji}]]][^\p{Emoji}&&[[\p{RGI_Emoji}]]]/v, -- /[^[[\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. -- ~~~~~~~~~~~~~~~~~ --!!! 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. -- /[^\q{foo|bar|baz}--\q{foo}--\q{bar}--\q{baz}][^\p{L}--\q{foo}--[\q{bar}]--[^[\q{baz}]]]/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. -- /[^[[\q{foo|bar|baz}]]--\q{foo}--\q{bar}--\q{baz}][^[^[^\p{L}]]--\q{foo}--[\q{bar}]--[^[\q{baz}]]]/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. -- ]; -- -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/regularExpressionUnicodePropertyValueExpressionSuggestions.errors.txt b/testdata/baselines/reference/submodule/compiler/regularExpressionUnicodePropertyValueExpressionSuggestions.errors.txt new file mode 100644 index 0000000000..cf811c2d94 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/regularExpressionUnicodePropertyValueExpressionSuggestions.errors.txt @@ -0,0 +1,25 @@ +regularExpressionUnicodePropertyValueExpressionSuggestions.ts(1,19): error TS1529: Unknown Unicode property name or value. +regularExpressionUnicodePropertyValueExpressionSuggestions.ts(1,28): error TS1524: Unknown Unicode property name. +regularExpressionUnicodePropertyValueExpressionSuggestions.ts(1,45): error TS1526: Unknown Unicode property value. +regularExpressionUnicodePropertyValueExpressionSuggestions.ts(1,57): error TS1524: Unknown Unicode property name. +regularExpressionUnicodePropertyValueExpressionSuggestions.ts(1,93): error TS1526: Unknown Unicode property value. + + +==== regularExpressionUnicodePropertyValueExpressionSuggestions.ts (5 errors) ==== + const regex = /\p{ascii}\p{Sc=Unknown}\p{sc=unknownX}\p{Script_Declensions=Inherited}\p{scx=inherit}/u; + ~~~~~ +!!! error TS1529: Unknown Unicode property name or value. +!!! related TS1369: Did you mean 'ASCII'? + ~~ +!!! error TS1524: Unknown Unicode property name. +!!! related TS1369: Did you mean 'sc'? + ~~~~~~~~ +!!! error TS1526: Unknown Unicode property value. +!!! related TS1369: Did you mean 'Unknown'? + ~~~~~~~~~~~~~~~~~~ +!!! error TS1524: Unknown Unicode property name. +!!! related TS1369: Did you mean 'Script_Extensions'? + ~~~~~~~ +!!! error TS1526: Unknown Unicode property value. +!!! related TS1369: Did you mean 'Inherited'? + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/regularExpressionUnicodePropertyValueExpressionSuggestions.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/regularExpressionUnicodePropertyValueExpressionSuggestions.errors.txt.diff deleted file mode 100644 index 48d7cfe763..0000000000 --- a/testdata/baselines/reference/submodule/compiler/regularExpressionUnicodePropertyValueExpressionSuggestions.errors.txt.diff +++ /dev/null @@ -1,29 +0,0 @@ ---- old.regularExpressionUnicodePropertyValueExpressionSuggestions.errors.txt -+++ new.regularExpressionUnicodePropertyValueExpressionSuggestions.errors.txt -@@= skipped -0, +0 lines =@@ --regularExpressionUnicodePropertyValueExpressionSuggestions.ts(1,19): error TS1529: Unknown Unicode property name or value. --regularExpressionUnicodePropertyValueExpressionSuggestions.ts(1,28): error TS1524: Unknown Unicode property name. --regularExpressionUnicodePropertyValueExpressionSuggestions.ts(1,45): error TS1526: Unknown Unicode property value. --regularExpressionUnicodePropertyValueExpressionSuggestions.ts(1,57): error TS1524: Unknown Unicode property name. --regularExpressionUnicodePropertyValueExpressionSuggestions.ts(1,93): error TS1526: Unknown Unicode property value. -- -- --==== regularExpressionUnicodePropertyValueExpressionSuggestions.ts (5 errors) ==== -- const regex = /\p{ascii}\p{Sc=Unknown}\p{sc=unknownX}\p{Script_Declensions=Inherited}\p{scx=inherit}/u; -- ~~~~~ --!!! error TS1529: Unknown Unicode property name or value. --!!! related TS1369: Did you mean 'ASCII'? -- ~~ --!!! error TS1524: Unknown Unicode property name. --!!! related TS1369: Did you mean 'sc'? -- ~~~~~~~~ --!!! error TS1526: Unknown Unicode property value. --!!! related TS1369: Did you mean 'Unknown'? -- ~~~~~~~~~~~~~~~~~~ --!!! error TS1524: Unknown Unicode property name. --!!! related TS1369: Did you mean 'Script_Extensions'? -- ~~~~~~~ --!!! error TS1526: Unknown Unicode property value. --!!! related TS1369: Did you mean 'Inherited'? -- -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/regularExpressionWithNonBMPFlags.errors.txt b/testdata/baselines/reference/submodule/compiler/regularExpressionWithNonBMPFlags.errors.txt new file mode 100644 index 0000000000..8bcee094eb --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/regularExpressionWithNonBMPFlags.errors.txt @@ -0,0 +1,29 @@ +regularExpressionWithNonBMPFlags.ts(7,18): error TS1499: Unknown regular expression flag. +regularExpressionWithNonBMPFlags.ts(7,19): error TS1499: Unknown regular expression flag. +regularExpressionWithNonBMPFlags.ts(7,21): error TS1499: Unknown regular expression flag. +regularExpressionWithNonBMPFlags.ts(7,30): error TS1499: Unknown regular expression flag. +regularExpressionWithNonBMPFlags.ts(7,31): error TS1499: Unknown regular expression flag. +regularExpressionWithNonBMPFlags.ts(7,32): error TS1499: Unknown regular expression flag. + + +==== regularExpressionWithNonBMPFlags.ts (6 errors) ==== + // The characters in the following regular expression are ASCII-lookalike characters found in Unicode, including: + // - š˜“ (U+1D634 Mathematical Sans-Serif Italic Small S) + // - š˜Ŗ (U+1D62A Mathematical Sans-Serif Italic Small I) + // - š˜® (U+1D62E Mathematical Sans-Serif Italic Small M) + // + // See https://en.wikipedia.org/wiki/Mathematical_Alphanumeric_Symbols + const š˜³š˜¦š˜Øš˜¦š˜¹ = /(?š˜“š˜Ŗ-š˜®:^š˜§š˜°š˜°.)/š˜Øš˜®š˜¶; + ~ +!!! error TS1499: Unknown regular expression flag. + ~ +!!! error TS1499: Unknown regular expression flag. + ~ +!!! error TS1499: Unknown regular expression flag. + ~ +!!! error TS1499: Unknown regular expression flag. + ~ +!!! error TS1499: Unknown regular expression flag. + ~ +!!! error TS1499: Unknown regular expression flag. + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/regularExpressionWithNonBMPFlags.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/regularExpressionWithNonBMPFlags.errors.txt.diff index cd423f64ac..ffedaf83db 100644 --- a/testdata/baselines/reference/submodule/compiler/regularExpressionWithNonBMPFlags.errors.txt.diff +++ b/testdata/baselines/reference/submodule/compiler/regularExpressionWithNonBMPFlags.errors.txt.diff @@ -7,16 +7,19 @@ -regularExpressionWithNonBMPFlags.ts(7,41): error TS1499: Unknown regular expression flag. -regularExpressionWithNonBMPFlags.ts(7,43): error TS1499: Unknown regular expression flag. -regularExpressionWithNonBMPFlags.ts(7,45): error TS1499: Unknown regular expression flag. -- -- --==== regularExpressionWithNonBMPFlags.ts (6 errors) ==== -- // The characters in the following regular expression are ASCII-lookalike characters found in Unicode, including: -- // - š˜“ (U+1D634 Mathematical Sans-Serif Italic Small S) -- // - š˜Ŗ (U+1D62A Mathematical Sans-Serif Italic Small I) -- // - š˜® (U+1D62E Mathematical Sans-Serif Italic Small M) -- // -- // See https://en.wikipedia.org/wiki/Mathematical_Alphanumeric_Symbols -- const š˜³š˜¦š˜Øš˜¦š˜¹ = /(?š˜“š˜Ŗ-š˜®:^š˜§š˜°š˜°.)/š˜Øš˜®š˜¶; ++regularExpressionWithNonBMPFlags.ts(7,18): error TS1499: Unknown regular expression flag. ++regularExpressionWithNonBMPFlags.ts(7,19): error TS1499: Unknown regular expression flag. ++regularExpressionWithNonBMPFlags.ts(7,21): error TS1499: Unknown regular expression flag. ++regularExpressionWithNonBMPFlags.ts(7,30): error TS1499: Unknown regular expression flag. ++regularExpressionWithNonBMPFlags.ts(7,31): error TS1499: Unknown regular expression flag. ++regularExpressionWithNonBMPFlags.ts(7,32): error TS1499: Unknown regular expression flag. + + + ==== regularExpressionWithNonBMPFlags.ts (6 errors) ==== +@@= skipped -13, +13 lines =@@ + // + // See https://en.wikipedia.org/wiki/Mathematical_Alphanumeric_Symbols + const š˜³š˜¦š˜Øš˜¦š˜¹ = /(?š˜“š˜Ŗ-š˜®:^š˜§š˜°š˜°.)/š˜Øš˜®š˜¶; - ~~ -!!! error TS1499: Unknown regular expression flag. - ~~ @@ -28,6 +31,16 @@ - ~~ -!!! error TS1499: Unknown regular expression flag. - ~~ --!!! error TS1499: Unknown regular expression flag. -- -+ \ No newline at end of file ++ ~ ++!!! error TS1499: Unknown regular expression flag. ++ ~ ++!!! error TS1499: Unknown regular expression flag. ++ ~ ++!!! error TS1499: Unknown regular expression flag. ++ ~ ++!!! error TS1499: Unknown regular expression flag. ++ ~ ++!!! error TS1499: Unknown regular expression flag. ++ ~ + !!! error TS1499: Unknown regular expression flag. + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/parser.numericSeparators.unicodeEscape.errors.txt b/testdata/baselines/reference/submodule/conformance/parser.numericSeparators.unicodeEscape.errors.txt index 3540eee22f..10c3bfa576 100644 --- a/testdata/baselines/reference/submodule/conformance/parser.numericSeparators.unicodeEscape.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/parser.numericSeparators.unicodeEscape.errors.txt @@ -1,32 +1,46 @@ 1.ts(1,7): error TS1199: Unterminated Unicode escape sequence. 10.ts(1,5): error TS1125: Hexadecimal digit expected. 11.ts(1,5): error TS1125: Hexadecimal digit expected. +12.ts(1,4): error TS1125: Hexadecimal digit expected. 13.ts(1,5): error TS1125: Hexadecimal digit expected. 14.ts(1,5): error TS1125: Hexadecimal digit expected. 15.ts(1,5): error TS1125: Hexadecimal digit expected. +16.ts(1,5): error TS1125: Hexadecimal digit expected. +16.ts(1,12): error TS1508: Unexpected '}'. Did you mean to escape it with backslash? 17.ts(1,4): error TS1125: Hexadecimal digit expected. 18.ts(1,4): error TS1125: Hexadecimal digit expected. 19.ts(1,4): error TS1125: Hexadecimal digit expected. 2.ts(1,7): error TS1199: Unterminated Unicode escape sequence. +20.ts(1,4): error TS1125: Hexadecimal digit expected. 21.ts(1,4): error TS1125: Hexadecimal digit expected. 22.ts(1,4): error TS1125: Hexadecimal digit expected. 23.ts(1,4): error TS1125: Hexadecimal digit expected. +24.ts(1,4): error TS1125: Hexadecimal digit expected. 25.ts(1,11): error TS1199: Unterminated Unicode escape sequence. 26.ts(1,11): error TS1199: Unterminated Unicode escape sequence. 27.ts(1,11): error TS1199: Unterminated Unicode escape sequence. +28.ts(1,2): error TS1199: Unterminated Unicode escape sequence. +28.ts(1,12): error TS1508: Unexpected '}'. Did you mean to escape it with backslash? 3.ts(1,7): error TS1199: Unterminated Unicode escape sequence. 37.ts(1,7): error TS1199: Unterminated Unicode escape sequence. 38.ts(1,7): error TS1199: Unterminated Unicode escape sequence. 39.ts(1,7): error TS1199: Unterminated Unicode escape sequence. +4.ts(1,2): error TS1199: Unterminated Unicode escape sequence. +4.ts(1,12): error TS1508: Unexpected '}'. Did you mean to escape it with backslash? +40.ts(1,2): error TS1199: Unterminated Unicode escape sequence. +40.ts(1,13): error TS1508: Unexpected '}'. Did you mean to escape it with backslash? 41.ts(1,6): error TS1125: Hexadecimal digit expected. 42.ts(1,6): error TS1125: Hexadecimal digit expected. 43.ts(1,6): error TS1125: Hexadecimal digit expected. +44.ts(1,4): error TS1125: Hexadecimal digit expected. 45.ts(1,5): error TS1125: Hexadecimal digit expected. 46.ts(1,5): error TS1125: Hexadecimal digit expected. 47.ts(1,5): error TS1125: Hexadecimal digit expected. +48.ts(1,4): error TS1125: Hexadecimal digit expected. 5.ts(1,6): error TS1125: Hexadecimal digit expected. 6.ts(1,6): error TS1125: Hexadecimal digit expected. 7.ts(1,6): error TS1125: Hexadecimal digit expected. +8.ts(1,4): error TS1125: Hexadecimal digit expected. 9.ts(1,5): error TS1125: Hexadecimal digit expected. @@ -45,8 +59,12 @@ !!! error TS1199: Unterminated Unicode escape sequence. -==== 4.ts (0 errors) ==== +==== 4.ts (2 errors) ==== /\u{10_ffff}/u + ~~~~~ +!!! error TS1199: Unterminated Unicode escape sequence. + ~ +!!! error TS1508: Unexpected '}'. Did you mean to escape it with backslash? ==== 5.ts (1 errors) ==== "\uff_ff" @@ -63,8 +81,10 @@ !!! error TS1125: Hexadecimal digit expected. -==== 8.ts (0 errors) ==== +==== 8.ts (1 errors) ==== /\uff_ff/u + ~~ +!!! error TS1125: Hexadecimal digit expected. ==== 9.ts (1 errors) ==== "\xf_f" @@ -81,8 +101,10 @@ !!! error TS1125: Hexadecimal digit expected. -==== 12.ts (0 errors) ==== +==== 12.ts (1 errors) ==== /\xf_f/u + ~ +!!! error TS1125: Hexadecimal digit expected. ==== 13.ts (1 errors) ==== "\u{_10ffff}" @@ -99,8 +121,12 @@ !!! error TS1125: Hexadecimal digit expected. -==== 16.ts (0 errors) ==== +==== 16.ts (2 errors) ==== /\u{_10ffff}/u + +!!! error TS1125: Hexadecimal digit expected. + ~ +!!! error TS1508: Unexpected '}'. Did you mean to escape it with backslash? ==== 17.ts (1 errors) ==== "\u_ffff" @@ -117,8 +143,10 @@ !!! error TS1125: Hexadecimal digit expected. -==== 20.ts (0 errors) ==== +==== 20.ts (1 errors) ==== /\u_ffff/u + +!!! error TS1125: Hexadecimal digit expected. ==== 21.ts (1 errors) ==== "\x_ff" @@ -135,8 +163,10 @@ !!! error TS1125: Hexadecimal digit expected. -==== 24.ts (0 errors) ==== +==== 24.ts (1 errors) ==== /\x_ff/u + +!!! error TS1125: Hexadecimal digit expected. ==== 25.ts (1 errors) ==== "\u{10ffff_}" @@ -153,8 +183,12 @@ !!! error TS1199: Unterminated Unicode escape sequence. -==== 28.ts (0 errors) ==== +==== 28.ts (2 errors) ==== /\u{10ffff_}/u + ~~~~~~~~~ +!!! error TS1199: Unterminated Unicode escape sequence. + ~ +!!! error TS1508: Unexpected '}'. Did you mean to escape it with backslash? ==== 29.ts (0 errors) ==== "\uffff_" @@ -195,8 +229,12 @@ !!! error TS1199: Unterminated Unicode escape sequence. -==== 40.ts (0 errors) ==== +==== 40.ts (2 errors) ==== /\u{10__ffff}/u + ~~~~~ +!!! error TS1199: Unterminated Unicode escape sequence. + ~ +!!! error TS1508: Unexpected '}'. Did you mean to escape it with backslash? ==== 41.ts (1 errors) ==== "\uff__ff" @@ -213,8 +251,10 @@ !!! error TS1125: Hexadecimal digit expected. -==== 44.ts (0 errors) ==== +==== 44.ts (1 errors) ==== /\uff__ff/u + ~~ +!!! error TS1125: Hexadecimal digit expected. ==== 45.ts (1 errors) ==== "\xf__f" @@ -231,6 +271,8 @@ !!! error TS1125: Hexadecimal digit expected. -==== 48.ts (0 errors) ==== +==== 48.ts (1 errors) ==== /\xf__f/u + ~ +!!! error TS1125: Hexadecimal digit expected. \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/parser.numericSeparators.unicodeEscape.errors.txt.diff b/testdata/baselines/reference/submodule/conformance/parser.numericSeparators.unicodeEscape.errors.txt.diff index 474fe947ce..0cce15a967 100644 --- a/testdata/baselines/reference/submodule/conformance/parser.numericSeparators.unicodeEscape.errors.txt.diff +++ b/testdata/baselines/reference/submodule/conformance/parser.numericSeparators.unicodeEscape.errors.txt.diff @@ -5,171 +5,104 @@ 10.ts(1,5): error TS1125: Hexadecimal digit expected. 11.ts(1,5): error TS1125: Hexadecimal digit expected. -12.ts(1,5): error TS1125: Hexadecimal digit expected. ++12.ts(1,4): error TS1125: Hexadecimal digit expected. 13.ts(1,5): error TS1125: Hexadecimal digit expected. 14.ts(1,5): error TS1125: Hexadecimal digit expected. 15.ts(1,5): error TS1125: Hexadecimal digit expected. --16.ts(1,5): error TS1125: Hexadecimal digit expected. --16.ts(1,12): error TS1508: Unexpected '}'. Did you mean to escape it with backslash? - 17.ts(1,4): error TS1125: Hexadecimal digit expected. - 18.ts(1,4): error TS1125: Hexadecimal digit expected. - 19.ts(1,4): error TS1125: Hexadecimal digit expected. - 2.ts(1,7): error TS1199: Unterminated Unicode escape sequence. --20.ts(1,4): error TS1125: Hexadecimal digit expected. - 21.ts(1,4): error TS1125: Hexadecimal digit expected. - 22.ts(1,4): error TS1125: Hexadecimal digit expected. - 23.ts(1,4): error TS1125: Hexadecimal digit expected. --24.ts(1,4): error TS1125: Hexadecimal digit expected. +@@= skipped -18, +18 lines =@@ 25.ts(1,11): error TS1199: Unterminated Unicode escape sequence. 26.ts(1,11): error TS1199: Unterminated Unicode escape sequence. 27.ts(1,11): error TS1199: Unterminated Unicode escape sequence. -28.ts(1,11): error TS1199: Unterminated Unicode escape sequence. --28.ts(1,12): error TS1508: Unexpected '}'. Did you mean to escape it with backslash? ++28.ts(1,2): error TS1199: Unterminated Unicode escape sequence. + 28.ts(1,12): error TS1508: Unexpected '}'. Did you mean to escape it with backslash? 3.ts(1,7): error TS1199: Unterminated Unicode escape sequence. 37.ts(1,7): error TS1199: Unterminated Unicode escape sequence. 38.ts(1,7): error TS1199: Unterminated Unicode escape sequence. 39.ts(1,7): error TS1199: Unterminated Unicode escape sequence. -4.ts(1,7): error TS1199: Unterminated Unicode escape sequence. --4.ts(1,12): error TS1508: Unexpected '}'. Did you mean to escape it with backslash? ++4.ts(1,2): error TS1199: Unterminated Unicode escape sequence. + 4.ts(1,12): error TS1508: Unexpected '}'. Did you mean to escape it with backslash? -40.ts(1,7): error TS1199: Unterminated Unicode escape sequence. --40.ts(1,13): error TS1508: Unexpected '}'. Did you mean to escape it with backslash? ++40.ts(1,2): error TS1199: Unterminated Unicode escape sequence. + 40.ts(1,13): error TS1508: Unexpected '}'. Did you mean to escape it with backslash? 41.ts(1,6): error TS1125: Hexadecimal digit expected. 42.ts(1,6): error TS1125: Hexadecimal digit expected. 43.ts(1,6): error TS1125: Hexadecimal digit expected. -44.ts(1,6): error TS1125: Hexadecimal digit expected. ++44.ts(1,4): error TS1125: Hexadecimal digit expected. 45.ts(1,5): error TS1125: Hexadecimal digit expected. 46.ts(1,5): error TS1125: Hexadecimal digit expected. 47.ts(1,5): error TS1125: Hexadecimal digit expected. -48.ts(1,5): error TS1125: Hexadecimal digit expected. ++48.ts(1,4): error TS1125: Hexadecimal digit expected. 5.ts(1,6): error TS1125: Hexadecimal digit expected. 6.ts(1,6): error TS1125: Hexadecimal digit expected. 7.ts(1,6): error TS1125: Hexadecimal digit expected. -8.ts(1,6): error TS1125: Hexadecimal digit expected. ++8.ts(1,4): error TS1125: Hexadecimal digit expected. 9.ts(1,5): error TS1125: Hexadecimal digit expected. -@@= skipped -58, +44 lines =@@ - - !!! error TS1199: Unterminated Unicode escape sequence. +@@= skipped -42, +42 lines =@@ --==== 4.ts (2 errors) ==== -+==== 4.ts (0 errors) ==== + ==== 4.ts (2 errors) ==== /\u{10_ffff}/u - --!!! error TS1199: Unterminated Unicode escape sequence. -- ~ --!!! error TS1508: Unexpected '}'. Did you mean to escape it with backslash? - - ==== 5.ts (1 errors) ==== - "\uff_ff" -@@= skipped -22, +18 lines =@@ - - !!! error TS1125: Hexadecimal digit expected. ++ ~~~~~ + !!! error TS1199: Unterminated Unicode escape sequence. + ~ + !!! error TS1508: Unexpected '}'. Did you mean to escape it with backslash? +@@= skipped -22, +22 lines =@@ --==== 8.ts (1 errors) ==== -+==== 8.ts (0 errors) ==== + ==== 8.ts (1 errors) ==== /\uff_ff/u - --!!! error TS1125: Hexadecimal digit expected. ++ ~~ + !!! error TS1125: Hexadecimal digit expected. ==== 9.ts (1 errors) ==== - "\xf_f" -@@= skipped -20, +18 lines =@@ - - !!! error TS1125: Hexadecimal digit expected. +@@= skipped -20, +20 lines =@@ --==== 12.ts (1 errors) ==== -+==== 12.ts (0 errors) ==== + ==== 12.ts (1 errors) ==== /\xf_f/u - --!!! error TS1125: Hexadecimal digit expected. - - ==== 13.ts (1 errors) ==== - "\u{_10ffff}" -@@= skipped -20, +18 lines =@@ - - !!! error TS1125: Hexadecimal digit expected. - --==== 16.ts (2 errors) ==== -+==== 16.ts (0 errors) ==== - /\u{_10ffff}/u -- --!!! error TS1125: Hexadecimal digit expected. -- ~ --!!! error TS1508: Unexpected '}'. Did you mean to escape it with backslash? - - ==== 17.ts (1 errors) ==== - "\u_ffff" -@@= skipped -22, +18 lines =@@ - ++ ~ !!! error TS1125: Hexadecimal digit expected. --==== 20.ts (1 errors) ==== -+==== 20.ts (0 errors) ==== - /\u_ffff/u -- --!!! error TS1125: Hexadecimal digit expected. - - ==== 21.ts (1 errors) ==== - "\x_ff" -@@= skipped -20, +18 lines =@@ - - !!! error TS1125: Hexadecimal digit expected. - --==== 24.ts (1 errors) ==== -+==== 24.ts (0 errors) ==== - /\x_ff/u -- --!!! error TS1125: Hexadecimal digit expected. - - ==== 25.ts (1 errors) ==== - "\u{10ffff_}" -@@= skipped -20, +18 lines =@@ - - !!! error TS1199: Unterminated Unicode escape sequence. + ==== 13.ts (1 errors) ==== +@@= skipped -82, +82 lines =@@ --==== 28.ts (2 errors) ==== -+==== 28.ts (0 errors) ==== + ==== 28.ts (2 errors) ==== /\u{10ffff_}/u - --!!! error TS1199: Unterminated Unicode escape sequence. -- ~ --!!! error TS1508: Unexpected '}'. Did you mean to escape it with backslash? - - ==== 29.ts (0 errors) ==== - "\uffff_" -@@= skipped -46, +42 lines =@@ - ++ ~~~~~~~~~ !!! error TS1199: Unterminated Unicode escape sequence. + ~ + !!! error TS1508: Unexpected '}'. Did you mean to escape it with backslash? +@@= skipped -46, +46 lines =@@ --==== 40.ts (2 errors) ==== -+==== 40.ts (0 errors) ==== + ==== 40.ts (2 errors) ==== /\u{10__ffff}/u - --!!! error TS1199: Unterminated Unicode escape sequence. -- ~ --!!! error TS1508: Unexpected '}'. Did you mean to escape it with backslash? - - ==== 41.ts (1 errors) ==== - "\uff__ff" -@@= skipped -22, +18 lines =@@ - - !!! error TS1125: Hexadecimal digit expected. ++ ~~~~~ + !!! error TS1199: Unterminated Unicode escape sequence. + ~ + !!! error TS1508: Unexpected '}'. Did you mean to escape it with backslash? +@@= skipped -22, +22 lines =@@ --==== 44.ts (1 errors) ==== -+==== 44.ts (0 errors) ==== + ==== 44.ts (1 errors) ==== /\uff__ff/u - --!!! error TS1125: Hexadecimal digit expected. ++ ~~ + !!! error TS1125: Hexadecimal digit expected. ==== 45.ts (1 errors) ==== - "\xf__f" -@@= skipped -20, +18 lines =@@ - - !!! error TS1125: Hexadecimal digit expected. +@@= skipped -20, +20 lines =@@ --==== 48.ts (1 errors) ==== -+==== 48.ts (0 errors) ==== + ==== 48.ts (1 errors) ==== /\xf__f/u - --!!! error TS1125: Hexadecimal digit expected. ++ ~ + !!! error TS1125: Hexadecimal digit expected. \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/parser579071.errors.txt b/testdata/baselines/reference/submodule/conformance/parser579071.errors.txt new file mode 100644 index 0000000000..577810615d --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/parser579071.errors.txt @@ -0,0 +1,7 @@ +parser579071.ts(1,14): error TS1005: ')' expected. + + +==== parser579071.ts (1 errors) ==== + var x = /fo(o/; + +!!! error TS1005: ')' expected. \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/parser579071.errors.txt.diff b/testdata/baselines/reference/submodule/conformance/parser579071.errors.txt.diff deleted file mode 100644 index b5039f7191..0000000000 --- a/testdata/baselines/reference/submodule/conformance/parser579071.errors.txt.diff +++ /dev/null @@ -1,11 +0,0 @@ ---- old.parser579071.errors.txt -+++ new.parser579071.errors.txt -@@= skipped -0, +0 lines =@@ --parser579071.ts(1,14): error TS1005: ')' expected. -- -- --==== parser579071.ts (1 errors) ==== -- var x = /fo(o/; -- --!!! error TS1005: ')' expected. -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/parserRegularExpressionDivideAmbiguity3.errors.txt b/testdata/baselines/reference/submodule/conformance/parserRegularExpressionDivideAmbiguity3.errors.txt index 1c021a9ba8..8c8babab6a 100644 --- a/testdata/baselines/reference/submodule/conformance/parserRegularExpressionDivideAmbiguity3.errors.txt +++ b/testdata/baselines/reference/submodule/conformance/parserRegularExpressionDivideAmbiguity3.errors.txt @@ -1,7 +1,10 @@ +parserRegularExpressionDivideAmbiguity3.ts(1,16): error TS1499: Unknown regular expression flag. parserRegularExpressionDivideAmbiguity3.ts(1,18): error TS2339: Property 'foo' does not exist on type 'RegExp'. -==== parserRegularExpressionDivideAmbiguity3.ts (1 errors) ==== +==== parserRegularExpressionDivideAmbiguity3.ts (2 errors) ==== if (1) /regexp/a.foo(); + ~ +!!! error TS1499: Unknown regular expression flag. ~~~ !!! error TS2339: Property 'foo' does not exist on type 'RegExp'. \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/parserRegularExpressionDivideAmbiguity3.errors.txt.diff b/testdata/baselines/reference/submodule/conformance/parserRegularExpressionDivideAmbiguity3.errors.txt.diff deleted file mode 100644 index 8834a567f0..0000000000 --- a/testdata/baselines/reference/submodule/conformance/parserRegularExpressionDivideAmbiguity3.errors.txt.diff +++ /dev/null @@ -1,14 +0,0 @@ ---- old.parserRegularExpressionDivideAmbiguity3.errors.txt -+++ new.parserRegularExpressionDivideAmbiguity3.errors.txt -@@= skipped -0, +0 lines =@@ --parserRegularExpressionDivideAmbiguity3.ts(1,16): error TS1499: Unknown regular expression flag. - parserRegularExpressionDivideAmbiguity3.ts(1,18): error TS2339: Property 'foo' does not exist on type 'RegExp'. - - --==== parserRegularExpressionDivideAmbiguity3.ts (2 errors) ==== -+==== parserRegularExpressionDivideAmbiguity3.ts (1 errors) ==== - if (1) /regexp/a.foo(); -- ~ --!!! error TS1499: Unknown regular expression flag. - ~~~ - !!! error TS2339: Property 'foo' does not exist on type 'RegExp'. \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/unicodeExtendedEscapesInRegularExpressions14(target=es5).errors.txt b/testdata/baselines/reference/submodule/conformance/unicodeExtendedEscapesInRegularExpressions14(target=es5).errors.txt new file mode 100644 index 0000000000..2f7010fdb3 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/unicodeExtendedEscapesInRegularExpressions14(target=es5).errors.txt @@ -0,0 +1,12 @@ +unicodeExtendedEscapesInRegularExpressions14.ts(2,13): error TS1125: Hexadecimal digit expected. +unicodeExtendedEscapesInRegularExpressions14.ts(2,18): error TS1508: Unexpected '}'. Did you mean to escape it with backslash? + + +==== unicodeExtendedEscapesInRegularExpressions14.ts (2 errors) ==== + // Shouldn't work, negatives are not allowed. + var x = /\u{-DDDD}/gu; + +!!! error TS1125: Hexadecimal digit expected. + ~ +!!! error TS1508: Unexpected '}'. Did you mean to escape it with backslash? + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/unicodeExtendedEscapesInRegularExpressions14(target=es5).errors.txt.diff b/testdata/baselines/reference/submodule/conformance/unicodeExtendedEscapesInRegularExpressions14(target=es5).errors.txt.diff deleted file mode 100644 index f943eef2ad..0000000000 --- a/testdata/baselines/reference/submodule/conformance/unicodeExtendedEscapesInRegularExpressions14(target=es5).errors.txt.diff +++ /dev/null @@ -1,16 +0,0 @@ ---- old.unicodeExtendedEscapesInRegularExpressions14(target=es5).errors.txt -+++ new.unicodeExtendedEscapesInRegularExpressions14(target=es5).errors.txt -@@= skipped -0, +0 lines =@@ --unicodeExtendedEscapesInRegularExpressions14.ts(2,13): error TS1125: Hexadecimal digit expected. --unicodeExtendedEscapesInRegularExpressions14.ts(2,18): error TS1508: Unexpected '}'. Did you mean to escape it with backslash? -- -- --==== unicodeExtendedEscapesInRegularExpressions14.ts (2 errors) ==== -- // Shouldn't work, negatives are not allowed. -- var x = /\u{-DDDD}/gu; -- --!!! error TS1125: Hexadecimal digit expected. -- ~ --!!! error TS1508: Unexpected '}'. Did you mean to escape it with backslash? -- -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/unicodeExtendedEscapesInRegularExpressions14(target=es6).errors.txt b/testdata/baselines/reference/submodule/conformance/unicodeExtendedEscapesInRegularExpressions14(target=es6).errors.txt new file mode 100644 index 0000000000..2f7010fdb3 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/unicodeExtendedEscapesInRegularExpressions14(target=es6).errors.txt @@ -0,0 +1,12 @@ +unicodeExtendedEscapesInRegularExpressions14.ts(2,13): error TS1125: Hexadecimal digit expected. +unicodeExtendedEscapesInRegularExpressions14.ts(2,18): error TS1508: Unexpected '}'. Did you mean to escape it with backslash? + + +==== unicodeExtendedEscapesInRegularExpressions14.ts (2 errors) ==== + // Shouldn't work, negatives are not allowed. + var x = /\u{-DDDD}/gu; + +!!! error TS1125: Hexadecimal digit expected. + ~ +!!! error TS1508: Unexpected '}'. Did you mean to escape it with backslash? + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/unicodeExtendedEscapesInRegularExpressions14(target=es6).errors.txt.diff b/testdata/baselines/reference/submodule/conformance/unicodeExtendedEscapesInRegularExpressions14(target=es6).errors.txt.diff deleted file mode 100644 index 0dfb17a99f..0000000000 --- a/testdata/baselines/reference/submodule/conformance/unicodeExtendedEscapesInRegularExpressions14(target=es6).errors.txt.diff +++ /dev/null @@ -1,16 +0,0 @@ ---- old.unicodeExtendedEscapesInRegularExpressions14(target=es6).errors.txt -+++ new.unicodeExtendedEscapesInRegularExpressions14(target=es6).errors.txt -@@= skipped -0, +0 lines =@@ --unicodeExtendedEscapesInRegularExpressions14.ts(2,13): error TS1125: Hexadecimal digit expected. --unicodeExtendedEscapesInRegularExpressions14.ts(2,18): error TS1508: Unexpected '}'. Did you mean to escape it with backslash? -- -- --==== unicodeExtendedEscapesInRegularExpressions14.ts (2 errors) ==== -- // Shouldn't work, negatives are not allowed. -- var x = /\u{-DDDD}/gu; -- --!!! error TS1125: Hexadecimal digit expected. -- ~ --!!! error TS1508: Unexpected '}'. Did you mean to escape it with backslash? -- -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/unicodeExtendedEscapesInRegularExpressions17(target=es5).errors.txt b/testdata/baselines/reference/submodule/conformance/unicodeExtendedEscapesInRegularExpressions17(target=es5).errors.txt new file mode 100644 index 0000000000..25e6af1498 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/unicodeExtendedEscapesInRegularExpressions17(target=es5).errors.txt @@ -0,0 +1,23 @@ +unicodeExtendedEscapesInRegularExpressions17.ts(1,13): error TS1125: Hexadecimal digit expected. +unicodeExtendedEscapesInRegularExpressions17.ts(1,14): error TS1508: Unexpected '}'. Did you mean to escape it with backslash? +unicodeExtendedEscapesInRegularExpressions17.ts(1,18): error TS1125: Hexadecimal digit expected. +unicodeExtendedEscapesInRegularExpressions17.ts(1,19): error TS1508: Unexpected '}'. Did you mean to escape it with backslash? +unicodeExtendedEscapesInRegularExpressions17.ts(1,23): error TS1125: Hexadecimal digit expected. +unicodeExtendedEscapesInRegularExpressions17.ts(1,24): error TS1508: Unexpected '}'. Did you mean to escape it with backslash? + + +==== unicodeExtendedEscapesInRegularExpressions17.ts (6 errors) ==== + var x = /\u{r}\u{n}\u{t}/gu; + +!!! error TS1125: Hexadecimal digit expected. + ~ +!!! error TS1508: Unexpected '}'. Did you mean to escape it with backslash? + +!!! error TS1125: Hexadecimal digit expected. + ~ +!!! error TS1508: Unexpected '}'. Did you mean to escape it with backslash? + +!!! error TS1125: Hexadecimal digit expected. + ~ +!!! error TS1508: Unexpected '}'. Did you mean to escape it with backslash? + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/unicodeExtendedEscapesInRegularExpressions17(target=es5).errors.txt.diff b/testdata/baselines/reference/submodule/conformance/unicodeExtendedEscapesInRegularExpressions17(target=es5).errors.txt.diff deleted file mode 100644 index ca58b1dcb1..0000000000 --- a/testdata/baselines/reference/submodule/conformance/unicodeExtendedEscapesInRegularExpressions17(target=es5).errors.txt.diff +++ /dev/null @@ -1,27 +0,0 @@ ---- old.unicodeExtendedEscapesInRegularExpressions17(target=es5).errors.txt -+++ new.unicodeExtendedEscapesInRegularExpressions17(target=es5).errors.txt -@@= skipped -0, +0 lines =@@ --unicodeExtendedEscapesInRegularExpressions17.ts(1,13): error TS1125: Hexadecimal digit expected. --unicodeExtendedEscapesInRegularExpressions17.ts(1,14): error TS1508: Unexpected '}'. Did you mean to escape it with backslash? --unicodeExtendedEscapesInRegularExpressions17.ts(1,18): error TS1125: Hexadecimal digit expected. --unicodeExtendedEscapesInRegularExpressions17.ts(1,19): error TS1508: Unexpected '}'. Did you mean to escape it with backslash? --unicodeExtendedEscapesInRegularExpressions17.ts(1,23): error TS1125: Hexadecimal digit expected. --unicodeExtendedEscapesInRegularExpressions17.ts(1,24): error TS1508: Unexpected '}'. Did you mean to escape it with backslash? -- -- --==== unicodeExtendedEscapesInRegularExpressions17.ts (6 errors) ==== -- var x = /\u{r}\u{n}\u{t}/gu; -- --!!! error TS1125: Hexadecimal digit expected. -- ~ --!!! error TS1508: Unexpected '}'. Did you mean to escape it with backslash? -- --!!! error TS1125: Hexadecimal digit expected. -- ~ --!!! error TS1508: Unexpected '}'. Did you mean to escape it with backslash? -- --!!! error TS1125: Hexadecimal digit expected. -- ~ --!!! error TS1508: Unexpected '}'. Did you mean to escape it with backslash? -- -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/unicodeExtendedEscapesInRegularExpressions17(target=es6).errors.txt b/testdata/baselines/reference/submodule/conformance/unicodeExtendedEscapesInRegularExpressions17(target=es6).errors.txt new file mode 100644 index 0000000000..25e6af1498 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/unicodeExtendedEscapesInRegularExpressions17(target=es6).errors.txt @@ -0,0 +1,23 @@ +unicodeExtendedEscapesInRegularExpressions17.ts(1,13): error TS1125: Hexadecimal digit expected. +unicodeExtendedEscapesInRegularExpressions17.ts(1,14): error TS1508: Unexpected '}'. Did you mean to escape it with backslash? +unicodeExtendedEscapesInRegularExpressions17.ts(1,18): error TS1125: Hexadecimal digit expected. +unicodeExtendedEscapesInRegularExpressions17.ts(1,19): error TS1508: Unexpected '}'. Did you mean to escape it with backslash? +unicodeExtendedEscapesInRegularExpressions17.ts(1,23): error TS1125: Hexadecimal digit expected. +unicodeExtendedEscapesInRegularExpressions17.ts(1,24): error TS1508: Unexpected '}'. Did you mean to escape it with backslash? + + +==== unicodeExtendedEscapesInRegularExpressions17.ts (6 errors) ==== + var x = /\u{r}\u{n}\u{t}/gu; + +!!! error TS1125: Hexadecimal digit expected. + ~ +!!! error TS1508: Unexpected '}'. Did you mean to escape it with backslash? + +!!! error TS1125: Hexadecimal digit expected. + ~ +!!! error TS1508: Unexpected '}'. Did you mean to escape it with backslash? + +!!! error TS1125: Hexadecimal digit expected. + ~ +!!! error TS1508: Unexpected '}'. Did you mean to escape it with backslash? + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/unicodeExtendedEscapesInRegularExpressions17(target=es6).errors.txt.diff b/testdata/baselines/reference/submodule/conformance/unicodeExtendedEscapesInRegularExpressions17(target=es6).errors.txt.diff deleted file mode 100644 index 87176ce857..0000000000 --- a/testdata/baselines/reference/submodule/conformance/unicodeExtendedEscapesInRegularExpressions17(target=es6).errors.txt.diff +++ /dev/null @@ -1,27 +0,0 @@ ---- old.unicodeExtendedEscapesInRegularExpressions17(target=es6).errors.txt -+++ new.unicodeExtendedEscapesInRegularExpressions17(target=es6).errors.txt -@@= skipped -0, +0 lines =@@ --unicodeExtendedEscapesInRegularExpressions17.ts(1,13): error TS1125: Hexadecimal digit expected. --unicodeExtendedEscapesInRegularExpressions17.ts(1,14): error TS1508: Unexpected '}'. Did you mean to escape it with backslash? --unicodeExtendedEscapesInRegularExpressions17.ts(1,18): error TS1125: Hexadecimal digit expected. --unicodeExtendedEscapesInRegularExpressions17.ts(1,19): error TS1508: Unexpected '}'. Did you mean to escape it with backslash? --unicodeExtendedEscapesInRegularExpressions17.ts(1,23): error TS1125: Hexadecimal digit expected. --unicodeExtendedEscapesInRegularExpressions17.ts(1,24): error TS1508: Unexpected '}'. Did you mean to escape it with backslash? -- -- --==== unicodeExtendedEscapesInRegularExpressions17.ts (6 errors) ==== -- var x = /\u{r}\u{n}\u{t}/gu; -- --!!! error TS1125: Hexadecimal digit expected. -- ~ --!!! error TS1508: Unexpected '}'. Did you mean to escape it with backslash? -- --!!! error TS1125: Hexadecimal digit expected. -- ~ --!!! error TS1508: Unexpected '}'. Did you mean to escape it with backslash? -- --!!! error TS1125: Hexadecimal digit expected. -- ~ --!!! error TS1508: Unexpected '}'. Did you mean to escape it with backslash? -- -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/unicodeExtendedEscapesInRegularExpressions19(target=es5).errors.txt b/testdata/baselines/reference/submodule/conformance/unicodeExtendedEscapesInRegularExpressions19(target=es5).errors.txt new file mode 100644 index 0000000000..dadcab40d9 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/unicodeExtendedEscapesInRegularExpressions19(target=es5).errors.txt @@ -0,0 +1,8 @@ +unicodeExtendedEscapesInRegularExpressions19.ts(1,13): error TS1125: Hexadecimal digit expected. + + +==== unicodeExtendedEscapesInRegularExpressions19.ts (1 errors) ==== + var x = /\u{}/gu; + +!!! error TS1125: Hexadecimal digit expected. + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/unicodeExtendedEscapesInRegularExpressions19(target=es5).errors.txt.diff b/testdata/baselines/reference/submodule/conformance/unicodeExtendedEscapesInRegularExpressions19(target=es5).errors.txt.diff deleted file mode 100644 index 21a88600ef..0000000000 --- a/testdata/baselines/reference/submodule/conformance/unicodeExtendedEscapesInRegularExpressions19(target=es5).errors.txt.diff +++ /dev/null @@ -1,12 +0,0 @@ ---- old.unicodeExtendedEscapesInRegularExpressions19(target=es5).errors.txt -+++ new.unicodeExtendedEscapesInRegularExpressions19(target=es5).errors.txt -@@= skipped -0, +0 lines =@@ --unicodeExtendedEscapesInRegularExpressions19.ts(1,13): error TS1125: Hexadecimal digit expected. -- -- --==== unicodeExtendedEscapesInRegularExpressions19.ts (1 errors) ==== -- var x = /\u{}/gu; -- --!!! error TS1125: Hexadecimal digit expected. -- -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/unicodeExtendedEscapesInRegularExpressions19(target=es6).errors.txt b/testdata/baselines/reference/submodule/conformance/unicodeExtendedEscapesInRegularExpressions19(target=es6).errors.txt new file mode 100644 index 0000000000..dadcab40d9 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/unicodeExtendedEscapesInRegularExpressions19(target=es6).errors.txt @@ -0,0 +1,8 @@ +unicodeExtendedEscapesInRegularExpressions19.ts(1,13): error TS1125: Hexadecimal digit expected. + + +==== unicodeExtendedEscapesInRegularExpressions19.ts (1 errors) ==== + var x = /\u{}/gu; + +!!! error TS1125: Hexadecimal digit expected. + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/unicodeExtendedEscapesInRegularExpressions19(target=es6).errors.txt.diff b/testdata/baselines/reference/submodule/conformance/unicodeExtendedEscapesInRegularExpressions19(target=es6).errors.txt.diff deleted file mode 100644 index 347886dd63..0000000000 --- a/testdata/baselines/reference/submodule/conformance/unicodeExtendedEscapesInRegularExpressions19(target=es6).errors.txt.diff +++ /dev/null @@ -1,12 +0,0 @@ ---- old.unicodeExtendedEscapesInRegularExpressions19(target=es6).errors.txt -+++ new.unicodeExtendedEscapesInRegularExpressions19(target=es6).errors.txt -@@= skipped -0, +0 lines =@@ --unicodeExtendedEscapesInRegularExpressions19.ts(1,13): error TS1125: Hexadecimal digit expected. -- -- --==== unicodeExtendedEscapesInRegularExpressions19.ts (1 errors) ==== -- var x = /\u{}/gu; -- --!!! error TS1125: Hexadecimal digit expected. -- -+ \ No newline at end of file diff --git a/testdata/tests/cases/compiler/regexpTestSimple.ts b/testdata/tests/cases/compiler/regexpTestSimple.ts new file mode 100644 index 0000000000..8d8746a8e6 --- /dev/null +++ b/testdata/tests/cases/compiler/regexpTestSimple.ts @@ -0,0 +1,3 @@ +// @strict: true +// Simple test +const x = /foo/xyz; From 1af4d7caf9713fbf1f65f1a72fb3ca025266cc8a Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Tue, 4 Nov 2025 20:43:24 -0800 Subject: [PATCH 02/33] wip --- internal/scanner/regexp.go | 178 ++++++++++-------- ...ressionCharacterClassRangeOrder.errors.txt | 32 +++- ...onCharacterClassRangeOrder.errors.txt.diff | 65 +++---- 3 files changed, 154 insertions(+), 121 deletions(-) diff --git a/internal/scanner/regexp.go b/internal/scanner/regexp.go index 8e5f4d2d71..8a21ab8409 100644 --- a/internal/scanner/regexp.go +++ b/internal/scanner/regexp.go @@ -3,6 +3,7 @@ package scanner import ( "fmt" "strings" + "unicode/utf16" "unicode/utf8" "github.com/microsoft/typescript-go/internal/ast" @@ -925,7 +926,15 @@ func (v *RegExpValidator) scanEscapeSequence(atomEscape bool) string { code = code*16 + int(digit-'A'+10) } } - escapedValueString := string(rune(code)) + // For surrogates, we need to preserve the actual value since string(rune(surrogate)) + // converts to 0xFFFD. We encode the surrogate as UTF-16BE bytes. + var escapedValueString string + if code >= 0xD800 && code <= 0xDFFF { + // Surrogate - encode as 2-byte sequence (UTF-16BE) + escapedValueString = string([]byte{byte(code >> 8), byte(code & 0xFF)}) + } else { + escapedValueString = string(rune(code)) + } // In Unicode mode, check for surrogate pairs if v.anyUnicodeMode && code >= 0xD800 && code <= 0xDBFF && v.pos+6 <= v.end && v.text[v.pos:v.pos+2] == "\\u" { @@ -955,9 +964,13 @@ func (v *RegExpValidator) scanEscapeSequence(atomEscape bool) string { } // Check if it's a low surrogate if nextCode >= 0xDC00 && nextCode <= 0xDFFF { - // Combine surrogates + // Combine surrogates into a single code point + // Formula: 0x10000 + ((high - 0xD800) << 10) + (low - 0xDC00) + highSurrogate := code + lowSurrogate := nextCode + combinedCodePoint := 0x10000 + ((highSurrogate - 0xD800) << 10) + (lowSurrogate - 0xDC00) v.pos = nextPos - return escapedValueString + string(rune(nextCode)) + return string(rune(combinedCodePoint)) } } } @@ -982,10 +995,19 @@ func isHexDigit(ch rune) bool { // codePointAt returns the code point value at the start of the string // If the string starts with a high surrogate followed by a low surrogate, they are combined +// Surrogates from escape sequences are encoded as 2-byte UTF-16BE sequences func codePointAt(s string) rune { if len(s) == 0 { return 0 } + // Check if this is a UTF-16BE encoded surrogate (2 bytes, first byte in surrogate range) + if len(s) == 2 { + firstByte := uint16(s[0]) + if firstByte >= 0xD8 && firstByte <= 0xDF { + // This is a surrogate encoded as UTF-16BE + return rune((uint16(s[0]) << 8) | uint16(s[1])) + } + } first, size := utf8.DecodeRuneInString(s) // Check if it's a high surrogate (0xD800-0xDBFF) if first >= 0xD800 && first <= 0xDBFF && len(s) > size { @@ -1013,6 +1035,22 @@ func charSize(ch rune) int { return 1 } +// utf16ComparisonValue returns the UTF-16 code unit value to use for range comparison +// In non-Unicode mode, JavaScript compares the low surrogate for code points >= 0x10000 +func utf16ComparisonValue(s string) rune { + if len(s) == 0 { + return 0 + } + r, _ := utf8.DecodeRuneInString(s) + // For code points >= 0x10000, return the low surrogate value + // This matches JavaScript's behavior in non-Unicode mode where surrogate pairs + // are treated as separate code units + if r >= 0x10000 { + return 0xDC00 + ((r - 0x10000) & 0x3FF) + } + return r +} + // stringCharSize returns the expected string length for a code point in our representation // Surrogate pairs are represented as 2-rune strings, each rune encoded as UTF-8 func stringCharSize(ch rune) int { @@ -1075,74 +1113,16 @@ func (v *RegExpValidator) scanSourceCharacter() string { v.pos++ return v.text[v.pos-1 : v.pos] } - // In non-Unicode mode, emulate UTF-16 behavior - // - // JavaScript strings are UTF-16, so a character like š˜ˆ (U+1D608) is stored as two 16-bit code units: - // - High surrogate: 0xD835 - // - Low surrogate: 0xDE08 - // - // When the JavaScript regex scanner processes `/[š˜ˆ-š˜”]/` in non-Unicode mode, it reads: - // 1. `[` - Start of character class - // 2. `\uD835` - High surrogate of š˜ˆ (first UTF-16 unit) - // 3. `\uDE08` - Low surrogate of š˜ˆ (second UTF-16 unit) - // 4. `-` - Hyphen (range operator) - // 5. `\uD835` - High surrogate of š˜” - // 6. `\uDE21` - Low surrogate of š˜” - // 7. `]` - End of character class - // - // So each call to scanSourceCharacter() returns a single UTF-16 code unit. - // - // In Go with UTF-8, the same string is: - // `/[<4-byte-š˜ˆ>-<4-byte-š˜”>]/` - // - // To emulate JavaScript, when we see a UTF-8 sequence for a code point >= 0x10000, - // we advance by 1 byte only and return a string representing the appropriate surrogate. - // The pendingLowSurrogate tracks when we're "inside" a multi-byte UTF-8 sequence. - - // Try to decode a full rune starting at current position - r, _ := utf8.DecodeRuneInString(v.text[v.pos:]) - - if r < 0x10000 || r == utf8.RuneError { - // Single UTF-16 code unit: ASCII, BMP character, or error - v.pos++ - if v.pos <= len(v.text) { - return string(r) - } - return "" - } - - // Multi-byte character (code point >= 0x10000) - // This would be a surrogate pair in UTF-16. - // - // Check if we're at the start of this character or in the middle. - // We do this by checking if we can decode a valid rune at our current position. - // If we're in the middle of a UTF-8 sequence, decoding would fail or give a different rune. - - // Check if we're at the start of the UTF-8 sequence - startPos := v.pos - for startPos > 0 && (v.text[startPos]&0xC0) == 0x80 { - // We're at a continuation byte, back up to find the start - startPos-- - } - - if startPos < v.pos { - // We're in the middle of a multi-byte sequence - // This means we already returned the high surrogate - // Now return the low surrogate and advance to the end of the sequence - testRune, testSize := utf8.DecodeRuneInString(v.text[startPos:]) - if testRune >= 0x10000 && testRune == r { - // Same character, return low surrogate - v.pos = startPos + testSize - low := int(0xDC00 + ((testRune - 0x10000) & 0x3FF)) - return string(rune(low)) - } + // In non-Unicode mode, we still consume full UTF-8 characters + // but we need to treat them as UTF-16 code units for range checking. + // JavaScript treats code points >= 0x10000 as surrogate pairs in non-Unicode mode. + r, s := utf8.DecodeRuneInString(v.text[v.pos:]) + if r != utf8.RuneError { + v.pos += s + return v.text[v.pos-s : v.pos] } - - // We're at the start of a multi-byte sequence - // Return high surrogate and advance by 1 byte - high := int(0xD800 + ((r - 0x10000) >> 10)) v.pos++ - return string(rune(high)) + return v.text[v.pos-1 : v.pos] } func (v *RegExpValidator) scanClassRanges() { @@ -1179,18 +1159,62 @@ func (v *RegExpValidator) scanClassRanges() { } // Check range order if atom != "" && rangeEnd != "" { - // Get the code point values, combining surrogate pairs if present minCodePoint := codePointAt(atom) maxCodePoint := codePointAt(rangeEnd) - // Calculate the expected string size for each code point in our representation - minExpectedSize := stringCharSize(minCodePoint) - maxExpectedSize := stringCharSize(maxCodePoint) + // Get the expected sizes (in UTF-16 code units) + minExpectedSize := charSize(minCodePoint) + maxExpectedSize := charSize(maxCodePoint) + + // Check if both are "complete" characters + // A character is complete if it's either: + // 1. A single UTF-8 rune (utf8.RuneCountInString == 1), or + // 2. A 2-byte surrogate encoding (len == 2 and in surrogate range) + minIsComplete := utf8.RuneCountInString(atom) == 1 || (len(atom) == 2 && minCodePoint >= 0xD800 && minCodePoint <= 0xDFFF) + maxIsComplete := utf8.RuneCountInString(rangeEnd) == 1 || (len(rangeEnd) == 2 && maxCodePoint >= 0xD800 && maxCodePoint <= 0xDFFF) + + if minIsComplete && maxIsComplete { + // In non-Unicode mode, TypeScript compares character ranges using UTF-16 code units + // For surrogate pairs (code points >= 0x10000), the comparison uses the LAST + // UTF-16 code unit (low surrogate for min, high surrogate for max conceptually, + // but since we scan sequentially, the actual values compared depend on position) + // + // The key insight: In `/[š˜ˆ-š˜”]/`, TypeScript parses as `[\uD835\uDE08-\uD835\uDE21]` + // This becomes a range from `\uDE08` (after first surrogate pair) to `\uD835` + // (the high surrogate of the second pair), and `\uDE08` > `\uD835` triggers the error. + // + // To emulate this: convert to UTF-16 and use the appropriate code unit + minValue, maxValue := minCodePoint, maxCodePoint + + if !v.anyUnicodeMode && minExpectedSize == maxExpectedSize { + // For surrogates (0xD800-0xDFFF), they are already UTF-16 code units, + // so use them directly for comparison + if minCodePoint >= 0xD800 && minCodePoint <= 0xDFFF { + minValue = minCodePoint + } else if minCodePoint >= 0x10000 { + // Convert to UTF-16 to get the comparison values + // For code points >= 0x10000, utf16.Encode returns [high, low] + minUTF16 := utf16.Encode([]rune{minCodePoint}) + // Use the LAST UTF-16 code unit for comparison + // This matches TypeScript's behavior where it compares the trailing unit + if len(minUTF16) > 0 { + minValue = rune(minUTF16[len(minUTF16)-1]) + } + } + + if maxCodePoint >= 0xD800 && maxCodePoint <= 0xDFFF { + maxValue = maxCodePoint + } else if maxCodePoint >= 0x10000 { + maxUTF16 := utf16.Encode([]rune{maxCodePoint}) + if len(maxUTF16) > 0 { + maxValue = rune(maxUTF16[0]) // First unit of max (high surrogate) + } + } + } - // Only check if both strings are complete characters (not partial) - // A character is complete if its string length matches the expected size for its code point - if len(atom) == minExpectedSize && len(rangeEnd) == maxExpectedSize && minCodePoint > maxCodePoint { - v.error(diagnostics.Range_out_of_order_in_character_class, atomStart, v.pos-atomStart) + if minValue > maxValue { + v.error(diagnostics.Range_out_of_order_in_character_class, atomStart, v.pos-atomStart) + } } } } diff --git a/testdata/baselines/reference/submodule/compiler/regularExpressionCharacterClassRangeOrder.errors.txt b/testdata/baselines/reference/submodule/compiler/regularExpressionCharacterClassRangeOrder.errors.txt index e0305b1ae0..f3224f36a1 100644 --- a/testdata/baselines/reference/submodule/compiler/regularExpressionCharacterClassRangeOrder.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/regularExpressionCharacterClassRangeOrder.errors.txt @@ -1,12 +1,22 @@ +regularExpressionCharacterClassRangeOrder.ts(7,4): error TS1517: Range out of order in character class. +regularExpressionCharacterClassRangeOrder.ts(7,9): error TS1517: Range out of order in character class. +regularExpressionCharacterClassRangeOrder.ts(8,9): error TS1517: Range out of order in character class. regularExpressionCharacterClassRangeOrder.ts(9,9): error TS1517: Range out of order in character class. regularExpressionCharacterClassRangeOrder.ts(11,4): error TS1538: Unicode escape sequences are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. +regularExpressionCharacterClassRangeOrder.ts(11,4): error TS1517: Range out of order in character class. regularExpressionCharacterClassRangeOrder.ts(11,14): error TS1538: Unicode escape sequences are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. regularExpressionCharacterClassRangeOrder.ts(11,25): error TS1538: Unicode escape sequences are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. +regularExpressionCharacterClassRangeOrder.ts(11,25): error TS1517: Range out of order in character class. regularExpressionCharacterClassRangeOrder.ts(11,35): error TS1538: Unicode escape sequences are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. +regularExpressionCharacterClassRangeOrder.ts(12,25): error TS1517: Range out of order in character class. regularExpressionCharacterClassRangeOrder.ts(13,25): error TS1517: Range out of order in character class. +regularExpressionCharacterClassRangeOrder.ts(15,10): error TS1517: Range out of order in character class. +regularExpressionCharacterClassRangeOrder.ts(15,37): error TS1517: Range out of order in character class. +regularExpressionCharacterClassRangeOrder.ts(16,31): error TS1517: Range out of order in character class. +regularExpressionCharacterClassRangeOrder.ts(17,31): error TS1517: Range out of order in character class. -==== regularExpressionCharacterClassRangeOrder.ts (6 errors) ==== +==== regularExpressionCharacterClassRangeOrder.ts (16 errors) ==== // The characters in the following regular expressions are ASCII-lookalike characters found in Unicode, including: // - š˜ˆ (U+1D608 Mathematical Sans-Serif Italic Capital A) // - š˜” (U+1D621 Mathematical Sans-Serif Italic Capital Z) @@ -14,7 +24,13 @@ regularExpressionCharacterClassRangeOrder.ts(13,25): error TS1517: Range out of // See https://en.wikipedia.org/wiki/Mathematical_Alphanumeric_Symbols const regexes: RegExp[] = [ /[š˜ˆ-š˜”][š˜”-š˜ˆ]/, + ~~~ +!!! error TS1517: Range out of order in character class. + ~~~ +!!! error TS1517: Range out of order in character class. /[š˜ˆ-š˜”][š˜”-š˜ˆ]/u, + ~~~ +!!! error TS1517: Range out of order in character class. /[š˜ˆ-š˜”][š˜”-š˜ˆ]/v, ~~~ !!! error TS1517: Range out of order in character class. @@ -22,19 +38,33 @@ regularExpressionCharacterClassRangeOrder.ts(13,25): error TS1517: Range out of /[\u{1D608}-\u{1D621}][\u{1D621}-\u{1D608}]/, ~~~~~~~~~ !!! error TS1538: Unicode escape sequences are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. + ~~~~~~~~~~~~~~~~~~~ +!!! error TS1517: Range out of order in character class. ~~~~~~~~~ !!! error TS1538: Unicode escape sequences are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. ~~~~~~~~~ !!! error TS1538: Unicode escape sequences are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. + ~~~~~~~~~~~~~~~~~~~ +!!! error TS1517: Range out of order in character class. ~~~~~~~~~ !!! error TS1538: Unicode escape sequences are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. /[\u{1D608}-\u{1D621}][\u{1D621}-\u{1D608}]/u, + ~~~~~~~~~~~~~~~~~~~ +!!! error TS1517: Range out of order in character class. /[\u{1D608}-\u{1D621}][\u{1D621}-\u{1D608}]/v, ~~~~~~~~~~~~~~~~~~~ !!! error TS1517: Range out of order in character class. /[\uD835\uDE08-\uD835\uDE21][\uD835\uDE21-\uD835\uDE08]/, + ~~~~~~~~~~~~~ +!!! error TS1517: Range out of order in character class. + ~~~~~~~~~~~~~ +!!! error TS1517: Range out of order in character class. /[\uD835\uDE08-\uD835\uDE21][\uD835\uDE21-\uD835\uDE08]/u, + ~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS1517: Range out of order in character class. /[\uD835\uDE08-\uD835\uDE21][\uD835\uDE21-\uD835\uDE08]/v, + ~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS1517: Range out of order in character class. ]; \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/regularExpressionCharacterClassRangeOrder.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/regularExpressionCharacterClassRangeOrder.errors.txt.diff index 73ff1407c2..f96ff74266 100644 --- a/testdata/baselines/reference/submodule/compiler/regularExpressionCharacterClassRangeOrder.errors.txt.diff +++ b/testdata/baselines/reference/submodule/compiler/regularExpressionCharacterClassRangeOrder.errors.txt.diff @@ -5,69 +5,48 @@ -regularExpressionCharacterClassRangeOrder.ts(7,12): error TS1517: Range out of order in character class. -regularExpressionCharacterClassRangeOrder.ts(8,11): error TS1517: Range out of order in character class. -regularExpressionCharacterClassRangeOrder.ts(9,11): error TS1517: Range out of order in character class. ++regularExpressionCharacterClassRangeOrder.ts(7,4): error TS1517: Range out of order in character class. ++regularExpressionCharacterClassRangeOrder.ts(7,9): error TS1517: Range out of order in character class. ++regularExpressionCharacterClassRangeOrder.ts(8,9): error TS1517: Range out of order in character class. +regularExpressionCharacterClassRangeOrder.ts(9,9): error TS1517: Range out of order in character class. regularExpressionCharacterClassRangeOrder.ts(11,4): error TS1538: Unicode escape sequences are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. ++regularExpressionCharacterClassRangeOrder.ts(11,4): error TS1517: Range out of order in character class. regularExpressionCharacterClassRangeOrder.ts(11,14): error TS1538: Unicode escape sequences are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. regularExpressionCharacterClassRangeOrder.ts(11,25): error TS1538: Unicode escape sequences are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. --regularExpressionCharacterClassRangeOrder.ts(11,25): error TS1517: Range out of order in character class. - regularExpressionCharacterClassRangeOrder.ts(11,35): error TS1538: Unicode escape sequences are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. --regularExpressionCharacterClassRangeOrder.ts(12,25): error TS1517: Range out of order in character class. - regularExpressionCharacterClassRangeOrder.ts(13,25): error TS1517: Range out of order in character class. --regularExpressionCharacterClassRangeOrder.ts(15,10): error TS1517: Range out of order in character class. --regularExpressionCharacterClassRangeOrder.ts(15,37): error TS1517: Range out of order in character class. --regularExpressionCharacterClassRangeOrder.ts(16,31): error TS1517: Range out of order in character class. --regularExpressionCharacterClassRangeOrder.ts(17,31): error TS1517: Range out of order in character class. -- -- + regularExpressionCharacterClassRangeOrder.ts(11,25): error TS1517: Range out of order in character class. +@@= skipped -14, +15 lines =@@ + regularExpressionCharacterClassRangeOrder.ts(17,31): error TS1517: Range out of order in character class. + + -==== regularExpressionCharacterClassRangeOrder.ts (15 errors) ==== -+ -+ -+==== regularExpressionCharacterClassRangeOrder.ts (6 errors) ==== ++==== regularExpressionCharacterClassRangeOrder.ts (16 errors) ==== // The characters in the following regular expressions are ASCII-lookalike characters found in Unicode, including: // - š˜ˆ (U+1D608 Mathematical Sans-Serif Italic Capital A) // - š˜” (U+1D621 Mathematical Sans-Serif Italic Capital Z) -@@= skipped -22, +13 lines =@@ +@@= skipped -8, +8 lines =@@ // See https://en.wikipedia.org/wiki/Mathematical_Alphanumeric_Symbols const regexes: RegExp[] = [ /[š˜ˆ-š˜”][š˜”-š˜ˆ]/, - ~~~ --!!! error TS1517: Range out of order in character class. ++ ~~~ + !!! error TS1517: Range out of order in character class. - ~~~ --!!! error TS1517: Range out of order in character class. ++ ~~~ + !!! error TS1517: Range out of order in character class. /[š˜ˆ-š˜”][š˜”-š˜ˆ]/u, - ~~~~~ --!!! error TS1517: Range out of order in character class. ++ ~~~ + !!! error TS1517: Range out of order in character class. /[š˜ˆ-š˜”][š˜”-š˜ˆ]/v, - ~~~~~ + ~~~ !!! error TS1517: Range out of order in character class. /[\u{1D608}-\u{1D621}][\u{1D621}-\u{1D608}]/, -@@= skipped -18, +12 lines =@@ - !!! error TS1538: Unicode escape sequences are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. - ~~~~~~~~~ + ~~~~~~~~~ !!! error TS1538: Unicode escape sequences are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. -- ~~~~~~~~~~~~~~~~~~~ --!!! error TS1517: Range out of order in character class. - ~~~~~~~~~ ++ ~~~~~~~~~~~~~~~~~~~ ++!!! error TS1517: Range out of order in character class. + ~~~~~~~~~ !!! error TS1538: Unicode escape sequences are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. - /[\u{1D608}-\u{1D621}][\u{1D621}-\u{1D608}]/u, -- ~~~~~~~~~~~~~~~~~~~ --!!! error TS1517: Range out of order in character class. - /[\u{1D608}-\u{1D621}][\u{1D621}-\u{1D608}]/v, - ~~~~~~~~~~~~~~~~~~~ - !!! error TS1517: Range out of order in character class. - - /[\uD835\uDE08-\uD835\uDE21][\uD835\uDE21-\uD835\uDE08]/, -- ~~~~~~~~~~~~~ --!!! error TS1517: Range out of order in character class. -- ~~~~~~~~~~~~~ --!!! error TS1517: Range out of order in character class. - /[\uD835\uDE08-\uD835\uDE21][\uD835\uDE21-\uD835\uDE08]/u, -- ~~~~~~~~~~~~~~~~~~~~~~~~~ --!!! error TS1517: Range out of order in character class. - /[\uD835\uDE08-\uD835\uDE21][\uD835\uDE21-\uD835\uDE08]/v, -- ~~~~~~~~~~~~~~~~~~~~~~~~~ --!!! error TS1517: Range out of order in character class. - ]; - \ No newline at end of file + ~~~~~~~~~ \ No newline at end of file From 1cef046fa9412a5605f24aa48dcb2825bb14b026 Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Tue, 4 Nov 2025 21:21:05 -0800 Subject: [PATCH 03/33] wip --- internal/scanner/regexp.go | 151 ++++++++++-------- ...ressionCharacterClassRangeOrder.errors.txt | 9 +- ...onCharacterClassRangeOrder.errors.txt.diff | 26 +-- 3 files changed, 92 insertions(+), 94 deletions(-) diff --git a/internal/scanner/regexp.go b/internal/scanner/regexp.go index 8a21ab8409..7ed7b93302 100644 --- a/internal/scanner/regexp.go +++ b/internal/scanner/regexp.go @@ -3,7 +3,6 @@ package scanner import ( "fmt" "strings" - "unicode/utf16" "unicode/utf8" "github.com/microsoft/typescript-go/internal/ast" @@ -85,6 +84,7 @@ type RegExpValidator struct { mayContainStrings bool isCharacterComplement bool tokenValue string + pendingLowSurrogate rune // For non-Unicode mode: pending low surrogate to return } type namedReference struct { @@ -883,9 +883,6 @@ func (v *RegExpValidator) scanEscapeSequence(atomEscape bool) string { v.error(diagnostics.Unterminated_Unicode_escape_sequence, start, v.pos-start) return v.text[start:v.pos] } - if !v.anyUnicodeMode { - v.error(diagnostics.Unicode_escape_sequences_are_only_available_when_the_Unicode_u_flag_or_the_Unicode_Sets_v_flag_is_set, start, v.pos-start) - } // Parse hex value code := 0 for i := hexStart; i < v.pos-1; i++ { // -1 to skip closing brace @@ -898,6 +895,9 @@ func (v *RegExpValidator) scanEscapeSequence(atomEscape bool) string { code = code*16 + int(digit-'A'+10) } } + if !v.anyUnicodeMode { + v.error(diagnostics.Unicode_escape_sequences_are_only_available_when_the_Unicode_u_flag_or_the_Unicode_Sets_v_flag_is_set, start, v.pos-start) + } return string(rune(code)) } else { // Standard unicode escape '\uDDDD' @@ -1072,6 +1072,32 @@ func stringCharSize(ch rune) int { return 1 } +// utf16Length returns the UTF-16 length of a string, matching JavaScript's string.length +// This counts UTF-16 code units, where surrogate pairs count as 2 units +// Handles both UTF-8 encoded strings and special 2-byte UTF-16BE surrogate encodings +func utf16Length(s string) int { + // Check if this is a 2-byte UTF-16BE surrogate encoding + // These are used to preserve surrogate values in patterns like \uD835 + if len(s) == 2 { + firstByte := uint16(s[0]) + if firstByte >= 0xD8 && firstByte <= 0xDF { + // This is a surrogate encoded as UTF-16BE + return 1 + } + } + + // Otherwise, count UTF-16 code units from UTF-8 runes + length := 0 + for _, r := range s { + if r >= 0x10000 { + length += 2 // Surrogate pair + } else { + length += 1 + } + } + return length +} + func (v *RegExpValidator) scanGroupName(isReference bool) { tokenStart := v.pos v.scanIdentifier(v.charAtOffset(0)) @@ -1103,26 +1129,47 @@ func (v *RegExpValidator) scanGroupName(isReference bool) { } func (v *RegExpValidator) scanSourceCharacter() string { - if v.anyUnicodeMode { - // In Unicode mode, consume the full character - r, s := utf8.DecodeRuneInString(v.text[v.pos:]) - if r != utf8.RuneError { - v.pos += s - return v.text[v.pos-s : v.pos] - } + // In non-Unicode mode, check if we have a pending low surrogate from a previous scan + if !v.anyUnicodeMode && v.pendingLowSurrogate != 0 { + low := v.pendingLowSurrogate + size := v.pendingLowSurrogate >> 16 // High 16 bits store the UTF-8 size + v.pendingLowSurrogate = 0 + // Now advance v.pos to consume the UTF-8 character + v.pos += int(size) + // Return the low surrogate encoded as UTF-16BE 2-byte sequence + return string([]byte{byte(low >> 8), byte(low & 0xFF)}) + } + + // Decode the next UTF-8 character + r, s := utf8.DecodeRuneInString(v.text[v.pos:]) + if r == utf8.RuneError { v.pos++ return v.text[v.pos-1 : v.pos] } - // In non-Unicode mode, we still consume full UTF-8 characters - // but we need to treat them as UTF-16 code units for range checking. - // JavaScript treats code points >= 0x10000 as surrogate pairs in non-Unicode mode. - r, s := utf8.DecodeRuneInString(v.text[v.pos:]) - if r != utf8.RuneError { + + if v.anyUnicodeMode { + // In Unicode mode, consume the full character v.pos += s return v.text[v.pos-s : v.pos] } - v.pos++ - return v.text[v.pos-1 : v.pos] + + // In non-Unicode mode, JavaScript treats characters as UTF-16 code units. + // For code points >= 0x10000, they are surrogate pairs, and we need to + // return them one UTF-16 code unit at a time (like TypeScript does). + if r >= 0x10000 { + // This character requires a surrogate pair in UTF-16. + // Return the high surrogate now, and save the low surrogate for next time. + high := 0xD800 + ((r-0x10000)>>10)&0x3FF + low := 0xDC00 + ((r - 0x10000) & 0x3FF) + // Store the low surrogate in lower 16 bits, and UTF-8 size in upper 16 bits + v.pendingLowSurrogate = low | (rune(s) << 16) + // Return the high surrogate encoded as UTF-16BE 2-byte sequence + return string([]byte{byte(high >> 8), byte(high & 0xFF)}) + } + + // For code points < 0x10000, consume and return the character normally + v.pos += s + return v.text[v.pos-s : v.pos] } func (v *RegExpValidator) scanClassRanges() { @@ -1167,54 +1214,26 @@ func (v *RegExpValidator) scanClassRanges() { maxExpectedSize := charSize(maxCodePoint) // Check if both are "complete" characters - // A character is complete if it's either: - // 1. A single UTF-8 rune (utf8.RuneCountInString == 1), or - // 2. A 2-byte surrogate encoding (len == 2 and in surrogate range) - minIsComplete := utf8.RuneCountInString(atom) == 1 || (len(atom) == 2 && minCodePoint >= 0xD800 && minCodePoint <= 0xDFFF) - maxIsComplete := utf8.RuneCountInString(rangeEnd) == 1 || (len(rangeEnd) == 2 && maxCodePoint >= 0xD800 && maxCodePoint <= 0xDFFF) - - if minIsComplete && maxIsComplete { - // In non-Unicode mode, TypeScript compares character ranges using UTF-16 code units - // For surrogate pairs (code points >= 0x10000), the comparison uses the LAST - // UTF-16 code unit (low surrogate for min, high surrogate for max conceptually, - // but since we scan sequentially, the actual values compared depend on position) - // - // The key insight: In `/[š˜ˆ-š˜”]/`, TypeScript parses as `[\uD835\uDE08-\uD835\uDE21]` - // This becomes a range from `\uDE08` (after first surrogate pair) to `\uD835` - // (the high surrogate of the second pair), and `\uDE08` > `\uD835` triggers the error. - // - // To emulate this: convert to UTF-16 and use the appropriate code unit - minValue, maxValue := minCodePoint, maxCodePoint - - if !v.anyUnicodeMode && minExpectedSize == maxExpectedSize { - // For surrogates (0xD800-0xDFFF), they are already UTF-16 code units, - // so use them directly for comparison - if minCodePoint >= 0xD800 && minCodePoint <= 0xDFFF { - minValue = minCodePoint - } else if minCodePoint >= 0x10000 { - // Convert to UTF-16 to get the comparison values - // For code points >= 0x10000, utf16.Encode returns [high, low] - minUTF16 := utf16.Encode([]rune{minCodePoint}) - // Use the LAST UTF-16 code unit for comparison - // This matches TypeScript's behavior where it compares the trailing unit - if len(minUTF16) > 0 { - minValue = rune(minUTF16[len(minUTF16)-1]) - } - } - - if maxCodePoint >= 0xD800 && maxCodePoint <= 0xDFFF { - maxValue = maxCodePoint - } else if maxCodePoint >= 0x10000 { - maxUTF16 := utf16.Encode([]rune{maxCodePoint}) - if len(maxUTF16) > 0 { - maxValue = rune(maxUTF16[0]) // First unit of max (high surrogate) - } - } - } - - if minValue > maxValue { - v.error(diagnostics.Range_out_of_order_in_character_class, atomStart, v.pos-atomStart) - } + // TypeScript checks: minCharacter.length === charSize(minCharacterValue) + // where .length is the UTF-16 length in JavaScript strings. + // We need to calculate the UTF-16 length of our strings. + minUTF16Length := utf16Length(atom) + maxUTF16Length := utf16Length(rangeEnd) + + // A character is complete if its UTF-16 length matches the expected size + // TypeScript checks: minCharacter.length === charSize(minCharacterValue) + // where .length is the UTF-16 length in JavaScript strings. + minIsComplete := minUTF16Length == minExpectedSize + maxIsComplete := maxUTF16Length == maxExpectedSize + + if minIsComplete && maxIsComplete && minCodePoint > maxCodePoint { + // TypeScript compares code points directly. In non-Unicode mode, + // literal characters >= 0x10000 are scanned as individual surrogates + // by scanSourceCharacter(), so the code points being compared are + // already the surrogate values (0xD800-0xDFFF). + // Escape sequences like \u{1D608} return the full character, so the + // code points are the actual values (>= 0x10000). + v.error(diagnostics.Range_out_of_order_in_character_class, atomStart, v.pos-atomStart) } } } diff --git a/testdata/baselines/reference/submodule/compiler/regularExpressionCharacterClassRangeOrder.errors.txt b/testdata/baselines/reference/submodule/compiler/regularExpressionCharacterClassRangeOrder.errors.txt index f3224f36a1..6fbc29d6fe 100644 --- a/testdata/baselines/reference/submodule/compiler/regularExpressionCharacterClassRangeOrder.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/regularExpressionCharacterClassRangeOrder.errors.txt @@ -3,7 +3,6 @@ regularExpressionCharacterClassRangeOrder.ts(7,9): error TS1517: Range out of or regularExpressionCharacterClassRangeOrder.ts(8,9): error TS1517: Range out of order in character class. regularExpressionCharacterClassRangeOrder.ts(9,9): error TS1517: Range out of order in character class. regularExpressionCharacterClassRangeOrder.ts(11,4): error TS1538: Unicode escape sequences are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. -regularExpressionCharacterClassRangeOrder.ts(11,4): error TS1517: Range out of order in character class. regularExpressionCharacterClassRangeOrder.ts(11,14): error TS1538: Unicode escape sequences are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. regularExpressionCharacterClassRangeOrder.ts(11,25): error TS1538: Unicode escape sequences are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. regularExpressionCharacterClassRangeOrder.ts(11,25): error TS1517: Range out of order in character class. @@ -16,7 +15,7 @@ regularExpressionCharacterClassRangeOrder.ts(16,31): error TS1517: Range out of regularExpressionCharacterClassRangeOrder.ts(17,31): error TS1517: Range out of order in character class. -==== regularExpressionCharacterClassRangeOrder.ts (16 errors) ==== +==== regularExpressionCharacterClassRangeOrder.ts (15 errors) ==== // The characters in the following regular expressions are ASCII-lookalike characters found in Unicode, including: // - š˜ˆ (U+1D608 Mathematical Sans-Serif Italic Capital A) // - š˜” (U+1D621 Mathematical Sans-Serif Italic Capital Z) @@ -24,9 +23,9 @@ regularExpressionCharacterClassRangeOrder.ts(17,31): error TS1517: Range out of // See https://en.wikipedia.org/wiki/Mathematical_Alphanumeric_Symbols const regexes: RegExp[] = [ /[š˜ˆ-š˜”][š˜”-š˜ˆ]/, - ~~~ + ~~ !!! error TS1517: Range out of order in character class. - ~~~ + ~~ !!! error TS1517: Range out of order in character class. /[š˜ˆ-š˜”][š˜”-š˜ˆ]/u, ~~~ @@ -38,8 +37,6 @@ regularExpressionCharacterClassRangeOrder.ts(17,31): error TS1517: Range out of /[\u{1D608}-\u{1D621}][\u{1D621}-\u{1D608}]/, ~~~~~~~~~ !!! error TS1538: Unicode escape sequences are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. - ~~~~~~~~~~~~~~~~~~~ -!!! error TS1517: Range out of order in character class. ~~~~~~~~~ !!! error TS1538: Unicode escape sequences are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. ~~~~~~~~~ diff --git a/testdata/baselines/reference/submodule/compiler/regularExpressionCharacterClassRangeOrder.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/regularExpressionCharacterClassRangeOrder.errors.txt.diff index f96ff74266..6135e7e82a 100644 --- a/testdata/baselines/reference/submodule/compiler/regularExpressionCharacterClassRangeOrder.errors.txt.diff +++ b/testdata/baselines/reference/submodule/compiler/regularExpressionCharacterClassRangeOrder.errors.txt.diff @@ -10,28 +10,17 @@ +regularExpressionCharacterClassRangeOrder.ts(8,9): error TS1517: Range out of order in character class. +regularExpressionCharacterClassRangeOrder.ts(9,9): error TS1517: Range out of order in character class. regularExpressionCharacterClassRangeOrder.ts(11,4): error TS1538: Unicode escape sequences are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. -+regularExpressionCharacterClassRangeOrder.ts(11,4): error TS1517: Range out of order in character class. regularExpressionCharacterClassRangeOrder.ts(11,14): error TS1538: Unicode escape sequences are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. regularExpressionCharacterClassRangeOrder.ts(11,25): error TS1538: Unicode escape sequences are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. - regularExpressionCharacterClassRangeOrder.ts(11,25): error TS1517: Range out of order in character class. -@@= skipped -14, +15 lines =@@ - regularExpressionCharacterClassRangeOrder.ts(17,31): error TS1517: Range out of order in character class. - - --==== regularExpressionCharacterClassRangeOrder.ts (15 errors) ==== -+==== regularExpressionCharacterClassRangeOrder.ts (16 errors) ==== - // The characters in the following regular expressions are ASCII-lookalike characters found in Unicode, including: - // - š˜ˆ (U+1D608 Mathematical Sans-Serif Italic Capital A) - // - š˜” (U+1D621 Mathematical Sans-Serif Italic Capital Z) -@@= skipped -8, +8 lines =@@ +@@= skipped -22, +22 lines =@@ // See https://en.wikipedia.org/wiki/Mathematical_Alphanumeric_Symbols const regexes: RegExp[] = [ /[š˜ˆ-š˜”][š˜”-š˜ˆ]/, - ~~~ -+ ~~~ ++ ~~ !!! error TS1517: Range out of order in character class. - ~~~ -+ ~~~ ++ ~~ !!! error TS1517: Range out of order in character class. /[š˜ˆ-š˜”][š˜”-š˜ˆ]/u, - ~~~~~ @@ -42,11 +31,4 @@ + ~~~ !!! error TS1517: Range out of order in character class. - /[\u{1D608}-\u{1D621}][\u{1D621}-\u{1D608}]/, - ~~~~~~~~~ - !!! error TS1538: Unicode escape sequences are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. -+ ~~~~~~~~~~~~~~~~~~~ -+!!! error TS1517: Range out of order in character class. - ~~~~~~~~~ - !!! error TS1538: Unicode escape sequences are only available when the Unicode (u) flag or the Unicode Sets (v) flag is set. - ~~~~~~~~~ \ No newline at end of file + /[\u{1D608}-\u{1D621}][\u{1D621}-\u{1D608}]/, \ No newline at end of file From 3110ac6fe43860a55c22db842ccbf05eb2708810 Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Tue, 4 Nov 2025 21:43:29 -0800 Subject: [PATCH 04/33] wip --- internal/scanner/regexp.go | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/internal/scanner/regexp.go b/internal/scanner/regexp.go index 7ed7b93302..7b5a26ab79 100644 --- a/internal/scanner/regexp.go +++ b/internal/scanner/regexp.go @@ -1128,8 +1128,12 @@ func (v *RegExpValidator) scanGroupName(isReference bool) { } } +// scanSourceCharacter scans and returns a single "character" from the source. +// In Unicode mode (u or v flags), returns complete Unicode code points. +// In non-Unicode mode, mimics JavaScript's UTF-16 behavior where literal characters +// >= U+10000 are returned as individual surrogates (matching TypeScript scanner.ts line 3536). func (v *RegExpValidator) scanSourceCharacter() string { - // In non-Unicode mode, check if we have a pending low surrogate from a previous scan + // Check if we have a pending low surrogate from splitting a previous character if !v.anyUnicodeMode && v.pendingLowSurrogate != 0 { low := v.pendingLowSurrogate size := v.pendingLowSurrogate >> 16 // High 16 bits store the UTF-8 size @@ -1172,6 +1176,9 @@ func (v *RegExpValidator) scanSourceCharacter() string { return v.text[v.pos-s : v.pos] } +// ClassRanges ::= ClassAtom ('-' ClassAtom)? +// Scans character class content like [a-z] or [^0-9]. +// TypeScript reference: scanner.ts line 2990 func (v *RegExpValidator) scanClassRanges() { isNegated := v.charAtOffset(0) == '^' if isNegated { @@ -1244,6 +1251,12 @@ func (v *RegExpValidator) isClassContentExit(ch rune) bool { return ch == ']' || ch == 0 || v.pos >= v.end } +// ClassAtom ::= +// +// | SourceCharacter but not one of '\' or ']' +// | '\' ClassEscape +// +// TypeScript reference: scanner.ts line 3406 func (v *RegExpValidator) scanClassAtom() string { if v.charAtOffset(0) == '\\' { v.pos++ @@ -1252,6 +1265,14 @@ func (v *RegExpValidator) scanClassAtom() string { return v.scanSourceCharacter() } +// ClassEscape ::= +// +// | 'b' +// | '-' +// | CharacterClassEscape +// | CharacterEscape +// +// TypeScript reference: scanner.ts line 3406 func (v *RegExpValidator) scanClassEscape() string { if v.scanCharacterClassEscape() { return "" From b6488059eb174568e77ad37d7384bf3898bf7605 Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Tue, 4 Nov 2025 21:55:53 -0800 Subject: [PATCH 05/33] wip --- internal/scanner/regexp.go | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/internal/scanner/regexp.go b/internal/scanner/regexp.go index 7b5a26ab79..2682e3e23b 100644 --- a/internal/scanner/regexp.go +++ b/internal/scanner/regexp.go @@ -8,6 +8,7 @@ import ( "github.com/microsoft/typescript-go/internal/ast" "github.com/microsoft/typescript-go/internal/core" "github.com/microsoft/typescript-go/internal/diagnostics" + "github.com/microsoft/typescript-go/internal/stringutil" ) // RegExpFlags represents regexp flags (e.g., 'g', 'i', 'm', etc.) @@ -749,7 +750,7 @@ func (v *RegExpValidator) scanCharacterEscape(atomEscape bool) string { case 'c': v.pos++ ch = v.charAtOffset(0) - if isASCIILetter(ch) { + if stringutil.IsASCIILetter(ch) { v.pos++ return string(ch & 0x1f) } @@ -768,10 +769,6 @@ func (v *RegExpValidator) scanCharacterEscape(atomEscape bool) string { } } -func isASCIILetter(ch rune) bool { - return (ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z') -} - func (v *RegExpValidator) scanEscapeSequence(atomEscape bool) string { // start points to the backslash (before the escape character) start := v.pos - 1 @@ -838,7 +835,7 @@ func (v *RegExpValidator) scanEscapeSequence(atomEscape bool) string { hexStart := v.pos validHex := true for range 2 { - if v.pos >= v.end || !isHexDigit(v.charAtOffset(0)) { + if v.pos >= v.end || !stringutil.IsHexDigit(v.charAtOffset(0)) { validHex = false break } @@ -869,7 +866,7 @@ func (v *RegExpValidator) scanEscapeSequence(atomEscape bool) string { v.pos++ hexStart := v.pos hasDigits := false - for v.pos < v.end && isHexDigit(v.charAtOffset(0)) { + for v.pos < v.end && stringutil.IsHexDigit(v.charAtOffset(0)) { hasDigits = true v.pos++ } @@ -904,7 +901,7 @@ func (v *RegExpValidator) scanEscapeSequence(atomEscape bool) string { hexStart := v.pos validHex := true for range 4 { - if v.pos >= v.end || !isHexDigit(v.charAtOffset(0)) { + if v.pos >= v.end || !stringutil.IsHexDigit(v.charAtOffset(0)) { validHex = false break } @@ -943,7 +940,7 @@ func (v *RegExpValidator) scanEscapeSequence(atomEscape bool) string { nextPos := v.pos + 2 validNext := true for range 4 { - if nextPos >= v.end || !isHexDigit(rune(v.text[nextPos])) { + if nextPos >= v.end || !stringutil.IsHexDigit(rune(v.text[nextPos])) { validNext = false break } @@ -989,10 +986,6 @@ func (v *RegExpValidator) scanEscapeSequence(atomEscape bool) string { } } -func isHexDigit(ch rune) bool { - return (ch >= '0' && ch <= '9') || (ch >= 'a' && ch <= 'f') || (ch >= 'A' && ch <= 'F') -} - // codePointAt returns the code point value at the start of the string // If the string starts with a high surrogate followed by a low surrogate, they are combined // Surrogates from escape sequences are encoded as 2-byte UTF-16BE sequences From 0470fb41fa8ff6ce339765744eccc422f787d6f1 Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Tue, 4 Nov 2025 22:05:16 -0800 Subject: [PATCH 06/33] wip --- internal/scanner/regexp.go | 78 +++++++++++++------------------------- 1 file changed, 26 insertions(+), 52 deletions(-) diff --git a/internal/scanner/regexp.go b/internal/scanner/regexp.go index 2682e3e23b..9c62e8a722 100644 --- a/internal/scanner/regexp.go +++ b/internal/scanner/regexp.go @@ -471,7 +471,7 @@ func (v *RegExpValidator) validateDecimalEscapes() { func (v *RegExpValidator) scanDigits() { start := v.pos - for v.pos < v.end && v.charAtOffset(0) >= '0' && v.charAtOffset(0) <= '9' { + for v.pos < v.end && stringutil.IsDigit(v.charAtOffset(0)) { v.pos++ } v.tokenValue = v.text[start:v.pos] @@ -782,26 +782,26 @@ func (v *RegExpValidator) scanEscapeSequence(atomEscape bool) string { switch ch { case '0': // '\0' - null character, but check if followed by digit - if v.pos >= v.end || !(v.charAtOffset(0) >= '0' && v.charAtOffset(0) <= '9') { + if v.pos >= v.end || !stringutil.IsDigit(v.charAtOffset(0)) { return "\x00" } // This is an octal escape starting with \0 // falls through to handle as octal - if v.charAtOffset(0) >= '0' && v.charAtOffset(0) <= '7' { + if stringutil.IsOctalDigit(v.charAtOffset(0)) { v.pos++ } fallthrough case '1', '2', '3': // Can be up to 3 octal digits - if v.pos < v.end && v.charAtOffset(0) >= '0' && v.charAtOffset(0) <= '7' { + if v.pos < v.end && stringutil.IsOctalDigit(v.charAtOffset(0)) { v.pos++ } fallthrough case '4', '5', '6', '7': // Can be 1 or 2 octal digits (already consumed one above for 1-3) - if v.pos < v.end && v.charAtOffset(0) >= '0' && v.charAtOffset(0) <= '7' { + if v.pos < v.end && stringutil.IsOctalDigit(v.charAtOffset(0)) { v.pos++ } // Always report errors for octal escapes in regexp mode @@ -845,18 +845,7 @@ func (v *RegExpValidator) scanEscapeSequence(atomEscape bool) string { v.error(diagnostics.Hexadecimal_digit_expected, hexStart, v.pos-hexStart) return v.text[start:v.pos] } - // Parse hex value and return the character - code := 0 - for i := hexStart; i < v.pos; i++ { - digit := v.text[i] - if digit >= '0' && digit <= '9' { - code = code*16 + int(digit-'0') - } else if digit >= 'a' && digit <= 'f' { - code = code*16 + int(digit-'a'+10) - } else if digit >= 'A' && digit <= 'F' { - code = code*16 + int(digit-'A'+10) - } - } + code := parseHexValue(v.text, hexStart, v.pos) return string(rune(code)) case 'u': @@ -880,18 +869,8 @@ func (v *RegExpValidator) scanEscapeSequence(atomEscape bool) string { v.error(diagnostics.Unterminated_Unicode_escape_sequence, start, v.pos-start) return v.text[start:v.pos] } - // Parse hex value - code := 0 - for i := hexStart; i < v.pos-1; i++ { // -1 to skip closing brace - digit := v.text[i] - if digit >= '0' && digit <= '9' { - code = code*16 + int(digit-'0') - } else if digit >= 'a' && digit <= 'f' { - code = code*16 + int(digit-'a'+10) - } else if digit >= 'A' && digit <= 'F' { - code = code*16 + int(digit-'A'+10) - } - } + // Parse hex value (-1 to skip closing brace) + code := parseHexValue(v.text, hexStart, v.pos-1) if !v.anyUnicodeMode { v.error(diagnostics.Unicode_escape_sequences_are_only_available_when_the_Unicode_u_flag_or_the_Unicode_Sets_v_flag_is_set, start, v.pos-start) } @@ -911,18 +890,7 @@ func (v *RegExpValidator) scanEscapeSequence(atomEscape bool) string { v.error(diagnostics.Hexadecimal_digit_expected, hexStart, v.pos-hexStart) return v.text[start:v.pos] } - // Parse hex value - code := 0 - for i := hexStart; i < v.pos; i++ { - digit := v.text[i] - if digit >= '0' && digit <= '9' { - code = code*16 + int(digit-'0') - } else if digit >= 'a' && digit <= 'f' { - code = code*16 + int(digit-'a'+10) - } else if digit >= 'A' && digit <= 'F' { - code = code*16 + int(digit-'A'+10) - } - } + code := parseHexValue(v.text, hexStart, v.pos) // For surrogates, we need to preserve the actual value since string(rune(surrogate)) // converts to 0xFFFD. We encode the surrogate as UTF-16BE bytes. var escapedValueString string @@ -948,17 +916,7 @@ func (v *RegExpValidator) scanEscapeSequence(atomEscape bool) string { } if validNext { // Parse the next escape - nextCode := 0 - for i := nextStart + 2; i < nextPos; i++ { - digit := v.text[i] - if digit >= '0' && digit <= '9' { - nextCode = nextCode*16 + int(digit-'0') - } else if digit >= 'a' && digit <= 'f' { - nextCode = nextCode*16 + int(digit-'a'+10) - } else if digit >= 'A' && digit <= 'F' { - nextCode = nextCode*16 + int(digit-'A'+10) - } - } + nextCode := parseHexValue(v.text, nextStart+2, nextPos) // Check if it's a low surrogate if nextCode >= 0xDC00 && nextCode <= 0xDFFF { // Combine surrogates into a single code point @@ -986,6 +944,22 @@ func (v *RegExpValidator) scanEscapeSequence(atomEscape bool) string { } } +// parseHexValue parses hexadecimal digits from text and returns the integer value +func parseHexValue(text string, start, end int) int { + code := 0 + for i := start; i < end; i++ { + digit := text[i] + if digit >= '0' && digit <= '9' { + code = code*16 + int(digit-'0') + } else if digit >= 'a' && digit <= 'f' { + code = code*16 + int(digit-'a'+10) + } else if digit >= 'A' && digit <= 'F' { + code = code*16 + int(digit-'A'+10) + } + } + return code +} + // codePointAt returns the code point value at the start of the string // If the string starts with a high surrogate followed by a low surrogate, they are combined // Surrogates from escape sequences are encoded as 2-byte UTF-16BE sequences From 899ad1dce2d1c3c17377f0b1cd4785b5c875582a Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Tue, 4 Nov 2025 22:19:35 -0800 Subject: [PATCH 07/33] wip --- internal/scanner/regexp.go | 31 +++++++++++++------------------ 1 file changed, 13 insertions(+), 18 deletions(-) diff --git a/internal/scanner/regexp.go b/internal/scanner/regexp.go index 9c62e8a722..28ea6057c1 100644 --- a/internal/scanner/regexp.go +++ b/internal/scanner/regexp.go @@ -162,7 +162,7 @@ func (v *RegExpValidator) validateRegularExpression() { // Set up validation parameters v.unicodeSetsMode = v.regExpFlags&RegExpFlagsUnicodeSets != 0 v.anyUnicodeMode = v.regExpFlags&RegExpFlagsAnyUnicodeMode != 0 - // TypeScript always uses Annex B mode for regexp validation + // Always validate as if in Annex B mode (matches JavaScript runtime behavior) v.annexB = true v.anyUnicodeModeOrNonAnnexB = v.anyUnicodeMode || !v.annexB @@ -990,7 +990,7 @@ func codePointAt(s string) rune { } // charSize returns the number of UTF-16 code units needed to represent a code point -// This matches TypeScript's charSize function +// This matches JavaScript's internal string representation func charSize(ch rune) int { if ch >= 0x10000 { // Code points >= 0x10000 require surrogate pairs in UTF-16 (2 code units) @@ -1098,7 +1098,7 @@ func (v *RegExpValidator) scanGroupName(isReference bool) { // scanSourceCharacter scans and returns a single "character" from the source. // In Unicode mode (u or v flags), returns complete Unicode code points. // In non-Unicode mode, mimics JavaScript's UTF-16 behavior where literal characters -// >= U+10000 are returned as individual surrogates (matching TypeScript scanner.ts line 3536). +// >= U+10000 are returned as individual surrogates (matching JS regexp semantics). func (v *RegExpValidator) scanSourceCharacter() string { // Check if we have a pending low surrogate from splitting a previous character if !v.anyUnicodeMode && v.pendingLowSurrogate != 0 { @@ -1126,7 +1126,7 @@ func (v *RegExpValidator) scanSourceCharacter() string { // In non-Unicode mode, JavaScript treats characters as UTF-16 code units. // For code points >= 0x10000, they are surrogate pairs, and we need to - // return them one UTF-16 code unit at a time (like TypeScript does). + // return them one UTF-16 code unit at a time (matching JS runtime behavior). if r >= 0x10000 { // This character requires a surrogate pair in UTF-16. // Return the high surrogate now, and save the low surrogate for next time. @@ -1145,7 +1145,7 @@ func (v *RegExpValidator) scanSourceCharacter() string { // ClassRanges ::= ClassAtom ('-' ClassAtom)? // Scans character class content like [a-z] or [^0-9]. -// TypeScript reference: scanner.ts line 2990 +// Follows ECMAScript regexp grammar func (v *RegExpValidator) scanClassRanges() { isNegated := v.charAtOffset(0) == '^' if isNegated { @@ -1187,24 +1187,19 @@ func (v *RegExpValidator) scanClassRanges() { minExpectedSize := charSize(minCodePoint) maxExpectedSize := charSize(maxCodePoint) - // Check if both are "complete" characters - // TypeScript checks: minCharacter.length === charSize(minCharacterValue) - // where .length is the UTF-16 length in JavaScript strings. - // We need to calculate the UTF-16 length of our strings. + // Check if both are "complete" characters in JavaScript's UTF-16 representation. + // A character is complete if its UTF-16 length matches the expected size. + // In JavaScript, string.length returns the UTF-16 code unit count. minUTF16Length := utf16Length(atom) maxUTF16Length := utf16Length(rangeEnd) - // A character is complete if its UTF-16 length matches the expected size - // TypeScript checks: minCharacter.length === charSize(minCharacterValue) - // where .length is the UTF-16 length in JavaScript strings. minIsComplete := minUTF16Length == minExpectedSize maxIsComplete := maxUTF16Length == maxExpectedSize if minIsComplete && maxIsComplete && minCodePoint > maxCodePoint { - // TypeScript compares code points directly. In non-Unicode mode, - // literal characters >= 0x10000 are scanned as individual surrogates - // by scanSourceCharacter(), so the code points being compared are - // already the surrogate values (0xD800-0xDFFF). + // In non-Unicode mode, literal characters >= 0x10000 are scanned + // as individual surrogates by scanSourceCharacter(), so the code + // points being compared are already the surrogate values (0xD800-0xDFFF). // Escape sequences like \u{1D608} return the full character, so the // code points are the actual values (>= 0x10000). v.error(diagnostics.Range_out_of_order_in_character_class, atomStart, v.pos-atomStart) @@ -1223,7 +1218,7 @@ func (v *RegExpValidator) isClassContentExit(ch rune) bool { // | SourceCharacter but not one of '\' or ']' // | '\' ClassEscape // -// TypeScript reference: scanner.ts line 3406 +// Follows ECMAScript regexp grammar func (v *RegExpValidator) scanClassAtom() string { if v.charAtOffset(0) == '\\' { v.pos++ @@ -1239,7 +1234,7 @@ func (v *RegExpValidator) scanClassAtom() string { // | CharacterClassEscape // | CharacterEscape // -// TypeScript reference: scanner.ts line 3406 +// Follows ECMAScript regexp grammar func (v *RegExpValidator) scanClassEscape() string { if v.scanCharacterClassEscape() { return "" From a5a15978df2b84e06f9e08a1abc3fe1715ac201a Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Tue, 4 Nov 2025 22:27:40 -0800 Subject: [PATCH 08/33] wip --- internal/checker/regexpchecks.go | 2 +- internal/scanner/regexp.go | 8 +------- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/internal/checker/regexpchecks.go b/internal/checker/regexpchecks.go index a652452122..2f85751052 100644 --- a/internal/checker/regexpchecks.go +++ b/internal/checker/regexpchecks.go @@ -38,5 +38,5 @@ func (c *Checker) validateRegularExpressionLiteralNode(node *ast.RegularExpressi } // Perform regexp validation - scanner.ValidateRegularExpressionLiteral(node, sourceFile, c.languageVersion, sourceFile.LanguageVariant, onError) + scanner.ValidateRegularExpressionLiteral(node, sourceFile, c.languageVersion, onError) } diff --git a/internal/scanner/regexp.go b/internal/scanner/regexp.go index 28ea6057c1..a5f51a6ed8 100644 --- a/internal/scanner/regexp.go +++ b/internal/scanner/regexp.go @@ -106,21 +106,15 @@ func ValidateRegularExpressionLiteral( node *ast.RegularExpressionLiteral, sourceFile *ast.SourceFile, languageVersion core.ScriptTarget, - languageVariant core.LanguageVariant, onError ErrorCallback, ) { - // Check if the token has the Unterminated flag - if node.AsNode().LiteralLikeData().TokenFlags&ast.TokenFlagsUnterminated != 0 { - return - } - text := node.Text v := &RegExpValidator{ text: text, pos: 1, // Skip initial '/' end: len(text), languageVersion: languageVersion, - languageVariant: languageVariant, + languageVariant: sourceFile.LanguageVariant, onError: onError, } From 9a4c582cdbe8d52e01c0dc3c7bfea431afb4178f Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Tue, 4 Nov 2025 22:31:28 -0800 Subject: [PATCH 09/33] move code --- internal/checker/regexpchecks.go | 4 +- .../regexpchecker.go} | 192 +++++++++--------- 2 files changed, 97 insertions(+), 99 deletions(-) rename internal/{scanner/regexp.go => regexpchecker/regexpchecker.go} (91%) diff --git a/internal/checker/regexpchecks.go b/internal/checker/regexpchecks.go index 2f85751052..45d21786a9 100644 --- a/internal/checker/regexpchecks.go +++ b/internal/checker/regexpchecks.go @@ -4,6 +4,7 @@ import ( "github.com/microsoft/typescript-go/internal/ast" "github.com/microsoft/typescript-go/internal/core" "github.com/microsoft/typescript-go/internal/diagnostics" + "github.com/microsoft/typescript-go/internal/regexpchecker" "github.com/microsoft/typescript-go/internal/scanner" ) @@ -37,6 +38,5 @@ func (c *Checker) validateRegularExpressionLiteralNode(node *ast.RegularExpressi } } - // Perform regexp validation - scanner.ValidateRegularExpressionLiteral(node, sourceFile, c.languageVersion, onError) + regexpchecker.Check(node, sourceFile, c.languageVersion, onError) } diff --git a/internal/scanner/regexp.go b/internal/regexpchecker/regexpchecker.go similarity index 91% rename from internal/scanner/regexp.go rename to internal/regexpchecker/regexpchecker.go index a5f51a6ed8..9229c0abe1 100644 --- a/internal/scanner/regexp.go +++ b/internal/regexpchecker/regexpchecker.go @@ -1,4 +1,4 @@ -package scanner +package regexpchecker import ( "fmt" @@ -8,69 +8,70 @@ import ( "github.com/microsoft/typescript-go/internal/ast" "github.com/microsoft/typescript-go/internal/core" "github.com/microsoft/typescript-go/internal/diagnostics" + "github.com/microsoft/typescript-go/internal/scanner" "github.com/microsoft/typescript-go/internal/stringutil" ) -// RegExpFlags represents regexp flags (e.g., 'g', 'i', 'm', etc.) -type RegExpFlags uint32 +// regExpFlags represents regexp flags (e.g., 'g', 'i', 'm', etc.) +type regExpFlags uint32 const ( - RegExpFlagsNone RegExpFlags = 0 - RegExpFlagsGlobal RegExpFlags = 1 << 0 // g - RegExpFlagsIgnoreCase RegExpFlags = 1 << 1 // i - RegExpFlagsMultiline RegExpFlags = 1 << 2 // m - RegExpFlagsDotAll RegExpFlags = 1 << 3 // s - RegExpFlagsUnicode RegExpFlags = 1 << 4 // u - RegExpFlagsSticky RegExpFlags = 1 << 5 // y - RegExpFlagsHasIndices RegExpFlags = 1 << 6 // d - RegExpFlagsUnicodeSets RegExpFlags = 1 << 7 // v - RegExpFlagsModifiers RegExpFlags = RegExpFlagsIgnoreCase | RegExpFlagsMultiline | RegExpFlagsDotAll - RegExpFlagsAnyUnicodeMode RegExpFlags = RegExpFlagsUnicode | RegExpFlagsUnicodeSets + regExpFlagsNone regExpFlags = 0 + regExpFlagsGlobal regExpFlags = 1 << 0 // g + regExpFlagsIgnoreCase regExpFlags = 1 << 1 // i + regExpFlagsMultiline regExpFlags = 1 << 2 // m + regExpFlagsDotAll regExpFlags = 1 << 3 // s + regExpFlagsUnicode regExpFlags = 1 << 4 // u + regExpFlagsSticky regExpFlags = 1 << 5 // y + regExpFlagsHasIndices regExpFlags = 1 << 6 // d + regExpFlagsUnicodeSets regExpFlags = 1 << 7 // v + regExpFlagsModifiers regExpFlags = regExpFlagsIgnoreCase | regExpFlagsMultiline | regExpFlagsDotAll + regExpFlagsAnyUnicodeMode regExpFlags = regExpFlagsUnicode | regExpFlagsUnicodeSets ) -var charCodeToRegExpFlag = map[rune]RegExpFlags{ - 'd': RegExpFlagsHasIndices, - 'g': RegExpFlagsGlobal, - 'i': RegExpFlagsIgnoreCase, - 'm': RegExpFlagsMultiline, - 's': RegExpFlagsDotAll, - 'u': RegExpFlagsUnicode, - 'v': RegExpFlagsUnicodeSets, - 'y': RegExpFlagsSticky, +var charCodeToRegExpFlag = map[rune]regExpFlags{ + 'd': regExpFlagsHasIndices, + 'g': regExpFlagsGlobal, + 'i': regExpFlagsIgnoreCase, + 'm': regExpFlagsMultiline, + 's': regExpFlagsDotAll, + 'u': regExpFlagsUnicode, + 'v': regExpFlagsUnicodeSets, + 'y': regExpFlagsSticky, } -var regExpFlagToCharCode = map[RegExpFlags]rune{ - RegExpFlagsHasIndices: 'd', - RegExpFlagsGlobal: 'g', - RegExpFlagsIgnoreCase: 'i', - RegExpFlagsMultiline: 'm', - RegExpFlagsDotAll: 's', - RegExpFlagsUnicode: 'u', - RegExpFlagsUnicodeSets: 'v', - RegExpFlagsSticky: 'y', +var regExpFlagToCharCode = map[regExpFlags]rune{ + regExpFlagsHasIndices: 'd', + regExpFlagsGlobal: 'g', + regExpFlagsIgnoreCase: 'i', + regExpFlagsMultiline: 'm', + regExpFlagsDotAll: 's', + regExpFlagsUnicode: 'u', + regExpFlagsUnicodeSets: 'v', + regExpFlagsSticky: 'y', } -// CharacterCodeToRegularExpressionFlag converts a character code to a regexp flag -func CharacterCodeToRegularExpressionFlag(ch rune) (RegExpFlags, bool) { +// characterCodeToRegularExpressionFlag converts a character code to a regexp flag +func characterCodeToRegularExpressionFlag(ch rune) (regExpFlags, bool) { flag, ok := charCodeToRegExpFlag[ch] return flag, ok } -// RegularExpressionFlagToCharacterCode converts a regexp flag to a character code -func RegularExpressionFlagToCharacterCode(f RegExpFlags) (rune, bool) { +// regularExpressionFlagToCharacterCode converts a regexp flag to a character code +func regularExpressionFlagToCharacterCode(f regExpFlags) (rune, bool) { ch, ok := regExpFlagToCharCode[f] return ch, ok } -// RegExpValidator is used to validate regular expressions -type RegExpValidator struct { +// regExpValidator is used to validate regular expressions +type regExpValidator struct { text string pos int end int languageVersion core.ScriptTarget languageVariant core.LanguageVariant - onError ErrorCallback - regExpFlags RegExpFlags + onError scanner.ErrorCallback + regExpFlags regExpFlags annexB bool unicodeSetsMode bool anyUnicodeMode bool @@ -100,16 +101,14 @@ type decimalEscape struct { value int } -// ValidateRegularExpressionLiteral validates a regular expression literal node -// This is called from the checker package during semantic analysis -func ValidateRegularExpressionLiteral( +func Check( node *ast.RegularExpressionLiteral, sourceFile *ast.SourceFile, languageVersion core.ScriptTarget, - onError ErrorCallback, + onError scanner.ErrorCallback, ) { text := node.Text - v := &RegExpValidator{ + v := ®ExpValidator{ text: text, pos: 1, // Skip initial '/' end: len(text), @@ -117,11 +116,10 @@ func ValidateRegularExpressionLiteral( languageVariant: sourceFile.LanguageVariant, onError: onError, } - v.validateRegularExpression() } -func (v *RegExpValidator) validateRegularExpression() { +func (v *regExpValidator) validateRegularExpression() { // Find the body end (before flags) bodyEnd := v.findRegExpBodyEnd() if bodyEnd < 0 { @@ -131,20 +129,20 @@ func (v *RegExpValidator) validateRegularExpression() { // Parse flags flagsStart := bodyEnd + 1 v.pos = flagsStart - v.regExpFlags = RegExpFlagsNone + v.regExpFlags = regExpFlagsNone for v.pos < v.end { ch, size := v.charAndSize() - if !IsIdentifierPart(ch) { + if !scanner.IsIdentifierPart(ch) { break } - flag, ok := CharacterCodeToRegularExpressionFlag(ch) + flag, ok := characterCodeToRegularExpressionFlag(ch) if !ok { v.error(diagnostics.Unknown_regular_expression_flag, v.pos, size) } else if v.regExpFlags&flag != 0 { v.error(diagnostics.Duplicate_regular_expression_flag, v.pos, size) - } else if (v.regExpFlags|flag)&RegExpFlagsAnyUnicodeMode == RegExpFlagsAnyUnicodeMode { + } else if (v.regExpFlags|flag)®ExpFlagsAnyUnicodeMode == regExpFlagsAnyUnicodeMode { v.error(diagnostics.The_Unicode_u_flag_and_the_Unicode_Sets_v_flag_cannot_be_set_simultaneously, v.pos, size) } else { v.regExpFlags |= flag @@ -154,8 +152,8 @@ func (v *RegExpValidator) validateRegularExpression() { } // Set up validation parameters - v.unicodeSetsMode = v.regExpFlags&RegExpFlagsUnicodeSets != 0 - v.anyUnicodeMode = v.regExpFlags&RegExpFlagsAnyUnicodeMode != 0 + v.unicodeSetsMode = v.regExpFlags®ExpFlagsUnicodeSets != 0 + v.anyUnicodeMode = v.regExpFlags®ExpFlagsAnyUnicodeMode != 0 // Always validate as if in Annex B mode (matches JavaScript runtime behavior) v.annexB = true v.anyUnicodeModeOrNonAnnexB = v.anyUnicodeMode || !v.annexB @@ -170,7 +168,7 @@ func (v *RegExpValidator) validateRegularExpression() { v.validateDecimalEscapes() } -func (v *RegExpValidator) findRegExpBodyEnd() int { +func (v *regExpValidator) findRegExpBodyEnd() int { pos := 1 // Skip initial '/' inEscape := false inCharacterClass := false @@ -205,11 +203,11 @@ func (v *RegExpValidator) findRegExpBodyEnd() int { return -1 // Unterminated } -func (v *RegExpValidator) textStart() int { +func (v *regExpValidator) textStart() int { return 1 // Offset from node start (which includes the '/') } -func (v *RegExpValidator) charAndSize() (rune, int) { +func (v *regExpValidator) charAndSize() (rune, int) { if v.pos >= v.end { return 0, 0 } @@ -222,7 +220,7 @@ func (v *RegExpValidator) charAndSize() (rune, int) { return r, size } -func (v *RegExpValidator) charAtOffset(offset int) rune { +func (v *regExpValidator) charAtOffset(offset int) rune { if v.pos+offset >= v.end { return 0 } @@ -235,20 +233,20 @@ func (v *RegExpValidator) charAtOffset(offset int) rune { return r } -func (v *RegExpValidator) error(message *diagnostics.Message, start, length int, args ...any) { +func (v *regExpValidator) error(message *diagnostics.Message, start, length int, args ...any) { if v.onError != nil { v.onError(message, start, length, args...) } } -func (v *RegExpValidator) checkRegularExpressionFlagAvailability(flag RegExpFlags, size int) { +func (v *regExpValidator) checkRegularExpressionFlagAvailability(flag regExpFlags, size int) { var availableFrom core.ScriptTarget switch flag { - case RegExpFlagsHasIndices: + case regExpFlagsHasIndices: availableFrom = core.ScriptTargetES2022 - case RegExpFlagsDotAll: + case regExpFlagsDotAll: availableFrom = core.ScriptTargetES2018 - case RegExpFlagsUnicodeSets: + case regExpFlagsUnicodeSets: availableFrom = core.ScriptTargetES2024 default: return @@ -260,7 +258,7 @@ func (v *RegExpValidator) checkRegularExpressionFlagAvailability(flag RegExpFlag } } -func (v *RegExpValidator) scanDisjunction(isInGroup bool) { +func (v *regExpValidator) scanDisjunction(isInGroup bool) { for { v.namedCapturingGroupsScopeStack = append(v.namedCapturingGroupsScopeStack, v.topNamedCapturingGroupsScope) v.topNamedCapturingGroupsScope = nil @@ -275,7 +273,7 @@ func (v *RegExpValidator) scanDisjunction(isInGroup bool) { } } -func (v *RegExpValidator) scanAlternative(isInGroup bool) { +func (v *regExpValidator) scanAlternative(isInGroup bool) { isPreviousTermQuantifiable := false for { start := v.pos @@ -322,7 +320,7 @@ func (v *RegExpValidator) scanAlternative(isInGroup bool) { } default: start := v.pos - setFlags := v.scanPatternModifiers(RegExpFlagsNone) + setFlags := v.scanPatternModifiers(regExpFlagsNone) if v.charAtOffset(0) == '-' { v.pos++ v.scanPatternModifiers(setFlags) @@ -431,7 +429,7 @@ func (v *RegExpValidator) scanAlternative(isInGroup bool) { } } -func (v *RegExpValidator) validateGroupReferences() { +func (v *regExpValidator) validateGroupReferences() { for _, ref := range v.groupNameReferences { if !v.groupSpecifiers[ref.name] { v.error(diagnostics.There_is_no_capturing_group_named_0_in_this_regular_expression, ref.pos, ref.end-ref.pos, ref.name) @@ -451,7 +449,7 @@ func (v *RegExpValidator) validateGroupReferences() { } } -func (v *RegExpValidator) validateDecimalEscapes() { +func (v *regExpValidator) validateDecimalEscapes() { for _, escape := range v.decimalEscapes { if escape.value > v.numberOfCapturingGroups { if v.numberOfCapturingGroups > 0 { @@ -463,7 +461,7 @@ func (v *RegExpValidator) validateDecimalEscapes() { } } -func (v *RegExpValidator) scanDigits() { +func (v *regExpValidator) scanDigits() { start := v.pos for v.pos < v.end && stringutil.IsDigit(v.charAtOffset(0)) { v.pos++ @@ -471,7 +469,7 @@ func (v *RegExpValidator) scanDigits() { v.tokenValue = v.text[start:v.pos] } -func (v *RegExpValidator) scanExpectedChar(expected rune) { +func (v *regExpValidator) scanExpectedChar(expected rune) { if v.charAtOffset(0) == expected { v.pos++ } else { @@ -479,18 +477,18 @@ func (v *RegExpValidator) scanExpectedChar(expected rune) { } } -func (v *RegExpValidator) scanPatternModifiers(currFlags RegExpFlags) RegExpFlags { +func (v *regExpValidator) scanPatternModifiers(currFlags regExpFlags) regExpFlags { for { ch, size := v.charAndSize() - if ch == 0 || !IsIdentifierPart(ch) { + if ch == 0 || !scanner.IsIdentifierPart(ch) { break } - flag, ok := CharacterCodeToRegularExpressionFlag(ch) + flag, ok := characterCodeToRegularExpressionFlag(ch) if !ok { v.error(diagnostics.Unknown_regular_expression_flag, v.pos, size) } else if currFlags&flag != 0 { v.error(diagnostics.Duplicate_regular_expression_flag, v.pos, size) - } else if flag&RegExpFlagsModifiers == 0 { + } else if flag®ExpFlagsModifiers == 0 { v.error(diagnostics.This_regular_expression_flag_cannot_be_toggled_within_a_subpattern, v.pos, size) } else { currFlags |= flag @@ -501,7 +499,7 @@ func (v *RegExpValidator) scanPatternModifiers(currFlags RegExpFlags) RegExpFlag return currFlags } -func (v *RegExpValidator) scanAtomEscape() { +func (v *regExpValidator) scanAtomEscape() { switch v.charAtOffset(0) { case 'k': v.pos++ @@ -526,7 +524,7 @@ func (v *RegExpValidator) scanAtomEscape() { } } -func (v *RegExpValidator) scanDecimalEscape() bool { +func (v *regExpValidator) scanDecimalEscape() bool { ch := v.charAtOffset(0) if ch >= '1' && ch <= '9' { start := v.pos @@ -541,7 +539,7 @@ func (v *RegExpValidator) scanDecimalEscape() bool { return false } -func (v *RegExpValidator) scanCharacterClassEscape() bool { +func (v *regExpValidator) scanCharacterClassEscape() bool { ch := v.charAtOffset(0) isCharacterComplement := false switch ch { @@ -568,7 +566,7 @@ func (v *RegExpValidator) scanCharacterClassEscape() bool { return false } -func (v *RegExpValidator) scanUnicodePropertyValueExpression(isCharacterComplement bool) { +func (v *regExpValidator) scanUnicodePropertyValueExpression(isCharacterComplement bool) { // start is at the first character after '{', so start-3 points to '\' before 'p' or 'P' start := v.pos - 3 @@ -698,16 +696,16 @@ var nonBinaryUnicodePropertyNames = map[string]string{ "scx": "Script_Extensions", } -func (v *RegExpValidator) isValidUnicodePropertyName(name string) bool { +func (v *regExpValidator) isValidUnicodePropertyName(name string) bool { return generalCategoryValues[name] || binaryUnicodeProperties[name] } -func (v *RegExpValidator) isValidNonBinaryUnicodePropertyName(name string) bool { +func (v *regExpValidator) isValidNonBinaryUnicodePropertyName(name string) bool { _, ok := nonBinaryUnicodePropertyNames[name] return ok } -func (v *RegExpValidator) isValidUnicodeProperty(name, value string) bool { +func (v *regExpValidator) isValidUnicodeProperty(name, value string) bool { // Get canonical name canonicalName := nonBinaryUnicodePropertyNames[name] if canonicalName == "General_Category" { @@ -719,13 +717,13 @@ func (v *RegExpValidator) isValidUnicodeProperty(name, value string) bool { return false } -func (v *RegExpValidator) scanIdentifier(ch rune) { +func (v *regExpValidator) scanIdentifier(ch rune) { start := v.pos - if ch != 0 && (IsIdentifierStart(ch) || ch == '_' || ch == '$') { + if ch != 0 && (scanner.IsIdentifierStart(ch) || ch == '_' || ch == '$') { v.pos++ for v.pos < v.end { ch = v.charAtOffset(0) - if IsIdentifierPart(ch) || ch == '_' || ch == '$' { + if scanner.IsIdentifierPart(ch) || ch == '_' || ch == '$' { v.pos++ } else { break @@ -735,7 +733,7 @@ func (v *RegExpValidator) scanIdentifier(ch rune) { v.tokenValue = v.text[start:v.pos] } -func (v *RegExpValidator) scanCharacterEscape(atomEscape bool) string { +func (v *regExpValidator) scanCharacterEscape(atomEscape bool) string { ch := v.charAtOffset(0) switch ch { case 0: @@ -763,7 +761,7 @@ func (v *RegExpValidator) scanCharacterEscape(atomEscape bool) string { } } -func (v *RegExpValidator) scanEscapeSequence(atomEscape bool) string { +func (v *regExpValidator) scanEscapeSequence(atomEscape bool) string { // start points to the backslash (before the escape character) start := v.pos - 1 ch := v.charAtOffset(0) @@ -931,7 +929,7 @@ func (v *RegExpValidator) scanEscapeSequence(atomEscape bool) string { // Report error if: // - In any Unicode mode, OR // - In regexp mode, not Annex B, and ch is an identifier part - if v.anyUnicodeMode || (v.anyUnicodeModeOrNonAnnexB && IsIdentifierPart(ch)) { + if v.anyUnicodeMode || (v.anyUnicodeModeOrNonAnnexB && scanner.IsIdentifierPart(ch)) { v.error(diagnostics.This_character_cannot_be_escaped_in_a_regular_expression, start, v.pos-start) } return string(ch) @@ -1059,7 +1057,7 @@ func utf16Length(s string) int { return length } -func (v *RegExpValidator) scanGroupName(isReference bool) { +func (v *regExpValidator) scanGroupName(isReference bool) { tokenStart := v.pos v.scanIdentifier(v.charAtOffset(0)) if v.pos == tokenStart { @@ -1093,7 +1091,7 @@ func (v *RegExpValidator) scanGroupName(isReference bool) { // In Unicode mode (u or v flags), returns complete Unicode code points. // In non-Unicode mode, mimics JavaScript's UTF-16 behavior where literal characters // >= U+10000 are returned as individual surrogates (matching JS regexp semantics). -func (v *RegExpValidator) scanSourceCharacter() string { +func (v *regExpValidator) scanSourceCharacter() string { // Check if we have a pending low surrogate from splitting a previous character if !v.anyUnicodeMode && v.pendingLowSurrogate != 0 { low := v.pendingLowSurrogate @@ -1140,7 +1138,7 @@ func (v *RegExpValidator) scanSourceCharacter() string { // ClassRanges ::= ClassAtom ('-' ClassAtom)? // Scans character class content like [a-z] or [^0-9]. // Follows ECMAScript regexp grammar -func (v *RegExpValidator) scanClassRanges() { +func (v *regExpValidator) scanClassRanges() { isNegated := v.charAtOffset(0) == '^' if isNegated { v.pos++ @@ -1203,7 +1201,7 @@ func (v *RegExpValidator) scanClassRanges() { } } -func (v *RegExpValidator) isClassContentExit(ch rune) bool { +func (v *regExpValidator) isClassContentExit(ch rune) bool { return ch == ']' || ch == 0 || v.pos >= v.end } @@ -1213,7 +1211,7 @@ func (v *RegExpValidator) isClassContentExit(ch rune) bool { // | '\' ClassEscape // // Follows ECMAScript regexp grammar -func (v *RegExpValidator) scanClassAtom() string { +func (v *regExpValidator) scanClassAtom() string { if v.charAtOffset(0) == '\\' { v.pos++ return v.scanClassEscape() @@ -1229,7 +1227,7 @@ func (v *RegExpValidator) scanClassAtom() string { // | CharacterEscape // // Follows ECMAScript regexp grammar -func (v *RegExpValidator) scanClassEscape() string { +func (v *regExpValidator) scanClassEscape() string { if v.scanCharacterClassEscape() { return "" } @@ -1244,7 +1242,7 @@ const ( classSetExpressionIntersection ) -func (v *RegExpValidator) scanClassSetExpression() { +func (v *regExpValidator) scanClassSetExpression() { isCharacterComplement := false if v.charAtOffset(0) == '^' { v.pos++ @@ -1385,7 +1383,7 @@ func (v *RegExpValidator) scanClassSetExpression() { v.mayContainStrings = !isCharacterComplement && expressionMayContainStrings } -func (v *RegExpValidator) scanClassSetSubExpression(expressionType classSetExpressionType) { +func (v *regExpValidator) scanClassSetSubExpression(expressionType classSetExpressionType) { expressionMayContainStrings := v.mayContainStrings for { ch := v.charAtOffset(0) @@ -1446,7 +1444,7 @@ func (v *RegExpValidator) scanClassSetSubExpression(expressionType classSetExpre // | '\' CharacterClassEscape // | '\q{' ClassStringDisjunctionContents '}' // | ClassSetCharacter -func (v *RegExpValidator) scanClassSetOperand() string { +func (v *regExpValidator) scanClassSetOperand() string { v.mayContainStrings = false switch v.charAtOffset(0) { case 0: @@ -1479,7 +1477,7 @@ func (v *RegExpValidator) scanClassSetOperand() string { } // ClassStringDisjunctionContents ::= ClassSetCharacter* ('|' ClassSetCharacter*)* -func (v *RegExpValidator) scanClassStringDisjunctionContents() { +func (v *regExpValidator) scanClassStringDisjunctionContents() { characterCount := 0 for { ch := v.charAtOffset(0) @@ -1508,7 +1506,7 @@ func (v *RegExpValidator) scanClassStringDisjunctionContents() { // // | SourceCharacter -- ClassSetSyntaxCharacter -- ClassSetReservedDoublePunctuator // | '\' (CharacterEscape | ClassSetReservedPunctuator | 'b') -func (v *RegExpValidator) scanClassSetCharacter() string { +func (v *regExpValidator) scanClassSetCharacter() string { ch := v.charAtOffset(0) if ch == 0 { return "" From 918571e9d7881ddcc354ab9dfe13454d10677996 Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Tue, 4 Nov 2025 22:46:24 -0800 Subject: [PATCH 10/33] wip --- internal/regexpchecker/regexpchecker.go | 65 ++++++++++++++----------- 1 file changed, 36 insertions(+), 29 deletions(-) diff --git a/internal/regexpchecker/regexpchecker.go b/internal/regexpchecker/regexpchecker.go index 9229c0abe1..e04aff5744 100644 --- a/internal/regexpchecker/regexpchecker.go +++ b/internal/regexpchecker/regexpchecker.go @@ -86,7 +86,14 @@ type regExpValidator struct { mayContainStrings bool isCharacterComplement bool tokenValue string - pendingLowSurrogate rune // For non-Unicode mode: pending low surrogate to return + surrogateState *surrogatePairState // For non-Unicode mode: tracks partial surrogate pair +} + +// surrogatePairState tracks when we're in the middle of emitting a surrogate pair +// in non-Unicode mode (where literal characters >= U+10000 must be split into two UTF-16 code units) +type surrogatePairState struct { + lowSurrogate rune // The low surrogate value to return next + utf8Size int // Size of the UTF-8 character to advance past } type namedReference struct { @@ -1090,49 +1097,49 @@ func (v *regExpValidator) scanGroupName(isReference bool) { // scanSourceCharacter scans and returns a single "character" from the source. // In Unicode mode (u or v flags), returns complete Unicode code points. // In non-Unicode mode, mimics JavaScript's UTF-16 behavior where literal characters -// >= U+10000 are returned as individual surrogates (matching JS regexp semantics). +// >= U+10000 are treated as surrogate pairs and consumed across two sequential calls. func (v *regExpValidator) scanSourceCharacter() string { - // Check if we have a pending low surrogate from splitting a previous character - if !v.anyUnicodeMode && v.pendingLowSurrogate != 0 { - low := v.pendingLowSurrogate - size := v.pendingLowSurrogate >> 16 // High 16 bits store the UTF-8 size - v.pendingLowSurrogate = 0 - // Now advance v.pos to consume the UTF-8 character - v.pos += int(size) - // Return the low surrogate encoded as UTF-16BE 2-byte sequence - return string([]byte{byte(low >> 8), byte(low & 0xFF)}) + // Check if we have a pending low surrogate from the previous call + if v.surrogateState != nil { + low := v.surrogateState.lowSurrogate + size := v.surrogateState.utf8Size + v.surrogateState = nil + v.pos += size + // Return the low surrogate encoded as UTF-16BE + return encodeSurrogate(low) } - // Decode the next UTF-8 character + // Decode the next UTF-8 character from the source r, s := utf8.DecodeRuneInString(v.text[v.pos:]) if r == utf8.RuneError { v.pos++ return v.text[v.pos-1 : v.pos] } - if v.anyUnicodeMode { - // In Unicode mode, consume the full character + if v.anyUnicodeMode || r < 0x10000 { + // In Unicode mode, or for BMP characters, consume and return normally v.pos += s return v.text[v.pos-s : v.pos] } - // In non-Unicode mode, JavaScript treats characters as UTF-16 code units. - // For code points >= 0x10000, they are surrogate pairs, and we need to - // return them one UTF-16 code unit at a time (matching JS runtime behavior). - if r >= 0x10000 { - // This character requires a surrogate pair in UTF-16. - // Return the high surrogate now, and save the low surrogate for next time. - high := 0xD800 + ((r-0x10000)>>10)&0x3FF - low := 0xDC00 + ((r - 0x10000) & 0x3FF) - // Store the low surrogate in lower 16 bits, and UTF-8 size in upper 16 bits - v.pendingLowSurrogate = low | (rune(s) << 16) - // Return the high surrogate encoded as UTF-16BE 2-byte sequence - return string([]byte{byte(high >> 8), byte(high & 0xFF)}) + // In non-Unicode mode with a supplementary character (>= U+10000): + // JavaScript represents these as surrogate pairs (two UTF-16 code units). + // Return the high surrogate now and save the low surrogate for the next call. + high := 0xD800 + ((r-0x10000)>>10)&0x3FF + low := 0xDC00 + ((r - 0x10000) & 0x3FF) + + v.surrogateState = &surrogatePairState{ + lowSurrogate: low, + utf8Size: s, } - // For code points < 0x10000, consume and return the character normally - v.pos += s - return v.text[v.pos-s : v.pos] + return encodeSurrogate(high) +} + +// encodeSurrogate encodes a UTF-16 surrogate value as a 2-byte UTF-16BE sequence. +// This preserves the surrogate value (which would otherwise be invalid in UTF-8/UTF-32). +func encodeSurrogate(surrogate rune) string { + return string([]byte{byte(surrogate >> 8), byte(surrogate & 0xFF)}) } // ClassRanges ::= ClassAtom ('-' ClassAtom)? From 9c50cd8c27e3aa5e80a0880d70dff35587396273 Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Tue, 4 Nov 2025 22:48:51 -0800 Subject: [PATCH 11/33] wip --- internal/regexpchecker/regexpchecker.go | 58 ------------------------- 1 file changed, 58 deletions(-) diff --git a/internal/regexpchecker/regexpchecker.go b/internal/regexpchecker/regexpchecker.go index e04aff5744..3ee8e0272e 100644 --- a/internal/regexpchecker/regexpchecker.go +++ b/internal/regexpchecker/regexpchecker.go @@ -40,29 +40,12 @@ var charCodeToRegExpFlag = map[rune]regExpFlags{ 'y': regExpFlagsSticky, } -var regExpFlagToCharCode = map[regExpFlags]rune{ - regExpFlagsHasIndices: 'd', - regExpFlagsGlobal: 'g', - regExpFlagsIgnoreCase: 'i', - regExpFlagsMultiline: 'm', - regExpFlagsDotAll: 's', - regExpFlagsUnicode: 'u', - regExpFlagsUnicodeSets: 'v', - regExpFlagsSticky: 'y', -} - // characterCodeToRegularExpressionFlag converts a character code to a regexp flag func characterCodeToRegularExpressionFlag(ch rune) (regExpFlags, bool) { flag, ok := charCodeToRegExpFlag[ch] return flag, ok } -// regularExpressionFlagToCharacterCode converts a regexp flag to a character code -func regularExpressionFlagToCharacterCode(f regExpFlags) (rune, bool) { - ch, ok := regExpFlagToCharCode[f] - return ch, ok -} - // regExpValidator is used to validate regular expressions type regExpValidator struct { text string @@ -210,10 +193,6 @@ func (v *regExpValidator) findRegExpBodyEnd() int { return -1 // Unterminated } -func (v *regExpValidator) textStart() int { - return 1 // Offset from node start (which includes the '/') -} - func (v *regExpValidator) charAndSize() (rune, int) { if v.pos >= v.end { return 0, 0 @@ -1001,43 +980,6 @@ func charSize(ch rune) int { return 1 } -// utf16ComparisonValue returns the UTF-16 code unit value to use for range comparison -// In non-Unicode mode, JavaScript compares the low surrogate for code points >= 0x10000 -func utf16ComparisonValue(s string) rune { - if len(s) == 0 { - return 0 - } - r, _ := utf8.DecodeRuneInString(s) - // For code points >= 0x10000, return the low surrogate value - // This matches JavaScript's behavior in non-Unicode mode where surrogate pairs - // are treated as separate code units - if r >= 0x10000 { - return 0xDC00 + ((r - 0x10000) & 0x3FF) - } - return r -} - -// stringCharSize returns the expected string length for a code point in our representation -// Surrogate pairs are represented as 2-rune strings, each rune encoded as UTF-8 -func stringCharSize(ch rune) int { - if ch >= 0x10000 { - // High surrogate (0xD800-0xDBFF): 3 bytes in UTF-8 - // Low surrogate (0xDC00-0xDFFF): 3 bytes in UTF-8 - // Total: 6 bytes - return 6 - } - if ch >= 0x800 { - return 3 - } - if ch >= 0x80 { - return 2 - } - if ch == 0 { - return 0 - } - return 1 -} - // utf16Length returns the UTF-16 length of a string, matching JavaScript's string.length // This counts UTF-16 code units, where surrogate pairs count as 2 units // Handles both UTF-8 encoded strings and special 2-byte UTF-16BE surrogate encodings From 9cade067eac57bd9c943388d0da71afb90b4e85d Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Tue, 4 Nov 2025 23:28:51 -0800 Subject: [PATCH 12/33] Validate extended Unicode escape values in regexp scanner and add baselines for out-of-range escapes - Check parsed hex code point in regexp escape sequences and emit error if > 0x10FFFF - Add test baselines for unicodeExtendedEscapesInRegularExpressions07 and 12 (ES5/ES6) showing TS1198 for out-of-range values - Remove obsolete .diff baseline artifacts --- internal/regexpchecker/regexpchecker.go | 4 ++++ ...esInRegularExpressions07(target=es5).errors.txt | 10 ++++++++++ ...egularExpressions07(target=es5).errors.txt.diff | 14 -------------- ...esInRegularExpressions07(target=es6).errors.txt | 10 ++++++++++ ...egularExpressions07(target=es6).errors.txt.diff | 14 -------------- ...esInRegularExpressions12(target=es5).errors.txt | 8 ++++++++ ...egularExpressions12(target=es5).errors.txt.diff | 12 ------------ ...esInRegularExpressions12(target=es6).errors.txt | 8 ++++++++ ...egularExpressions12(target=es6).errors.txt.diff | 12 ------------ 9 files changed, 40 insertions(+), 52 deletions(-) create mode 100644 testdata/baselines/reference/submodule/conformance/unicodeExtendedEscapesInRegularExpressions07(target=es5).errors.txt delete mode 100644 testdata/baselines/reference/submodule/conformance/unicodeExtendedEscapesInRegularExpressions07(target=es5).errors.txt.diff create mode 100644 testdata/baselines/reference/submodule/conformance/unicodeExtendedEscapesInRegularExpressions07(target=es6).errors.txt delete mode 100644 testdata/baselines/reference/submodule/conformance/unicodeExtendedEscapesInRegularExpressions07(target=es6).errors.txt.diff create mode 100644 testdata/baselines/reference/submodule/conformance/unicodeExtendedEscapesInRegularExpressions12(target=es5).errors.txt delete mode 100644 testdata/baselines/reference/submodule/conformance/unicodeExtendedEscapesInRegularExpressions12(target=es5).errors.txt.diff create mode 100644 testdata/baselines/reference/submodule/conformance/unicodeExtendedEscapesInRegularExpressions12(target=es6).errors.txt delete mode 100644 testdata/baselines/reference/submodule/conformance/unicodeExtendedEscapesInRegularExpressions12(target=es6).errors.txt.diff diff --git a/internal/regexpchecker/regexpchecker.go b/internal/regexpchecker/regexpchecker.go index 3ee8e0272e..c54dfe130e 100644 --- a/internal/regexpchecker/regexpchecker.go +++ b/internal/regexpchecker/regexpchecker.go @@ -849,6 +849,10 @@ func (v *regExpValidator) scanEscapeSequence(atomEscape bool) string { } // Parse hex value (-1 to skip closing brace) code := parseHexValue(v.text, hexStart, v.pos-1) + // Validate the code point is within valid Unicode range + if code > 0x10FFFF { + v.error(diagnostics.An_extended_Unicode_escape_value_must_be_between_0x0_and_0x10FFFF_inclusive, hexStart, v.pos-1-hexStart) + } if !v.anyUnicodeMode { v.error(diagnostics.Unicode_escape_sequences_are_only_available_when_the_Unicode_u_flag_or_the_Unicode_Sets_v_flag_is_set, start, v.pos-start) } diff --git a/testdata/baselines/reference/submodule/conformance/unicodeExtendedEscapesInRegularExpressions07(target=es5).errors.txt b/testdata/baselines/reference/submodule/conformance/unicodeExtendedEscapesInRegularExpressions07(target=es5).errors.txt new file mode 100644 index 0000000000..51228e4c87 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/unicodeExtendedEscapesInRegularExpressions07(target=es5).errors.txt @@ -0,0 +1,10 @@ +unicodeExtendedEscapesInRegularExpressions07.ts(3,13): error TS1198: An extended Unicode escape value must be between 0x0 and 0x10FFFF inclusive. + + +==== unicodeExtendedEscapesInRegularExpressions07.ts (1 errors) ==== + // ES6 Spec - 10.1.1 Static Semantics: UTF16Encoding (cp) + // 1. Assert: 0 ≤ cp ≤ 0x10FFFF. + var x = /\u{110000}/gu; + ~~~~~~ +!!! error TS1198: An extended Unicode escape value must be between 0x0 and 0x10FFFF inclusive. + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/unicodeExtendedEscapesInRegularExpressions07(target=es5).errors.txt.diff b/testdata/baselines/reference/submodule/conformance/unicodeExtendedEscapesInRegularExpressions07(target=es5).errors.txt.diff deleted file mode 100644 index 87410caeea..0000000000 --- a/testdata/baselines/reference/submodule/conformance/unicodeExtendedEscapesInRegularExpressions07(target=es5).errors.txt.diff +++ /dev/null @@ -1,14 +0,0 @@ ---- old.unicodeExtendedEscapesInRegularExpressions07(target=es5).errors.txt -+++ new.unicodeExtendedEscapesInRegularExpressions07(target=es5).errors.txt -@@= skipped -0, +0 lines =@@ --unicodeExtendedEscapesInRegularExpressions07.ts(3,13): error TS1198: An extended Unicode escape value must be between 0x0 and 0x10FFFF inclusive. -- -- --==== unicodeExtendedEscapesInRegularExpressions07.ts (1 errors) ==== -- // ES6 Spec - 10.1.1 Static Semantics: UTF16Encoding (cp) -- // 1. Assert: 0 ≤ cp ≤ 0x10FFFF. -- var x = /\u{110000}/gu; -- ~~~~~~ --!!! error TS1198: An extended Unicode escape value must be between 0x0 and 0x10FFFF inclusive. -- -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/unicodeExtendedEscapesInRegularExpressions07(target=es6).errors.txt b/testdata/baselines/reference/submodule/conformance/unicodeExtendedEscapesInRegularExpressions07(target=es6).errors.txt new file mode 100644 index 0000000000..51228e4c87 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/unicodeExtendedEscapesInRegularExpressions07(target=es6).errors.txt @@ -0,0 +1,10 @@ +unicodeExtendedEscapesInRegularExpressions07.ts(3,13): error TS1198: An extended Unicode escape value must be between 0x0 and 0x10FFFF inclusive. + + +==== unicodeExtendedEscapesInRegularExpressions07.ts (1 errors) ==== + // ES6 Spec - 10.1.1 Static Semantics: UTF16Encoding (cp) + // 1. Assert: 0 ≤ cp ≤ 0x10FFFF. + var x = /\u{110000}/gu; + ~~~~~~ +!!! error TS1198: An extended Unicode escape value must be between 0x0 and 0x10FFFF inclusive. + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/unicodeExtendedEscapesInRegularExpressions07(target=es6).errors.txt.diff b/testdata/baselines/reference/submodule/conformance/unicodeExtendedEscapesInRegularExpressions07(target=es6).errors.txt.diff deleted file mode 100644 index 095c977c6b..0000000000 --- a/testdata/baselines/reference/submodule/conformance/unicodeExtendedEscapesInRegularExpressions07(target=es6).errors.txt.diff +++ /dev/null @@ -1,14 +0,0 @@ ---- old.unicodeExtendedEscapesInRegularExpressions07(target=es6).errors.txt -+++ new.unicodeExtendedEscapesInRegularExpressions07(target=es6).errors.txt -@@= skipped -0, +0 lines =@@ --unicodeExtendedEscapesInRegularExpressions07.ts(3,13): error TS1198: An extended Unicode escape value must be between 0x0 and 0x10FFFF inclusive. -- -- --==== unicodeExtendedEscapesInRegularExpressions07.ts (1 errors) ==== -- // ES6 Spec - 10.1.1 Static Semantics: UTF16Encoding (cp) -- // 1. Assert: 0 ≤ cp ≤ 0x10FFFF. -- var x = /\u{110000}/gu; -- ~~~~~~ --!!! error TS1198: An extended Unicode escape value must be between 0x0 and 0x10FFFF inclusive. -- -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/unicodeExtendedEscapesInRegularExpressions12(target=es5).errors.txt b/testdata/baselines/reference/submodule/conformance/unicodeExtendedEscapesInRegularExpressions12(target=es5).errors.txt new file mode 100644 index 0000000000..71bc964c77 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/unicodeExtendedEscapesInRegularExpressions12(target=es5).errors.txt @@ -0,0 +1,8 @@ +unicodeExtendedEscapesInRegularExpressions12.ts(1,13): error TS1198: An extended Unicode escape value must be between 0x0 and 0x10FFFF inclusive. + + +==== unicodeExtendedEscapesInRegularExpressions12.ts (1 errors) ==== + var x = /\u{FFFFFFFF}/gu; + ~~~~~~~~ +!!! error TS1198: An extended Unicode escape value must be between 0x0 and 0x10FFFF inclusive. + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/unicodeExtendedEscapesInRegularExpressions12(target=es5).errors.txt.diff b/testdata/baselines/reference/submodule/conformance/unicodeExtendedEscapesInRegularExpressions12(target=es5).errors.txt.diff deleted file mode 100644 index 654852c80b..0000000000 --- a/testdata/baselines/reference/submodule/conformance/unicodeExtendedEscapesInRegularExpressions12(target=es5).errors.txt.diff +++ /dev/null @@ -1,12 +0,0 @@ ---- old.unicodeExtendedEscapesInRegularExpressions12(target=es5).errors.txt -+++ new.unicodeExtendedEscapesInRegularExpressions12(target=es5).errors.txt -@@= skipped -0, +0 lines =@@ --unicodeExtendedEscapesInRegularExpressions12.ts(1,13): error TS1198: An extended Unicode escape value must be between 0x0 and 0x10FFFF inclusive. -- -- --==== unicodeExtendedEscapesInRegularExpressions12.ts (1 errors) ==== -- var x = /\u{FFFFFFFF}/gu; -- ~~~~~~~~ --!!! error TS1198: An extended Unicode escape value must be between 0x0 and 0x10FFFF inclusive. -- -+ \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/unicodeExtendedEscapesInRegularExpressions12(target=es6).errors.txt b/testdata/baselines/reference/submodule/conformance/unicodeExtendedEscapesInRegularExpressions12(target=es6).errors.txt new file mode 100644 index 0000000000..71bc964c77 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/unicodeExtendedEscapesInRegularExpressions12(target=es6).errors.txt @@ -0,0 +1,8 @@ +unicodeExtendedEscapesInRegularExpressions12.ts(1,13): error TS1198: An extended Unicode escape value must be between 0x0 and 0x10FFFF inclusive. + + +==== unicodeExtendedEscapesInRegularExpressions12.ts (1 errors) ==== + var x = /\u{FFFFFFFF}/gu; + ~~~~~~~~ +!!! error TS1198: An extended Unicode escape value must be between 0x0 and 0x10FFFF inclusive. + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/unicodeExtendedEscapesInRegularExpressions12(target=es6).errors.txt.diff b/testdata/baselines/reference/submodule/conformance/unicodeExtendedEscapesInRegularExpressions12(target=es6).errors.txt.diff deleted file mode 100644 index 3ce7eaec31..0000000000 --- a/testdata/baselines/reference/submodule/conformance/unicodeExtendedEscapesInRegularExpressions12(target=es6).errors.txt.diff +++ /dev/null @@ -1,12 +0,0 @@ ---- old.unicodeExtendedEscapesInRegularExpressions12(target=es6).errors.txt -+++ new.unicodeExtendedEscapesInRegularExpressions12(target=es6).errors.txt -@@= skipped -0, +0 lines =@@ --unicodeExtendedEscapesInRegularExpressions12.ts(1,13): error TS1198: An extended Unicode escape value must be between 0x0 and 0x10FFFF inclusive. -- -- --==== unicodeExtendedEscapesInRegularExpressions12.ts (1 errors) ==== -- var x = /\u{FFFFFFFF}/gu; -- ~~~~~~~~ --!!! error TS1198: An extended Unicode escape value must be between 0x0 and 0x10FFFF inclusive. -- -+ \ No newline at end of file From 2ab00a32d384cc60cd616918e4fcb2b755b8e102 Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Wed, 5 Nov 2025 09:47:38 -0800 Subject: [PATCH 13/33] Include pending low surrogate in character class range error When reporting "Range out of order in character class", extend the diagnostic length to include a pending low surrogate (using surrogateState.utf8Size). This ensures the error highlight covers the full surrogate pair in non-Unicode mode. Update baselines to reflect the corrected highlight spans. --- internal/regexpchecker/regexpchecker.go | 10 +++++++++- ...egularExpressionCharacterClassRangeOrder.errors.txt | 4 ++-- ...rExpressionCharacterClassRangeOrder.errors.txt.diff | 4 ++-- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/internal/regexpchecker/regexpchecker.go b/internal/regexpchecker/regexpchecker.go index c54dfe130e..18a211d847 100644 --- a/internal/regexpchecker/regexpchecker.go +++ b/internal/regexpchecker/regexpchecker.go @@ -1147,7 +1147,15 @@ func (v *regExpValidator) scanClassRanges() { // points being compared are already the surrogate values (0xD800-0xDFFF). // Escape sequences like \u{1D608} return the full character, so the // code points are the actual values (>= 0x10000). - v.error(diagnostics.Range_out_of_order_in_character_class, atomStart, v.pos-atomStart) + + // If there's a pending low surrogate from scanning the second atom, + // we need to account for its UTF-8 size in the error range. + errorEnd := v.pos + if v.surrogateState != nil { + errorEnd += v.surrogateState.utf8Size + } + length := errorEnd - atomStart + v.error(diagnostics.Range_out_of_order_in_character_class, atomStart, length) } } } diff --git a/testdata/baselines/reference/submodule/compiler/regularExpressionCharacterClassRangeOrder.errors.txt b/testdata/baselines/reference/submodule/compiler/regularExpressionCharacterClassRangeOrder.errors.txt index 6fbc29d6fe..6a2614dc0e 100644 --- a/testdata/baselines/reference/submodule/compiler/regularExpressionCharacterClassRangeOrder.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/regularExpressionCharacterClassRangeOrder.errors.txt @@ -23,9 +23,9 @@ regularExpressionCharacterClassRangeOrder.ts(17,31): error TS1517: Range out of // See https://en.wikipedia.org/wiki/Mathematical_Alphanumeric_Symbols const regexes: RegExp[] = [ /[š˜ˆ-š˜”][š˜”-š˜ˆ]/, - ~~ + ~~~ !!! error TS1517: Range out of order in character class. - ~~ + ~~~ !!! error TS1517: Range out of order in character class. /[š˜ˆ-š˜”][š˜”-š˜ˆ]/u, ~~~ diff --git a/testdata/baselines/reference/submodule/compiler/regularExpressionCharacterClassRangeOrder.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/regularExpressionCharacterClassRangeOrder.errors.txt.diff index 6135e7e82a..451d8be820 100644 --- a/testdata/baselines/reference/submodule/compiler/regularExpressionCharacterClassRangeOrder.errors.txt.diff +++ b/testdata/baselines/reference/submodule/compiler/regularExpressionCharacterClassRangeOrder.errors.txt.diff @@ -17,10 +17,10 @@ const regexes: RegExp[] = [ /[š˜ˆ-š˜”][š˜”-š˜ˆ]/, - ~~~ -+ ~~ ++ ~~~ !!! error TS1517: Range out of order in character class. - ~~~ -+ ~~ ++ ~~~ !!! error TS1517: Range out of order in character class. /[š˜ˆ-š˜”][š˜”-š˜ˆ]/u, - ~~~~~ From 6b788d2fc8148483ae7f48d5cad0ebdc4a795150 Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Wed, 5 Nov 2025 09:59:37 -0800 Subject: [PATCH 14/33] Simplify --- internal/checker/grammarchecks.go | 25 ++++++++++++++++-- internal/checker/regexpchecks.go | 42 ------------------------------- 2 files changed, 23 insertions(+), 44 deletions(-) delete mode 100644 internal/checker/regexpchecks.go diff --git a/internal/checker/grammarchecks.go b/internal/checker/grammarchecks.go index 8500240c2b..febaf2e5af 100644 --- a/internal/checker/grammarchecks.go +++ b/internal/checker/grammarchecks.go @@ -11,6 +11,7 @@ import ( "github.com/microsoft/typescript-go/internal/debug" "github.com/microsoft/typescript-go/internal/diagnostics" "github.com/microsoft/typescript-go/internal/jsnum" + "github.com/microsoft/typescript-go/internal/regexpchecker" "github.com/microsoft/typescript-go/internal/scanner" "github.com/microsoft/typescript-go/internal/tspath" ) @@ -55,8 +56,28 @@ func (c *Checker) grammarErrorOnNodeSkippedOnNoEmit(node *ast.Node, message *dia } func (c *Checker) checkGrammarRegularExpressionLiteral(node *ast.RegularExpressionLiteral) bool { - // Validate the regular expression during semantic analysis - c.validateRegularExpressionLiteralNode(node) + sourceFile := ast.GetSourceFileOfNode(node.AsNode()) + if !c.hasParseDiagnostics(sourceFile) && node.AsNode().LiteralLikeData().TokenFlags&ast.TokenFlagsUnterminated == 0 { + var lastError *ast.Diagnostic + + onError := func(message *diagnostics.Message, start int, length int, args ...any) { + nodeStart := scanner.GetTokenPosOfNode(node.AsNode(), sourceFile, false) + adjustedStart := nodeStart + start + + if message.Category() == diagnostics.CategoryMessage && lastError != nil && + adjustedStart == lastError.Pos() && length == lastError.Len() { + err := ast.NewDiagnostic(nil, core.NewTextRange(adjustedStart, adjustedStart+length), message, args...) + lastError.AddRelatedInfo(err) + } else if lastError == nil || adjustedStart != lastError.Pos() { + lastError = ast.NewDiagnostic(sourceFile, core.NewTextRange(adjustedStart, adjustedStart+length), message, args...) + c.diagnostics.Add(lastError) + } + } + + regexpchecker.Check(node, sourceFile, c.languageVersion, onError) + + return lastError != nil + } return false } diff --git a/internal/checker/regexpchecks.go b/internal/checker/regexpchecks.go deleted file mode 100644 index 45d21786a9..0000000000 --- a/internal/checker/regexpchecks.go +++ /dev/null @@ -1,42 +0,0 @@ -package checker - -import ( - "github.com/microsoft/typescript-go/internal/ast" - "github.com/microsoft/typescript-go/internal/core" - "github.com/microsoft/typescript-go/internal/diagnostics" - "github.com/microsoft/typescript-go/internal/regexpchecker" - "github.com/microsoft/typescript-go/internal/scanner" -) - -// validateRegularExpressionLiteralNode validates a regular expression literal during semantic analysis. -// This function is called from checkGrammarRegularExpressionLiteral and performs deep validation -// of the regexp pattern and flags that would affect code generation based on language version. -func (c *Checker) validateRegularExpressionLiteralNode(node *ast.RegularExpressionLiteral) { - sourceFile := ast.GetSourceFileOfNode(node.AsNode()) - // Check if the token has the Unterminated flag - if c.hasParseDiagnostics(sourceFile) || node.AsNode().LiteralLikeData().TokenFlags&ast.TokenFlagsUnterminated != 0 { - return - } - - var lastError *ast.Diagnostic - - // Create an error callback that collects diagnostics - onError := func(message *diagnostics.Message, start int, length int, args ...any) { - // Adjust start position relative to the node position in the source file (skipping leading trivia) - nodeStart := scanner.GetTokenPosOfNode(node.AsNode(), sourceFile, false) - adjustedStart := nodeStart + start - - // For providing spelling suggestions - if this is a suggestion message, - // add it as related info to the previous error - if message.Category() == diagnostics.CategoryMessage && lastError != nil && - adjustedStart == lastError.Pos() && length == lastError.Len() { - err := ast.NewDiagnostic(nil, core.NewTextRange(adjustedStart, adjustedStart+length), message, args...) - lastError.AddRelatedInfo(err) - } else if lastError == nil || adjustedStart != lastError.Pos() { - lastError = ast.NewDiagnostic(sourceFile, core.NewTextRange(adjustedStart, adjustedStart+length), message, args...) - c.diagnostics.Add(lastError) - } - } - - regexpchecker.Check(node, sourceFile, c.languageVersion, onError) -} From e1c3215e672bc9d3513ada9a1cd70cf118b4ef20 Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Wed, 5 Nov 2025 10:00:27 -0800 Subject: [PATCH 15/33] Simplify --- internal/checker/grammarchecks.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/checker/grammarchecks.go b/internal/checker/grammarchecks.go index febaf2e5af..ba61cd32a8 100644 --- a/internal/checker/grammarchecks.go +++ b/internal/checker/grammarchecks.go @@ -57,7 +57,7 @@ func (c *Checker) grammarErrorOnNodeSkippedOnNoEmit(node *ast.Node, message *dia func (c *Checker) checkGrammarRegularExpressionLiteral(node *ast.RegularExpressionLiteral) bool { sourceFile := ast.GetSourceFileOfNode(node.AsNode()) - if !c.hasParseDiagnostics(sourceFile) && node.AsNode().LiteralLikeData().TokenFlags&ast.TokenFlagsUnterminated == 0 { + if !c.hasParseDiagnostics(sourceFile) && node.TokenFlags&ast.TokenFlagsUnterminated == 0 { var lastError *ast.Diagnostic onError := func(message *diagnostics.Message, start int, length int, args ...any) { From 1831e7b1230f16f647acefdda613346f2413adb1 Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Wed, 5 Nov 2025 10:06:08 -0800 Subject: [PATCH 16/33] Simplify --- internal/checker/grammarchecks.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/internal/checker/grammarchecks.go b/internal/checker/grammarchecks.go index ba61cd32a8..f4b7d50468 100644 --- a/internal/checker/grammarchecks.go +++ b/internal/checker/grammarchecks.go @@ -60,16 +60,16 @@ func (c *Checker) checkGrammarRegularExpressionLiteral(node *ast.RegularExpressi if !c.hasParseDiagnostics(sourceFile) && node.TokenFlags&ast.TokenFlagsUnterminated == 0 { var lastError *ast.Diagnostic + nodeStart := scanner.GetTokenPosOfNode(node.AsNode(), sourceFile, false) onError := func(message *diagnostics.Message, start int, length int, args ...any) { - nodeStart := scanner.GetTokenPosOfNode(node.AsNode(), sourceFile, false) - adjustedStart := nodeStart + start + start += nodeStart if message.Category() == diagnostics.CategoryMessage && lastError != nil && - adjustedStart == lastError.Pos() && length == lastError.Len() { - err := ast.NewDiagnostic(nil, core.NewTextRange(adjustedStart, adjustedStart+length), message, args...) + start == lastError.Pos() && length == lastError.Len() { + err := ast.NewDiagnostic(nil, core.NewTextRange(start, start+length), message, args...) lastError.AddRelatedInfo(err) - } else if lastError == nil || adjustedStart != lastError.Pos() { - lastError = ast.NewDiagnostic(sourceFile, core.NewTextRange(adjustedStart, adjustedStart+length), message, args...) + } else if lastError == nil || start != lastError.Pos() { + lastError = ast.NewDiagnostic(sourceFile, core.NewTextRange(start, start+length), message, args...) c.diagnostics.Add(lastError) } } From e9443854219e3af236804ed0f60738d46dfe2254 Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Wed, 5 Nov 2025 10:14:01 -0800 Subject: [PATCH 17/33] Delete temp test --- .../reference/compiler/regexpTestSimple.errors.txt | 12 ------------ .../baselines/reference/compiler/regexpTestSimple.js | 10 ---------- .../reference/compiler/regexpTestSimple.symbols | 7 ------- .../reference/compiler/regexpTestSimple.types | 8 -------- testdata/tests/cases/compiler/regexpTestSimple.ts | 3 --- 5 files changed, 40 deletions(-) delete mode 100644 testdata/baselines/reference/compiler/regexpTestSimple.errors.txt delete mode 100644 testdata/baselines/reference/compiler/regexpTestSimple.js delete mode 100644 testdata/baselines/reference/compiler/regexpTestSimple.symbols delete mode 100644 testdata/baselines/reference/compiler/regexpTestSimple.types delete mode 100644 testdata/tests/cases/compiler/regexpTestSimple.ts diff --git a/testdata/baselines/reference/compiler/regexpTestSimple.errors.txt b/testdata/baselines/reference/compiler/regexpTestSimple.errors.txt deleted file mode 100644 index 0094755150..0000000000 --- a/testdata/baselines/reference/compiler/regexpTestSimple.errors.txt +++ /dev/null @@ -1,12 +0,0 @@ -regexpTestSimple.ts(2,16): error TS1499: Unknown regular expression flag. -regexpTestSimple.ts(2,18): error TS1499: Unknown regular expression flag. - - -==== regexpTestSimple.ts (2 errors) ==== - // Simple test - const x = /foo/xyz; - ~ -!!! error TS1499: Unknown regular expression flag. - ~ -!!! error TS1499: Unknown regular expression flag. - \ No newline at end of file diff --git a/testdata/baselines/reference/compiler/regexpTestSimple.js b/testdata/baselines/reference/compiler/regexpTestSimple.js deleted file mode 100644 index c855a7f9fc..0000000000 --- a/testdata/baselines/reference/compiler/regexpTestSimple.js +++ /dev/null @@ -1,10 +0,0 @@ -//// [tests/cases/compiler/regexpTestSimple.ts] //// - -//// [regexpTestSimple.ts] -// Simple test -const x = /foo/xyz; - - -//// [regexpTestSimple.js] -// Simple test -const x = /foo/xyz; diff --git a/testdata/baselines/reference/compiler/regexpTestSimple.symbols b/testdata/baselines/reference/compiler/regexpTestSimple.symbols deleted file mode 100644 index f1e0130855..0000000000 --- a/testdata/baselines/reference/compiler/regexpTestSimple.symbols +++ /dev/null @@ -1,7 +0,0 @@ -//// [tests/cases/compiler/regexpTestSimple.ts] //// - -=== regexpTestSimple.ts === -// Simple test -const x = /foo/xyz; ->x : Symbol(x, Decl(regexpTestSimple.ts, 1, 5)) - diff --git a/testdata/baselines/reference/compiler/regexpTestSimple.types b/testdata/baselines/reference/compiler/regexpTestSimple.types deleted file mode 100644 index 2167d88e90..0000000000 --- a/testdata/baselines/reference/compiler/regexpTestSimple.types +++ /dev/null @@ -1,8 +0,0 @@ -//// [tests/cases/compiler/regexpTestSimple.ts] //// - -=== regexpTestSimple.ts === -// Simple test -const x = /foo/xyz; ->x : RegExp ->/foo/xyz : RegExp - diff --git a/testdata/tests/cases/compiler/regexpTestSimple.ts b/testdata/tests/cases/compiler/regexpTestSimple.ts deleted file mode 100644 index 8d8746a8e6..0000000000 --- a/testdata/tests/cases/compiler/regexpTestSimple.ts +++ /dev/null @@ -1,3 +0,0 @@ -// @strict: true -// Simple test -const x = /foo/xyz; From 2d4159cb0c099020e831154b1d46b90b81ee44fc Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Wed, 5 Nov 2025 10:17:25 -0800 Subject: [PATCH 18/33] Remove helper --- internal/regexpchecker/regexpchecker.go | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/internal/regexpchecker/regexpchecker.go b/internal/regexpchecker/regexpchecker.go index 18a211d847..7871eee0e5 100644 --- a/internal/regexpchecker/regexpchecker.go +++ b/internal/regexpchecker/regexpchecker.go @@ -40,12 +40,6 @@ var charCodeToRegExpFlag = map[rune]regExpFlags{ 'y': regExpFlagsSticky, } -// characterCodeToRegularExpressionFlag converts a character code to a regexp flag -func characterCodeToRegularExpressionFlag(ch rune) (regExpFlags, bool) { - flag, ok := charCodeToRegExpFlag[ch] - return flag, ok -} - // regExpValidator is used to validate regular expressions type regExpValidator struct { text string @@ -127,7 +121,7 @@ func (v *regExpValidator) validateRegularExpression() { break } - flag, ok := characterCodeToRegularExpressionFlag(ch) + flag, ok := charCodeToRegExpFlag[ch] if !ok { v.error(diagnostics.Unknown_regular_expression_flag, v.pos, size) } else if v.regExpFlags&flag != 0 { @@ -469,7 +463,7 @@ func (v *regExpValidator) scanPatternModifiers(currFlags regExpFlags) regExpFlag if ch == 0 || !scanner.IsIdentifierPart(ch) { break } - flag, ok := characterCodeToRegularExpressionFlag(ch) + flag, ok := charCodeToRegExpFlag[ch] if !ok { v.error(diagnostics.Unknown_regular_expression_flag, v.pos, size) } else if currFlags&flag != 0 { From d6a8a5cac28abff8333af4065f6809dc26a50596 Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Wed, 5 Nov 2025 10:48:47 -0800 Subject: [PATCH 19/33] refactor --- internal/regexpchecker/regexpchecker.go | 38 +++++++++---------------- 1 file changed, 13 insertions(+), 25 deletions(-) diff --git a/internal/regexpchecker/regexpchecker.go b/internal/regexpchecker/regexpchecker.go index 7871eee0e5..ee5f66994b 100644 --- a/internal/regexpchecker/regexpchecker.go +++ b/internal/regexpchecker/regexpchecker.go @@ -100,10 +100,10 @@ func Check( languageVariant: sourceFile.LanguageVariant, onError: onError, } - v.validateRegularExpression() + v.scanRegularExpressionWorker() } -func (v *regExpValidator) validateRegularExpression() { +func (v *regExpValidator) scanRegularExpressionWorker() { // Find the body end (before flags) bodyEnd := v.findRegExpBodyEnd() if bodyEnd < 0 { @@ -113,27 +113,7 @@ func (v *regExpValidator) validateRegularExpression() { // Parse flags flagsStart := bodyEnd + 1 v.pos = flagsStart - v.regExpFlags = regExpFlagsNone - - for v.pos < v.end { - ch, size := v.charAndSize() - if !scanner.IsIdentifierPart(ch) { - break - } - - flag, ok := charCodeToRegExpFlag[ch] - if !ok { - v.error(diagnostics.Unknown_regular_expression_flag, v.pos, size) - } else if v.regExpFlags&flag != 0 { - v.error(diagnostics.Duplicate_regular_expression_flag, v.pos, size) - } else if (v.regExpFlags|flag)®ExpFlagsAnyUnicodeMode == regExpFlagsAnyUnicodeMode { - v.error(diagnostics.The_Unicode_u_flag_and_the_Unicode_Sets_v_flag_cannot_be_set_simultaneously, v.pos, size) - } else { - v.regExpFlags |= flag - v.checkRegularExpressionFlagAvailability(flag, size) - } - v.pos += size - } + v.regExpFlags = v.scanFlags(regExpFlagsNone, false) // Set up validation parameters v.unicodeSetsMode = v.regExpFlags®ExpFlagsUnicodeSets != 0 @@ -457,7 +437,9 @@ func (v *regExpValidator) scanExpectedChar(expected rune) { } } -func (v *regExpValidator) scanPatternModifiers(currFlags regExpFlags) regExpFlags { +// scanFlags scans regexp flags and validates them. +// If checkModifiers is true, only allows modifier flags (i, m, s). +func (v *regExpValidator) scanFlags(currFlags regExpFlags, checkModifiers bool) regExpFlags { for { ch, size := v.charAndSize() if ch == 0 || !scanner.IsIdentifierPart(ch) { @@ -468,7 +450,9 @@ func (v *regExpValidator) scanPatternModifiers(currFlags regExpFlags) regExpFlag v.error(diagnostics.Unknown_regular_expression_flag, v.pos, size) } else if currFlags&flag != 0 { v.error(diagnostics.Duplicate_regular_expression_flag, v.pos, size) - } else if flag®ExpFlagsModifiers == 0 { + } else if (currFlags|flag)®ExpFlagsAnyUnicodeMode == regExpFlagsAnyUnicodeMode { + v.error(diagnostics.The_Unicode_u_flag_and_the_Unicode_Sets_v_flag_cannot_be_set_simultaneously, v.pos, size) + } else if checkModifiers && flag®ExpFlagsModifiers == 0 { v.error(diagnostics.This_regular_expression_flag_cannot_be_toggled_within_a_subpattern, v.pos, size) } else { currFlags |= flag @@ -479,6 +463,10 @@ func (v *regExpValidator) scanPatternModifiers(currFlags regExpFlags) regExpFlag return currFlags } +func (v *regExpValidator) scanPatternModifiers(currFlags regExpFlags) regExpFlags { + return v.scanFlags(currFlags, true) +} + func (v *regExpValidator) scanAtomEscape() { switch v.charAtOffset(0) { case 'k': From b36d0276d6284d2208c0460a41711da47901ea1e Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Wed, 5 Nov 2025 10:56:43 -0800 Subject: [PATCH 20/33] refactor --- internal/regexpchecker/regexpchecker.go | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/internal/regexpchecker/regexpchecker.go b/internal/regexpchecker/regexpchecker.go index ee5f66994b..7313f8ccd2 100644 --- a/internal/regexpchecker/regexpchecker.go +++ b/internal/regexpchecker/regexpchecker.go @@ -106,9 +106,6 @@ func Check( func (v *regExpValidator) scanRegularExpressionWorker() { // Find the body end (before flags) bodyEnd := v.findRegExpBodyEnd() - if bodyEnd < 0 { - return // Already unterminated - } // Parse flags flagsStart := bodyEnd + 1 @@ -164,7 +161,7 @@ func (v *regExpValidator) findRegExpBodyEnd() int { pos++ } - return -1 // Unterminated + panic("regexpchecker: unterminated regex should have been caught by scanner") } func (v *regExpValidator) charAndSize() (rune, int) { From d878c541ff0530cae1e4bba472c074c4493db092 Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Wed, 5 Nov 2025 11:00:12 -0800 Subject: [PATCH 21/33] Simplify --- internal/regexpchecker/regexpchecker.go | 36 ++++--------------------- 1 file changed, 5 insertions(+), 31 deletions(-) diff --git a/internal/regexpchecker/regexpchecker.go b/internal/regexpchecker/regexpchecker.go index 7313f8ccd2..22954de7e1 100644 --- a/internal/regexpchecker/regexpchecker.go +++ b/internal/regexpchecker/regexpchecker.go @@ -130,38 +130,12 @@ func (v *regExpValidator) scanRegularExpressionWorker() { } func (v *regExpValidator) findRegExpBodyEnd() int { - pos := 1 // Skip initial '/' - inEscape := false - inCharacterClass := false - - for pos < len(v.text) { - ch := v.text[pos] - if ch == '\\' && !inEscape { - inEscape = true - pos++ - continue - } - - if inEscape { - inEscape = false - pos++ - continue - } - - if ch == '/' && !inCharacterClass { - return pos - } - - if ch == '[' { - inCharacterClass = true - } else if ch == ']' { - inCharacterClass = false - } - - pos++ + // Find the last '/' which closes the pattern + pos := strings.LastIndexByte(v.text, '/') + if pos <= 0 { + panic("regexpchecker: regex must have closing '/' (scanner should have validated)") } - - panic("regexpchecker: unterminated regex should have been caught by scanner") + return pos } func (v *regExpValidator) charAndSize() (rune, int) { From 24e7ea174f7117ceae77cba2de66826ba7057db1 Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Wed, 5 Nov 2025 11:34:08 -0800 Subject: [PATCH 22/33] more refactors --- internal/regexpchecker/regexpchecker.go | 30 +++++++++---------------- 1 file changed, 10 insertions(+), 20 deletions(-) diff --git a/internal/regexpchecker/regexpchecker.go b/internal/regexpchecker/regexpchecker.go index 22954de7e1..0c3b7f6255 100644 --- a/internal/regexpchecker/regexpchecker.go +++ b/internal/regexpchecker/regexpchecker.go @@ -94,22 +94,23 @@ func Check( text := node.Text v := ®ExpValidator{ text: text, - pos: 1, // Skip initial '/' - end: len(text), languageVersion: languageVersion, languageVariant: sourceFile.LanguageVariant, onError: onError, } - v.scanRegularExpressionWorker() -} -func (v *regExpValidator) scanRegularExpressionWorker() { + // Similar to the original scanRegularExpressionWorker, but since we are outside the scanner, + // we need to rescan to find the body end and recalculate flags. + // Find the body end (before flags) - bodyEnd := v.findRegExpBodyEnd() + bodyEnd := strings.LastIndexByte(text, '/') + if bodyEnd <= 0 { + panic("regexpchecker: regex must have closing '/' (scanner should have validated)") + } // Parse flags - flagsStart := bodyEnd + 1 - v.pos = flagsStart + v.pos = bodyEnd + 1 + v.end = len(text) v.regExpFlags = v.scanFlags(regExpFlagsNone, false) // Set up validation parameters @@ -129,15 +130,6 @@ func (v *regExpValidator) scanRegularExpressionWorker() { v.validateDecimalEscapes() } -func (v *regExpValidator) findRegExpBodyEnd() int { - // Find the last '/' which closes the pattern - pos := strings.LastIndexByte(v.text, '/') - if pos <= 0 { - panic("regexpchecker: regex must have closing '/' (scanner should have validated)") - } - return pos -} - func (v *regExpValidator) charAndSize() (rune, int) { if v.pos >= v.end { return 0, 0 @@ -165,9 +157,7 @@ func (v *regExpValidator) charAtOffset(offset int) rune { } func (v *regExpValidator) error(message *diagnostics.Message, start, length int, args ...any) { - if v.onError != nil { - v.onError(message, start, length, args...) - } + v.onError(message, start, length, args...) } func (v *regExpValidator) checkRegularExpressionFlagAvailability(flag regExpFlags, size int) { From 6e230fb53b766c44be8d1f8fea819cf93d67a042 Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Wed, 5 Nov 2025 11:47:32 -0800 Subject: [PATCH 23/33] move code around --- internal/regexpchecker/regexpchecker.go | 65 +-- internal/regexpchecker/tables.go | 558 ++++++++++++++++++++++++ 2 files changed, 564 insertions(+), 59 deletions(-) create mode 100644 internal/regexpchecker/tables.go diff --git a/internal/regexpchecker/regexpchecker.go b/internal/regexpchecker/regexpchecker.go index 0c3b7f6255..1748624c53 100644 --- a/internal/regexpchecker/regexpchecker.go +++ b/internal/regexpchecker/regexpchecker.go @@ -116,7 +116,7 @@ func Check( // Set up validation parameters v.unicodeSetsMode = v.regExpFlags®ExpFlagsUnicodeSets != 0 v.anyUnicodeMode = v.regExpFlags®ExpFlagsAnyUnicodeMode != 0 - // Always validate as if in Annex B mode (matches JavaScript runtime behavior) + // Always validate as if in Annex B mode v.annexB = true v.anyUnicodeModeOrNonAnnexB = v.anyUnicodeMode || !v.annexB @@ -174,7 +174,7 @@ func (v *regExpValidator) checkRegularExpressionFlagAvailability(flag regExpFlag } if v.languageVersion < availableFrom { - // Workaround: TypeScript uses lowercase ES version names in error messages (e.g., "es2024" not "ES2024") + // !!! Old compiler lowercases these names. v.error(diagnostics.This_regular_expression_flag_is_only_available_when_targeting_0_or_later, v.pos, size, strings.ToLower(availableFrom.String())) } } @@ -509,7 +509,7 @@ func (v *regExpValidator) scanUnicodePropertyValueExpression(isCharacterCompleme if v.pos == propertyNameOrValueStart { v.error(diagnostics.Expected_a_Unicode_property_name, propertyNameOrValueStart, 0) propertyNameValid = false - } else if !v.isValidNonBinaryUnicodePropertyName(propertyNameOrValue) { + } else if !isValidNonBinaryUnicodePropertyName(propertyNameOrValue) { v.error(diagnostics.Unknown_Unicode_property_name, propertyNameOrValueStart, v.pos-propertyNameOrValueStart) // Provide spelling suggestion candidates := make([]string, 0, len(nonBinaryUnicodePropertyNames)) @@ -528,7 +528,7 @@ func (v *regExpValidator) scanUnicodePropertyValueExpression(isCharacterCompleme propertyValue := v.tokenValue if v.pos == propertyValueStart { v.error(diagnostics.Expected_a_Unicode_property_value, propertyValueStart, 0) - } else if propertyNameValid && !v.isValidUnicodeProperty(propertyNameOrValue, propertyValue) { + } else if propertyNameValid && !isValidUnicodeProperty(propertyNameOrValue, propertyValue) { v.error(diagnostics.Unknown_Unicode_property_value, propertyValueStart, v.pos-propertyValueStart) // Provide spelling suggestion based on the property name canonicalName := nonBinaryUnicodePropertyNames[propertyNameOrValue] @@ -564,7 +564,7 @@ func (v *regExpValidator) scanUnicodePropertyValueExpression(isCharacterCompleme } else { v.mayContainStrings = true } - } else if !v.isValidUnicodePropertyName(propertyNameOrValue) { + } else if !isValidUnicodePropertyName(propertyNameOrValue) { v.error(diagnostics.Unknown_Unicode_property_name_or_value, propertyNameOrValueStart, v.pos-propertyNameOrValueStart) // Provide spelling suggestion from general category values, binary properties, and binary properties of strings candidates := make([]string, 0, len(generalCategoryValues)+len(binaryUnicodeProperties)+len(binaryUnicodePropertiesOfStrings)) @@ -577,7 +577,7 @@ func (v *regExpValidator) scanUnicodePropertyValueExpression(isCharacterCompleme for key := range binaryUnicodePropertiesOfStrings { candidates = append(candidates, key) } - suggestion := core.GetSpellingSuggestion(propertyNameOrValue, candidates, core.Identity[string]) + suggestion := core.GetSpellingSuggestion(propertyNameOrValue, candidates, core.Identity) if suggestion != "" { v.error(diagnostics.Did_you_mean_0, propertyNameOrValueStart, v.pos-propertyNameOrValueStart, suggestion) } @@ -593,59 +593,6 @@ func (v *regExpValidator) scanUnicodePropertyValueExpression(isCharacterCompleme } } -// Table 67: Binary Unicode property aliases and their canonical property names -// https://tc39.es/ecma262/#table-binary-unicode-properties -var binaryUnicodeProperties = map[string]bool{ - "ASCII": true, "ASCII_Hex_Digit": true, "AHex": true, "Alphabetic": true, "Alpha": true, "Any": true, "Assigned": true, "Bidi_Control": true, "Bidi_C": true, "Bidi_Mirrored": true, "Bidi_M": true, "Case_Ignorable": true, "CI": true, "Cased": true, "Changes_When_Casefolded": true, "CWCF": true, "Changes_When_Casemapped": true, "CWCM": true, "Changes_When_Lowercased": true, "CWL": true, "Changes_When_NFKC_Casefolded": true, "CWKCF": true, "Changes_When_Titlecased": true, "CWT": true, "Changes_When_Uppercased": true, "CWU": true, "Dash": true, "Default_Ignorable_Code_Point": true, "DI": true, "Deprecated": true, "Dep": true, "Diacritic": true, "Dia": true, "Emoji": true, "Emoji_Component": true, "EComp": true, "Emoji_Modifier": true, "EMod": true, "Emoji_Modifier_Base": true, "EBase": true, "Emoji_Presentation": true, "EPres": true, "Extended_Pictographic": true, "ExtPict": true, "Extender": true, "Ext": true, "Grapheme_Base": true, "Gr_Base": true, "Grapheme_Extend": true, "Gr_Ext": true, "Hex_Digit": true, "Hex": true, "IDS_Binary_Operator": true, "IDSB": true, "IDS_Trinary_Operator": true, "IDST": true, "ID_Continue": true, "IDC": true, "ID_Start": true, "IDS": true, "Ideographic": true, "Ideo": true, "Join_Control": true, "Join_C": true, "Logical_Order_Exception": true, "LOE": true, "Lowercase": true, "Lower": true, "Math": true, "Noncharacter_Code_Point": true, "NChar": true, "Pattern_Syntax": true, "Pat_Syn": true, "Pattern_White_Space": true, "Pat_WS": true, "Quotation_Mark": true, "QMark": true, "Radical": true, "Regional_Indicator": true, "RI": true, "Sentence_Terminal": true, "STerm": true, "Soft_Dotted": true, "SD": true, "Terminal_Punctuation": true, "Term": true, "Unified_Ideograph": true, "UIdeo": true, "Uppercase": true, "Upper": true, "Variation_Selector": true, "VS": true, "White_Space": true, "space": true, "XID_Continue": true, "XIDC": true, "XID_Start": true, "XIDS": true, -} - -// Table 68: Binary Unicode properties of strings -// https://tc39.es/ecma262/#table-binary-unicode-properties-of-strings -var binaryUnicodePropertiesOfStrings = map[string]bool{ - "Basic_Emoji": true, "Emoji_Keycap_Sequence": true, "RGI_Emoji_Modifier_Sequence": true, "RGI_Emoji_Flag_Sequence": true, "RGI_Emoji_Tag_Sequence": true, "RGI_Emoji_ZWJ_Sequence": true, "RGI_Emoji": true, -} - -// Unicode 15.1 - General_Category values -var generalCategoryValues = map[string]bool{ - "C": true, "Other": true, "Cc": true, "Control": true, "cntrl": true, "Cf": true, "Format": true, "Cn": true, "Unassigned": true, "Co": true, "Private_Use": true, "Cs": true, "Surrogate": true, "L": true, "Letter": true, "LC": true, "Cased_Letter": true, "Ll": true, "Lowercase_Letter": true, "Lm": true, "Modifier_Letter": true, "Lo": true, "Other_Letter": true, "Lt": true, "Titlecase_Letter": true, "Lu": true, "Uppercase_Letter": true, "M": true, "Mark": true, "Combining_Mark": true, "Mc": true, "Spacing_Mark": true, "Me": true, "Enclosing_Mark": true, "Mn": true, "Nonspacing_Mark": true, "N": true, "Number": true, "Nd": true, "Decimal_Number": true, "digit": true, "Nl": true, "Letter_Number": true, "No": true, "Other_Number": true, "P": true, "Punctuation": true, "punct": true, "Pc": true, "Connector_Punctuation": true, "Pd": true, "Dash_Punctuation": true, "Pe": true, "Close_Punctuation": true, "Pf": true, "Final_Punctuation": true, "Pi": true, "Initial_Punctuation": true, "Po": true, "Other_Punctuation": true, "Ps": true, "Open_Punctuation": true, "S": true, "Symbol": true, "Sc": true, "Currency_Symbol": true, "Sk": true, "Modifier_Symbol": true, "Sm": true, "Math_Symbol": true, "So": true, "Other_Symbol": true, "Z": true, "Separator": true, "Zl": true, "Line_Separator": true, "Zp": true, "Paragraph_Separator": true, "Zs": true, "Space_Separator": true, -} - -// Unicode 15.1 - Script values -var scriptValues = map[string]bool{ - "Adlm": true, "Adlam": true, "Aghb": true, "Caucasian_Albanian": true, "Ahom": true, "Arab": true, "Arabic": true, "Armi": true, "Imperial_Aramaic": true, "Armn": true, "Armenian": true, "Avst": true, "Avestan": true, "Bali": true, "Balinese": true, "Bamu": true, "Bamum": true, "Bass": true, "Bassa_Vah": true, "Batk": true, "Batak": true, "Beng": true, "Bengali": true, "Bhks": true, "Bhaiksuki": true, "Bopo": true, "Bopomofo": true, "Brah": true, "Brahmi": true, "Brai": true, "Braille": true, "Bugi": true, "Buginese": true, "Buhd": true, "Buhid": true, "Cakm": true, "Chakma": true, "Cans": true, "Canadian_Aboriginal": true, "Cari": true, "Carian": true, "Cham": true, "Cher": true, "Cherokee": true, "Chrs": true, "Chorasmian": true, "Copt": true, "Coptic": true, "Qaac": true, "Cpmn": true, "Cypro_Minoan": true, "Cprt": true, "Cypriot": true, "Cyrl": true, "Cyrillic": true, "Deva": true, "Devanagari": true, "Diak": true, "Dives_Akuru": true, "Dogr": true, "Dogra": true, "Dsrt": true, "Deseret": true, "Dupl": true, "Duployan": true, "Egyp": true, "Egyptian_Hieroglyphs": true, "Elba": true, "Elbasan": true, "Elym": true, "Elymaic": true, "Ethi": true, "Ethiopic": true, "Geor": true, "Georgian": true, "Glag": true, "Glagolitic": true, "Gong": true, "Gunjala_Gondi": true, "Gonm": true, "Masaram_Gondi": true, "Goth": true, "Gothic": true, "Gran": true, "Grantha": true, "Grek": true, "Greek": true, "Gujr": true, "Gujarati": true, "Guru": true, "Gurmukhi": true, "Hang": true, "Hangul": true, "Hani": true, "Han": true, "Hano": true, "Hanunoo": true, "Hatr": true, "Hatran": true, "Hebr": true, "Hebrew": true, "Hira": true, "Hiragana": true, "Hluw": true, "Anatolian_Hieroglyphs": true, "Hmng": true, "Pahawh_Hmong": true, "Hmnp": true, "Nyiakeng_Puachue_Hmong": true, "Hrkt": true, "Katakana_Or_Hiragana": true, "Hung": true, "Old_Hungarian": true, "Ital": true, "Old_Italic": true, "Java": true, "Javanese": true, "Kali": true, "Kayah_Li": true, "Kana": true, "Katakana": true, "Kawi": true, "Khar": true, "Kharoshthi": true, "Khmr": true, "Khmer": true, "Khoj": true, "Khojki": true, "Kits": true, "Khitan_Small_Script": true, "Knda": true, "Kannada": true, "Kthi": true, "Kaithi": true, "Lana": true, "Tai_Tham": true, "Laoo": true, "Lao": true, "Latn": true, "Latin": true, "Lepc": true, "Lepcha": true, "Limb": true, "Limbu": true, "Lina": true, "Linear_A": true, "Linb": true, "Linear_B": true, "Lisu": true, "Lyci": true, "Lycian": true, "Lydi": true, "Lydian": true, "Mahj": true, "Mahajani": true, "Maka": true, "Makasar": true, "Mand": true, "Mandaic": true, "Mani": true, "Manichaean": true, "Marc": true, "Marchen": true, "Medf": true, "Medefaidrin": true, "Mend": true, "Mende_Kikakui": true, "Merc": true, "Meroitic_Cursive": true, "Mero": true, "Meroitic_Hieroglyphs": true, "Mlym": true, "Malayalam": true, "Modi": true, "Mong": true, "Mongolian": true, "Mroo": true, "Mro": true, "Mtei": true, "Meetei_Mayek": true, "Mult": true, "Multani": true, "Mymr": true, "Myanmar": true, "Nagm": true, "Nag_Mundari": true, "Nand": true, "Nandinagari": true, "Narb": true, "Old_North_Arabian": true, "Nbat": true, "Nabataean": true, "Newa": true, "Nkoo": true, "Nko": true, "Nshu": true, "Nushu": true, "Ogam": true, "Ogham": true, "Olck": true, "Ol_Chiki": true, "Orkh": true, "Old_Turkic": true, "Orya": true, "Oriya": true, "Osge": true, "Osage": true, "Osma": true, "Osmanya": true, "Ougr": true, "Old_Uyghur": true, "Palm": true, "Palmyrene": true, "Pauc": true, "Pau_Cin_Hau": true, "Perm": true, "Old_Permic": true, "Phag": true, "Phags_Pa": true, "Phli": true, "Inscriptional_Pahlavi": true, "Phlp": true, "Psalter_Pahlavi": true, "Phnx": true, "Phoenician": true, "Plrd": true, "Miao": true, "Prti": true, "Inscriptional_Parthian": true, "Rjng": true, "Rejang": true, "Rohg": true, "Hanifi_Rohingya": true, "Runr": true, "Runic": true, "Samr": true, "Samaritan": true, "Sarb": true, "Old_South_Arabian": true, "Saur": true, "Saurashtra": true, "Sgnw": true, "SignWriting": true, "Shaw": true, "Shavian": true, "Shrd": true, "Sharada": true, "Sidd": true, "Siddham": true, "Sind": true, "Khudawadi": true, "Sinh": true, "Sinhala": true, "Sogd": true, "Sogdian": true, "Sogo": true, "Old_Sogdian": true, "Sora": true, "Sora_Sompeng": true, "Soyo": true, "Soyombo": true, "Sund": true, "Sundanese": true, "Sylo": true, "Syloti_Nagri": true, "Syrc": true, "Syriac": true, "Tagb": true, "Tagbanwa": true, "Takr": true, "Takri": true, "Tale": true, "Tai_Le": true, "Talu": true, "New_Tai_Lue": true, "Taml": true, "Tamil": true, "Tang": true, "Tangut": true, "Tavt": true, "Tai_Viet": true, "Telu": true, "Telugu": true, "Tfng": true, "Tifinagh": true, "Tglg": true, "Tagalog": true, "Thaa": true, "Thaana": true, "Thai": true, "Tibt": true, "Tibetan": true, "Tirh": true, "Tirhuta": true, "Tnsa": true, "Tangsa": true, "Toto": true, "Ugar": true, "Ugaritic": true, "Vaii": true, "Vai": true, "Vith": true, "Vithkuqi": true, "Wara": true, "Warang_Citi": true, "Wcho": true, "Wancho": true, "Xpeo": true, "Old_Persian": true, "Xsux": true, "Cuneiform": true, "Yezi": true, "Yezidi": true, "Yiii": true, "Yi": true, "Zanb": true, "Zanabazar_Square": true, "Zinh": true, "Inherited": true, "Qaai": true, "Zyyy": true, "Common": true, "Zzzz": true, "Unknown": true, -} - -// Map of non-binary property names to their canonical names -var nonBinaryUnicodePropertyNames = map[string]string{ - "General_Category": "General_Category", - "gc": "General_Category", - "Script": "Script", - "sc": "Script", - "Script_Extensions": "Script_Extensions", - "scx": "Script_Extensions", -} - -func (v *regExpValidator) isValidUnicodePropertyName(name string) bool { - return generalCategoryValues[name] || binaryUnicodeProperties[name] -} - -func (v *regExpValidator) isValidNonBinaryUnicodePropertyName(name string) bool { - _, ok := nonBinaryUnicodePropertyNames[name] - return ok -} - -func (v *regExpValidator) isValidUnicodeProperty(name, value string) bool { - // Get canonical name - canonicalName := nonBinaryUnicodePropertyNames[name] - if canonicalName == "General_Category" { - return generalCategoryValues[value] - } - if canonicalName == "Script" || canonicalName == "Script_Extensions" { - return scriptValues[value] - } - return false -} - func (v *regExpValidator) scanIdentifier(ch rune) { start := v.pos if ch != 0 && (scanner.IsIdentifierStart(ch) || ch == '_' || ch == '$') { diff --git a/internal/regexpchecker/tables.go b/internal/regexpchecker/tables.go new file mode 100644 index 0000000000..dfddb90ab1 --- /dev/null +++ b/internal/regexpchecker/tables.go @@ -0,0 +1,558 @@ +package regexpchecker + +// Table 67: Binary Unicode property aliases and their canonical property names +// https://tc39.es/ecma262/#table-binary-unicode-properties +var binaryUnicodeProperties = map[string]bool{ + "ASCII": true, + "ASCII_Hex_Digit": true, + "AHex": true, + "Alphabetic": true, + "Alpha": true, + "Any": true, + "Assigned": true, + "Bidi_Control": true, + "Bidi_C": true, + "Bidi_Mirrored": true, + "Bidi_M": true, + "Case_Ignorable": true, + "CI": true, + "Cased": true, + "Changes_When_Casefolded": true, + "CWCF": true, + "Changes_When_Casemapped": true, + "CWCM": true, + "Changes_When_Lowercased": true, + "CWL": true, + "Changes_When_NFKC_Casefolded": true, + "CWKCF": true, + "Changes_When_Titlecased": true, + "CWT": true, + "Changes_When_Uppercased": true, + "CWU": true, + "Dash": true, + "Default_Ignorable_Code_Point": true, + "DI": true, + "Deprecated": true, + "Dep": true, + "Diacritic": true, + "Dia": true, + "Emoji": true, + "Emoji_Component": true, + "EComp": true, + "Emoji_Modifier": true, + "EMod": true, + "Emoji_Modifier_Base": true, + "EBase": true, + "Emoji_Presentation": true, + "EPres": true, + "Extended_Pictographic": true, + "ExtPict": true, + "Extender": true, + "Ext": true, + "Grapheme_Base": true, + "Gr_Base": true, + "Grapheme_Extend": true, + "Gr_Ext": true, + "Hex_Digit": true, + "Hex": true, + "IDS_Binary_Operator": true, + "IDSB": true, + "IDS_Trinary_Operator": true, + "IDST": true, + "ID_Continue": true, + "IDC": true, + "ID_Start": true, + "IDS": true, + "Ideographic": true, + "Ideo": true, + "Join_Control": true, + "Join_C": true, + "Logical_Order_Exception": true, + "LOE": true, + "Lowercase": true, + "Lower": true, + "Math": true, + "Noncharacter_Code_Point": true, + "NChar": true, + "Pattern_Syntax": true, + "Pat_Syn": true, + "Pattern_White_Space": true, + "Pat_WS": true, + "Quotation_Mark": true, + "QMark": true, + "Radical": true, + "Regional_Indicator": true, + "RI": true, + "Sentence_Terminal": true, + "STerm": true, + "Soft_Dotted": true, + "SD": true, + "Terminal_Punctuation": true, + "Term": true, + "Unified_Ideograph": true, + "UIdeo": true, + "Uppercase": true, + "Upper": true, + "Variation_Selector": true, + "VS": true, + "White_Space": true, + "space": true, + "XID_Continue": true, + "XIDC": true, + "XID_Start": true, + "XIDS": true, +} + +// Table 68: Binary Unicode properties of strings +// https://tc39.es/ecma262/#table-binary-unicode-properties-of-strings +var binaryUnicodePropertiesOfStrings = map[string]bool{ + "Basic_Emoji": true, + "Emoji_Keycap_Sequence": true, + "RGI_Emoji_Modifier_Sequence": true, + "RGI_Emoji_Flag_Sequence": true, + "RGI_Emoji_Tag_Sequence": true, + "RGI_Emoji_ZWJ_Sequence": true, + "RGI_Emoji": true, +} + +// Unicode 15.1 - General_Category values +var generalCategoryValues = map[string]bool{ + "C": true, + "Other": true, + "Cc": true, + "Control": true, + "cntrl": true, + "Cf": true, + "Format": true, + "Cn": true, + "Unassigned": true, + "Co": true, + "Private_Use": true, + "Cs": true, + "Surrogate": true, + "L": true, + "Letter": true, + "LC": true, + "Cased_Letter": true, + "Ll": true, + "Lowercase_Letter": true, + "Lm": true, + "Modifier_Letter": true, + "Lo": true, + "Other_Letter": true, + "Lt": true, + "Titlecase_Letter": true, + "Lu": true, + "Uppercase_Letter": true, + "M": true, + "Mark": true, + "Combining_Mark": true, + "Mc": true, + "Spacing_Mark": true, + "Me": true, + "Enclosing_Mark": true, + "Mn": true, + "Nonspacing_Mark": true, + "N": true, + "Number": true, + "Nd": true, + "Decimal_Number": true, + "digit": true, + "Nl": true, + "Letter_Number": true, + "No": true, + "Other_Number": true, + "P": true, + "Punctuation": true, + "punct": true, + "Pc": true, + "Connector_Punctuation": true, + "Pd": true, + "Dash_Punctuation": true, + "Pe": true, + "Close_Punctuation": true, + "Pf": true, + "Final_Punctuation": true, + "Pi": true, + "Initial_Punctuation": true, + "Po": true, + "Other_Punctuation": true, + "Ps": true, + "Open_Punctuation": true, + "S": true, + "Symbol": true, + "Sc": true, + "Currency_Symbol": true, + "Sk": true, + "Modifier_Symbol": true, + "Sm": true, + "Math_Symbol": true, + "So": true, + "Other_Symbol": true, + "Z": true, + "Separator": true, + "Zl": true, + "Line_Separator": true, + "Zp": true, + "Paragraph_Separator": true, + "Zs": true, + "Space_Separator": true, +} + +// Unicode 15.1 - Script values +var scriptValues = map[string]bool{ + "Adlm": true, + "Adlam": true, + "Aghb": true, + "Caucasian_Albanian": true, + "Ahom": true, + "Arab": true, + "Arabic": true, + "Armi": true, + "Imperial_Aramaic": true, + "Armn": true, + "Armenian": true, + "Avst": true, + "Avestan": true, + "Bali": true, + "Balinese": true, + "Bamu": true, + "Bamum": true, + "Bass": true, + "Bassa_Vah": true, + "Batk": true, + "Batak": true, + "Beng": true, + "Bengali": true, + "Bhks": true, + "Bhaiksuki": true, + "Bopo": true, + "Bopomofo": true, + "Brah": true, + "Brahmi": true, + "Brai": true, + "Braille": true, + "Bugi": true, + "Buginese": true, + "Buhd": true, + "Buhid": true, + "Cakm": true, + "Chakma": true, + "Cans": true, + "Canadian_Aboriginal": true, + "Cari": true, + "Carian": true, + "Cham": true, + "Cher": true, + "Cherokee": true, + "Chrs": true, + "Chorasmian": true, + "Copt": true, + "Coptic": true, + "Qaac": true, + "Cpmn": true, + "Cypro_Minoan": true, + "Cprt": true, + "Cypriot": true, + "Cyrl": true, + "Cyrillic": true, + "Deva": true, + "Devanagari": true, + "Diak": true, + "Dives_Akuru": true, + "Dogr": true, + "Dogra": true, + "Dsrt": true, + "Deseret": true, + "Dupl": true, + "Duployan": true, + "Egyp": true, + "Egyptian_Hieroglyphs": true, + "Elba": true, + "Elbasan": true, + "Elym": true, + "Elymaic": true, + "Ethi": true, + "Ethiopic": true, + "Geor": true, + "Georgian": true, + "Glag": true, + "Glagolitic": true, + "Gong": true, + "Gunjala_Gondi": true, + "Gonm": true, + "Masaram_Gondi": true, + "Goth": true, + "Gothic": true, + "Gran": true, + "Grantha": true, + "Grek": true, + "Greek": true, + "Gujr": true, + "Gujarati": true, + "Guru": true, + "Gurmukhi": true, + "Hang": true, + "Hangul": true, + "Hani": true, + "Han": true, + "Hano": true, + "Hanunoo": true, + "Hatr": true, + "Hatran": true, + "Hebr": true, + "Hebrew": true, + "Hira": true, + "Hiragana": true, + "Hluw": true, + "Anatolian_Hieroglyphs": true, + "Hmng": true, + "Pahawh_Hmong": true, + "Hmnp": true, + "Nyiakeng_Puachue_Hmong": true, + "Hrkt": true, + "Katakana_Or_Hiragana": true, + "Hung": true, + "Old_Hungarian": true, + "Ital": true, + "Old_Italic": true, + "Java": true, + "Javanese": true, + "Kali": true, + "Kayah_Li": true, + "Kana": true, + "Katakana": true, + "Kawi": true, + "Khar": true, + "Kharoshthi": true, + "Khmr": true, + "Khmer": true, + "Khoj": true, + "Khojki": true, + "Kits": true, + "Khitan_Small_Script": true, + "Knda": true, + "Kannada": true, + "Kthi": true, + "Kaithi": true, + "Lana": true, + "Tai_Tham": true, + "Laoo": true, + "Lao": true, + "Latn": true, + "Latin": true, + "Lepc": true, + "Lepcha": true, + "Limb": true, + "Limbu": true, + "Lina": true, + "Linear_A": true, + "Linb": true, + "Linear_B": true, + "Lisu": true, + "Lyci": true, + "Lycian": true, + "Lydi": true, + "Lydian": true, + "Mahj": true, + "Mahajani": true, + "Maka": true, + "Makasar": true, + "Mand": true, + "Mandaic": true, + "Mani": true, + "Manichaean": true, + "Marc": true, + "Marchen": true, + "Medf": true, + "Medefaidrin": true, + "Mend": true, + "Mende_Kikakui": true, + "Merc": true, + "Meroitic_Cursive": true, + "Mero": true, + "Meroitic_Hieroglyphs": true, + "Mlym": true, + "Malayalam": true, + "Modi": true, + "Mong": true, + "Mongolian": true, + "Mroo": true, + "Mro": true, + "Mtei": true, + "Meetei_Mayek": true, + "Mult": true, + "Multani": true, + "Mymr": true, + "Myanmar": true, + "Nagm": true, + "Nag_Mundari": true, + "Nand": true, + "Nandinagari": true, + "Narb": true, + "Old_North_Arabian": true, + "Nbat": true, + "Nabataean": true, + "Newa": true, + "Nkoo": true, + "Nko": true, + "Nshu": true, + "Nushu": true, + "Ogam": true, + "Ogham": true, + "Olck": true, + "Ol_Chiki": true, + "Orkh": true, + "Old_Turkic": true, + "Orya": true, + "Oriya": true, + "Osge": true, + "Osage": true, + "Osma": true, + "Osmanya": true, + "Ougr": true, + "Old_Uyghur": true, + "Palm": true, + "Palmyrene": true, + "Pauc": true, + "Pau_Cin_Hau": true, + "Perm": true, + "Old_Permic": true, + "Phag": true, + "Phags_Pa": true, + "Phli": true, + "Inscriptional_Pahlavi": true, + "Phlp": true, + "Psalter_Pahlavi": true, + "Phnx": true, + "Phoenician": true, + "Plrd": true, + "Miao": true, + "Prti": true, + "Inscriptional_Parthian": true, + "Rjng": true, + "Rejang": true, + "Rohg": true, + "Hanifi_Rohingya": true, + "Runr": true, + "Runic": true, + "Samr": true, + "Samaritan": true, + "Sarb": true, + "Old_South_Arabian": true, + "Saur": true, + "Saurashtra": true, + "Sgnw": true, + "SignWriting": true, + "Shaw": true, + "Shavian": true, + "Shrd": true, + "Sharada": true, + "Sidd": true, + "Siddham": true, + "Sind": true, + "Khudawadi": true, + "Sinh": true, + "Sinhala": true, + "Sogd": true, + "Sogdian": true, + "Sogo": true, + "Old_Sogdian": true, + "Sora": true, + "Sora_Sompeng": true, + "Soyo": true, + "Soyombo": true, + "Sund": true, + "Sundanese": true, + "Sylo": true, + "Syloti_Nagri": true, + "Syrc": true, + "Syriac": true, + "Tagb": true, + "Tagbanwa": true, + "Takr": true, + "Takri": true, + "Tale": true, + "Tai_Le": true, + "Talu": true, + "New_Tai_Lue": true, + "Taml": true, + "Tamil": true, + "Tang": true, + "Tangut": true, + "Tavt": true, + "Tai_Viet": true, + "Telu": true, + "Telugu": true, + "Tfng": true, + "Tifinagh": true, + "Tglg": true, + "Tagalog": true, + "Thaa": true, + "Thaana": true, + "Thai": true, + "Tibt": true, + "Tibetan": true, + "Tirh": true, + "Tirhuta": true, + "Tnsa": true, + "Tangsa": true, + "Toto": true, + "Ugar": true, + "Ugaritic": true, + "Vaii": true, + "Vai": true, + "Vith": true, + "Vithkuqi": true, + "Wara": true, + "Warang_Citi": true, + "Wcho": true, + "Wancho": true, + "Xpeo": true, + "Old_Persian": true, + "Xsux": true, + "Cuneiform": true, + "Yezi": true, + "Yezidi": true, + "Yiii": true, + "Yi": true, + "Zanb": true, + "Zanabazar_Square": true, + "Zinh": true, + "Inherited": true, + "Qaai": true, + "Zyyy": true, + "Common": true, + "Zzzz": true, + "Unknown": true, +} + +// Map of non-binary property names to their canonical names +var nonBinaryUnicodePropertyNames = map[string]string{ + "General_Category": "General_Category", + "gc": "General_Category", + "Script": "Script", + "sc": "Script", + "Script_Extensions": "Script_Extensions", + "scx": "Script_Extensions", +} + +func isValidUnicodePropertyName(name string) bool { + return generalCategoryValues[name] || binaryUnicodeProperties[name] +} + +func isValidNonBinaryUnicodePropertyName(name string) bool { + _, ok := nonBinaryUnicodePropertyNames[name] + return ok +} + +func isValidUnicodeProperty(name, value string) bool { + canonicalName := nonBinaryUnicodePropertyNames[name] + if canonicalName == "General_Category" { + return generalCategoryValues[value] + } + if canonicalName == "Script" || canonicalName == "Script_Extensions" { + return scriptValues[value] + } + return false +} From 1ab893af948fa496057c1bb822b30f3f5fff2bbe Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Wed, 5 Nov 2025 12:20:27 -0800 Subject: [PATCH 24/33] use a set --- internal/collections/set.go | 11 +- internal/regexpchecker/regexpchecker.go | 28 +- internal/regexpchecker/tables.go | 1042 ++++++++++++----------- 3 files changed, 540 insertions(+), 541 deletions(-) diff --git a/internal/collections/set.go b/internal/collections/set.go index 6dfd3c90d6..bc284cbc90 100644 --- a/internal/collections/set.go +++ b/internal/collections/set.go @@ -1,6 +1,9 @@ package collections -import "maps" +import ( + "maps" + "slices" +) type Set[T comparable] struct { M map[T]struct{} @@ -37,6 +40,10 @@ func (s *Set[T]) Keys() map[T]struct{} { return s.M } +func (s *Set[T]) KeysSlice() []T { + return slices.AppendSeq(make([]T, 0, len(s.M)), maps.Keys(s.M)) +} + func (s *Set[T]) Clear() { clear(s.M) } @@ -69,7 +76,7 @@ func (s *Set[T]) Equals(other *Set[T]) bool { } func NewSetFromItems[T comparable](items ...T) *Set[T] { - s := &Set[T]{} + s := NewSetWithSizeHint[T](len(items)) for _, item := range items { s.Add(item) } diff --git a/internal/regexpchecker/regexpchecker.go b/internal/regexpchecker/regexpchecker.go index 1748624c53..34e0887752 100644 --- a/internal/regexpchecker/regexpchecker.go +++ b/internal/regexpchecker/regexpchecker.go @@ -2,6 +2,8 @@ package regexpchecker import ( "fmt" + "maps" + "slices" "strings" "unicode/utf8" @@ -534,15 +536,9 @@ func (v *regExpValidator) scanUnicodePropertyValueExpression(isCharacterCompleme canonicalName := nonBinaryUnicodePropertyNames[propertyNameOrValue] var candidates []string if canonicalName == "General_Category" { - candidates = make([]string, 0, len(generalCategoryValues)) - for key := range generalCategoryValues { - candidates = append(candidates, key) - } + candidates = generalCategoryValues.KeysSlice() } else if canonicalName == "Script" || canonicalName == "Script_Extensions" { - candidates = make([]string, 0, len(scriptValues)) - for key := range scriptValues { - candidates = append(candidates, key) - } + candidates = scriptValues.KeysSlice() } if len(candidates) > 0 { suggestion := core.GetSpellingSuggestion(propertyValue, candidates, core.Identity[string]) @@ -555,7 +551,7 @@ func (v *regExpValidator) scanUnicodePropertyValueExpression(isCharacterCompleme // property name alone if v.pos == propertyNameOrValueStart { v.error(diagnostics.Expected_a_Unicode_property_name_or_value, propertyNameOrValueStart, 0) - } else if binaryUnicodePropertiesOfStrings[propertyNameOrValue] { + } else if binaryUnicodePropertiesOfStrings.Has(propertyNameOrValue) { // Properties that match more than one character (strings) if !v.unicodeSetsMode { v.error(diagnostics.Any_Unicode_property_that_would_possibly_match_more_than_a_single_character_is_only_available_when_the_Unicode_Sets_v_flag_is_set, propertyNameOrValueStart, v.pos-propertyNameOrValueStart) @@ -567,16 +563,10 @@ func (v *regExpValidator) scanUnicodePropertyValueExpression(isCharacterCompleme } else if !isValidUnicodePropertyName(propertyNameOrValue) { v.error(diagnostics.Unknown_Unicode_property_name_or_value, propertyNameOrValueStart, v.pos-propertyNameOrValueStart) // Provide spelling suggestion from general category values, binary properties, and binary properties of strings - candidates := make([]string, 0, len(generalCategoryValues)+len(binaryUnicodeProperties)+len(binaryUnicodePropertiesOfStrings)) - for key := range generalCategoryValues { - candidates = append(candidates, key) - } - for key := range binaryUnicodeProperties { - candidates = append(candidates, key) - } - for key := range binaryUnicodePropertiesOfStrings { - candidates = append(candidates, key) - } + candidates := make([]string, 0, generalCategoryValues.Len()+binaryUnicodeProperties.Len()+binaryUnicodePropertiesOfStrings.Len()) + candidates = slices.AppendSeq(candidates, maps.Keys(generalCategoryValues.M)) + candidates = slices.AppendSeq(candidates, maps.Keys(binaryUnicodeProperties.M)) + candidates = slices.AppendSeq(candidates, maps.Keys(binaryUnicodePropertiesOfStrings.M)) suggestion := core.GetSpellingSuggestion(propertyNameOrValue, candidates, core.Identity) if suggestion != "" { v.error(diagnostics.Did_you_mean_0, propertyNameOrValueStart, v.pos-propertyNameOrValueStart, suggestion) diff --git a/internal/regexpchecker/tables.go b/internal/regexpchecker/tables.go index dfddb90ab1..ddf554b31e 100644 --- a/internal/regexpchecker/tables.go +++ b/internal/regexpchecker/tables.go @@ -1,531 +1,533 @@ package regexpchecker +import "github.com/microsoft/typescript-go/internal/collections" + // Table 67: Binary Unicode property aliases and their canonical property names // https://tc39.es/ecma262/#table-binary-unicode-properties -var binaryUnicodeProperties = map[string]bool{ - "ASCII": true, - "ASCII_Hex_Digit": true, - "AHex": true, - "Alphabetic": true, - "Alpha": true, - "Any": true, - "Assigned": true, - "Bidi_Control": true, - "Bidi_C": true, - "Bidi_Mirrored": true, - "Bidi_M": true, - "Case_Ignorable": true, - "CI": true, - "Cased": true, - "Changes_When_Casefolded": true, - "CWCF": true, - "Changes_When_Casemapped": true, - "CWCM": true, - "Changes_When_Lowercased": true, - "CWL": true, - "Changes_When_NFKC_Casefolded": true, - "CWKCF": true, - "Changes_When_Titlecased": true, - "CWT": true, - "Changes_When_Uppercased": true, - "CWU": true, - "Dash": true, - "Default_Ignorable_Code_Point": true, - "DI": true, - "Deprecated": true, - "Dep": true, - "Diacritic": true, - "Dia": true, - "Emoji": true, - "Emoji_Component": true, - "EComp": true, - "Emoji_Modifier": true, - "EMod": true, - "Emoji_Modifier_Base": true, - "EBase": true, - "Emoji_Presentation": true, - "EPres": true, - "Extended_Pictographic": true, - "ExtPict": true, - "Extender": true, - "Ext": true, - "Grapheme_Base": true, - "Gr_Base": true, - "Grapheme_Extend": true, - "Gr_Ext": true, - "Hex_Digit": true, - "Hex": true, - "IDS_Binary_Operator": true, - "IDSB": true, - "IDS_Trinary_Operator": true, - "IDST": true, - "ID_Continue": true, - "IDC": true, - "ID_Start": true, - "IDS": true, - "Ideographic": true, - "Ideo": true, - "Join_Control": true, - "Join_C": true, - "Logical_Order_Exception": true, - "LOE": true, - "Lowercase": true, - "Lower": true, - "Math": true, - "Noncharacter_Code_Point": true, - "NChar": true, - "Pattern_Syntax": true, - "Pat_Syn": true, - "Pattern_White_Space": true, - "Pat_WS": true, - "Quotation_Mark": true, - "QMark": true, - "Radical": true, - "Regional_Indicator": true, - "RI": true, - "Sentence_Terminal": true, - "STerm": true, - "Soft_Dotted": true, - "SD": true, - "Terminal_Punctuation": true, - "Term": true, - "Unified_Ideograph": true, - "UIdeo": true, - "Uppercase": true, - "Upper": true, - "Variation_Selector": true, - "VS": true, - "White_Space": true, - "space": true, - "XID_Continue": true, - "XIDC": true, - "XID_Start": true, - "XIDS": true, -} +var binaryUnicodeProperties = collections.NewSetFromItems( + "ASCII", + "ASCII_Hex_Digit", + "AHex", + "Alphabetic", + "Alpha", + "Any", + "Assigned", + "Bidi_Control", + "Bidi_C", + "Bidi_Mirrored", + "Bidi_M", + "Case_Ignorable", + "CI", + "Cased", + "Changes_When_Casefolded", + "CWCF", + "Changes_When_Casemapped", + "CWCM", + "Changes_When_Lowercased", + "CWL", + "Changes_When_NFKC_Casefolded", + "CWKCF", + "Changes_When_Titlecased", + "CWT", + "Changes_When_Uppercased", + "CWU", + "Dash", + "Default_Ignorable_Code_Point", + "DI", + "Deprecated", + "Dep", + "Diacritic", + "Dia", + "Emoji", + "Emoji_Component", + "EComp", + "Emoji_Modifier", + "EMod", + "Emoji_Modifier_Base", + "EBase", + "Emoji_Presentation", + "EPres", + "Extended_Pictographic", + "ExtPict", + "Extender", + "Ext", + "Grapheme_Base", + "Gr_Base", + "Grapheme_Extend", + "Gr_Ext", + "Hex_Digit", + "Hex", + "IDS_Binary_Operator", + "IDSB", + "IDS_Trinary_Operator", + "IDST", + "ID_Continue", + "IDC", + "ID_Start", + "IDS", + "Ideographic", + "Ideo", + "Join_Control", + "Join_C", + "Logical_Order_Exception", + "LOE", + "Lowercase", + "Lower", + "Math", + "Noncharacter_Code_Point", + "NChar", + "Pattern_Syntax", + "Pat_Syn", + "Pattern_White_Space", + "Pat_WS", + "Quotation_Mark", + "QMark", + "Radical", + "Regional_Indicator", + "RI", + "Sentence_Terminal", + "STerm", + "Soft_Dotted", + "SD", + "Terminal_Punctuation", + "Term", + "Unified_Ideograph", + "UIdeo", + "Uppercase", + "Upper", + "Variation_Selector", + "VS", + "White_Space", + "space", + "XID_Continue", + "XIDC", + "XID_Start", + "XIDS", +) // Table 68: Binary Unicode properties of strings // https://tc39.es/ecma262/#table-binary-unicode-properties-of-strings -var binaryUnicodePropertiesOfStrings = map[string]bool{ - "Basic_Emoji": true, - "Emoji_Keycap_Sequence": true, - "RGI_Emoji_Modifier_Sequence": true, - "RGI_Emoji_Flag_Sequence": true, - "RGI_Emoji_Tag_Sequence": true, - "RGI_Emoji_ZWJ_Sequence": true, - "RGI_Emoji": true, -} +var binaryUnicodePropertiesOfStrings = collections.NewSetFromItems( + "Basic_Emoji", + "Emoji_Keycap_Sequence", + "RGI_Emoji_Modifier_Sequence", + "RGI_Emoji_Flag_Sequence", + "RGI_Emoji_Tag_Sequence", + "RGI_Emoji_ZWJ_Sequence", + "RGI_Emoji", +) // Unicode 15.1 - General_Category values -var generalCategoryValues = map[string]bool{ - "C": true, - "Other": true, - "Cc": true, - "Control": true, - "cntrl": true, - "Cf": true, - "Format": true, - "Cn": true, - "Unassigned": true, - "Co": true, - "Private_Use": true, - "Cs": true, - "Surrogate": true, - "L": true, - "Letter": true, - "LC": true, - "Cased_Letter": true, - "Ll": true, - "Lowercase_Letter": true, - "Lm": true, - "Modifier_Letter": true, - "Lo": true, - "Other_Letter": true, - "Lt": true, - "Titlecase_Letter": true, - "Lu": true, - "Uppercase_Letter": true, - "M": true, - "Mark": true, - "Combining_Mark": true, - "Mc": true, - "Spacing_Mark": true, - "Me": true, - "Enclosing_Mark": true, - "Mn": true, - "Nonspacing_Mark": true, - "N": true, - "Number": true, - "Nd": true, - "Decimal_Number": true, - "digit": true, - "Nl": true, - "Letter_Number": true, - "No": true, - "Other_Number": true, - "P": true, - "Punctuation": true, - "punct": true, - "Pc": true, - "Connector_Punctuation": true, - "Pd": true, - "Dash_Punctuation": true, - "Pe": true, - "Close_Punctuation": true, - "Pf": true, - "Final_Punctuation": true, - "Pi": true, - "Initial_Punctuation": true, - "Po": true, - "Other_Punctuation": true, - "Ps": true, - "Open_Punctuation": true, - "S": true, - "Symbol": true, - "Sc": true, - "Currency_Symbol": true, - "Sk": true, - "Modifier_Symbol": true, - "Sm": true, - "Math_Symbol": true, - "So": true, - "Other_Symbol": true, - "Z": true, - "Separator": true, - "Zl": true, - "Line_Separator": true, - "Zp": true, - "Paragraph_Separator": true, - "Zs": true, - "Space_Separator": true, -} +var generalCategoryValues = collections.NewSetFromItems( + "C", + "Other", + "Cc", + "Control", + "cntrl", + "Cf", + "Format", + "Cn", + "Unassigned", + "Co", + "Private_Use", + "Cs", + "Surrogate", + "L", + "Letter", + "LC", + "Cased_Letter", + "Ll", + "Lowercase_Letter", + "Lm", + "Modifier_Letter", + "Lo", + "Other_Letter", + "Lt", + "Titlecase_Letter", + "Lu", + "Uppercase_Letter", + "M", + "Mark", + "Combining_Mark", + "Mc", + "Spacing_Mark", + "Me", + "Enclosing_Mark", + "Mn", + "Nonspacing_Mark", + "N", + "Number", + "Nd", + "Decimal_Number", + "digit", + "Nl", + "Letter_Number", + "No", + "Other_Number", + "P", + "Punctuation", + "punct", + "Pc", + "Connector_Punctuation", + "Pd", + "Dash_Punctuation", + "Pe", + "Close_Punctuation", + "Pf", + "Final_Punctuation", + "Pi", + "Initial_Punctuation", + "Po", + "Other_Punctuation", + "Ps", + "Open_Punctuation", + "S", + "Symbol", + "Sc", + "Currency_Symbol", + "Sk", + "Modifier_Symbol", + "Sm", + "Math_Symbol", + "So", + "Other_Symbol", + "Z", + "Separator", + "Zl", + "Line_Separator", + "Zp", + "Paragraph_Separator", + "Zs", + "Space_Separator", +) // Unicode 15.1 - Script values -var scriptValues = map[string]bool{ - "Adlm": true, - "Adlam": true, - "Aghb": true, - "Caucasian_Albanian": true, - "Ahom": true, - "Arab": true, - "Arabic": true, - "Armi": true, - "Imperial_Aramaic": true, - "Armn": true, - "Armenian": true, - "Avst": true, - "Avestan": true, - "Bali": true, - "Balinese": true, - "Bamu": true, - "Bamum": true, - "Bass": true, - "Bassa_Vah": true, - "Batk": true, - "Batak": true, - "Beng": true, - "Bengali": true, - "Bhks": true, - "Bhaiksuki": true, - "Bopo": true, - "Bopomofo": true, - "Brah": true, - "Brahmi": true, - "Brai": true, - "Braille": true, - "Bugi": true, - "Buginese": true, - "Buhd": true, - "Buhid": true, - "Cakm": true, - "Chakma": true, - "Cans": true, - "Canadian_Aboriginal": true, - "Cari": true, - "Carian": true, - "Cham": true, - "Cher": true, - "Cherokee": true, - "Chrs": true, - "Chorasmian": true, - "Copt": true, - "Coptic": true, - "Qaac": true, - "Cpmn": true, - "Cypro_Minoan": true, - "Cprt": true, - "Cypriot": true, - "Cyrl": true, - "Cyrillic": true, - "Deva": true, - "Devanagari": true, - "Diak": true, - "Dives_Akuru": true, - "Dogr": true, - "Dogra": true, - "Dsrt": true, - "Deseret": true, - "Dupl": true, - "Duployan": true, - "Egyp": true, - "Egyptian_Hieroglyphs": true, - "Elba": true, - "Elbasan": true, - "Elym": true, - "Elymaic": true, - "Ethi": true, - "Ethiopic": true, - "Geor": true, - "Georgian": true, - "Glag": true, - "Glagolitic": true, - "Gong": true, - "Gunjala_Gondi": true, - "Gonm": true, - "Masaram_Gondi": true, - "Goth": true, - "Gothic": true, - "Gran": true, - "Grantha": true, - "Grek": true, - "Greek": true, - "Gujr": true, - "Gujarati": true, - "Guru": true, - "Gurmukhi": true, - "Hang": true, - "Hangul": true, - "Hani": true, - "Han": true, - "Hano": true, - "Hanunoo": true, - "Hatr": true, - "Hatran": true, - "Hebr": true, - "Hebrew": true, - "Hira": true, - "Hiragana": true, - "Hluw": true, - "Anatolian_Hieroglyphs": true, - "Hmng": true, - "Pahawh_Hmong": true, - "Hmnp": true, - "Nyiakeng_Puachue_Hmong": true, - "Hrkt": true, - "Katakana_Or_Hiragana": true, - "Hung": true, - "Old_Hungarian": true, - "Ital": true, - "Old_Italic": true, - "Java": true, - "Javanese": true, - "Kali": true, - "Kayah_Li": true, - "Kana": true, - "Katakana": true, - "Kawi": true, - "Khar": true, - "Kharoshthi": true, - "Khmr": true, - "Khmer": true, - "Khoj": true, - "Khojki": true, - "Kits": true, - "Khitan_Small_Script": true, - "Knda": true, - "Kannada": true, - "Kthi": true, - "Kaithi": true, - "Lana": true, - "Tai_Tham": true, - "Laoo": true, - "Lao": true, - "Latn": true, - "Latin": true, - "Lepc": true, - "Lepcha": true, - "Limb": true, - "Limbu": true, - "Lina": true, - "Linear_A": true, - "Linb": true, - "Linear_B": true, - "Lisu": true, - "Lyci": true, - "Lycian": true, - "Lydi": true, - "Lydian": true, - "Mahj": true, - "Mahajani": true, - "Maka": true, - "Makasar": true, - "Mand": true, - "Mandaic": true, - "Mani": true, - "Manichaean": true, - "Marc": true, - "Marchen": true, - "Medf": true, - "Medefaidrin": true, - "Mend": true, - "Mende_Kikakui": true, - "Merc": true, - "Meroitic_Cursive": true, - "Mero": true, - "Meroitic_Hieroglyphs": true, - "Mlym": true, - "Malayalam": true, - "Modi": true, - "Mong": true, - "Mongolian": true, - "Mroo": true, - "Mro": true, - "Mtei": true, - "Meetei_Mayek": true, - "Mult": true, - "Multani": true, - "Mymr": true, - "Myanmar": true, - "Nagm": true, - "Nag_Mundari": true, - "Nand": true, - "Nandinagari": true, - "Narb": true, - "Old_North_Arabian": true, - "Nbat": true, - "Nabataean": true, - "Newa": true, - "Nkoo": true, - "Nko": true, - "Nshu": true, - "Nushu": true, - "Ogam": true, - "Ogham": true, - "Olck": true, - "Ol_Chiki": true, - "Orkh": true, - "Old_Turkic": true, - "Orya": true, - "Oriya": true, - "Osge": true, - "Osage": true, - "Osma": true, - "Osmanya": true, - "Ougr": true, - "Old_Uyghur": true, - "Palm": true, - "Palmyrene": true, - "Pauc": true, - "Pau_Cin_Hau": true, - "Perm": true, - "Old_Permic": true, - "Phag": true, - "Phags_Pa": true, - "Phli": true, - "Inscriptional_Pahlavi": true, - "Phlp": true, - "Psalter_Pahlavi": true, - "Phnx": true, - "Phoenician": true, - "Plrd": true, - "Miao": true, - "Prti": true, - "Inscriptional_Parthian": true, - "Rjng": true, - "Rejang": true, - "Rohg": true, - "Hanifi_Rohingya": true, - "Runr": true, - "Runic": true, - "Samr": true, - "Samaritan": true, - "Sarb": true, - "Old_South_Arabian": true, - "Saur": true, - "Saurashtra": true, - "Sgnw": true, - "SignWriting": true, - "Shaw": true, - "Shavian": true, - "Shrd": true, - "Sharada": true, - "Sidd": true, - "Siddham": true, - "Sind": true, - "Khudawadi": true, - "Sinh": true, - "Sinhala": true, - "Sogd": true, - "Sogdian": true, - "Sogo": true, - "Old_Sogdian": true, - "Sora": true, - "Sora_Sompeng": true, - "Soyo": true, - "Soyombo": true, - "Sund": true, - "Sundanese": true, - "Sylo": true, - "Syloti_Nagri": true, - "Syrc": true, - "Syriac": true, - "Tagb": true, - "Tagbanwa": true, - "Takr": true, - "Takri": true, - "Tale": true, - "Tai_Le": true, - "Talu": true, - "New_Tai_Lue": true, - "Taml": true, - "Tamil": true, - "Tang": true, - "Tangut": true, - "Tavt": true, - "Tai_Viet": true, - "Telu": true, - "Telugu": true, - "Tfng": true, - "Tifinagh": true, - "Tglg": true, - "Tagalog": true, - "Thaa": true, - "Thaana": true, - "Thai": true, - "Tibt": true, - "Tibetan": true, - "Tirh": true, - "Tirhuta": true, - "Tnsa": true, - "Tangsa": true, - "Toto": true, - "Ugar": true, - "Ugaritic": true, - "Vaii": true, - "Vai": true, - "Vith": true, - "Vithkuqi": true, - "Wara": true, - "Warang_Citi": true, - "Wcho": true, - "Wancho": true, - "Xpeo": true, - "Old_Persian": true, - "Xsux": true, - "Cuneiform": true, - "Yezi": true, - "Yezidi": true, - "Yiii": true, - "Yi": true, - "Zanb": true, - "Zanabazar_Square": true, - "Zinh": true, - "Inherited": true, - "Qaai": true, - "Zyyy": true, - "Common": true, - "Zzzz": true, - "Unknown": true, -} +var scriptValues = collections.NewSetFromItems( + "Adlm", + "Adlam", + "Aghb", + "Caucasian_Albanian", + "Ahom", + "Arab", + "Arabic", + "Armi", + "Imperial_Aramaic", + "Armn", + "Armenian", + "Avst", + "Avestan", + "Bali", + "Balinese", + "Bamu", + "Bamum", + "Bass", + "Bassa_Vah", + "Batk", + "Batak", + "Beng", + "Bengali", + "Bhks", + "Bhaiksuki", + "Bopo", + "Bopomofo", + "Brah", + "Brahmi", + "Brai", + "Braille", + "Bugi", + "Buginese", + "Buhd", + "Buhid", + "Cakm", + "Chakma", + "Cans", + "Canadian_Aboriginal", + "Cari", + "Carian", + "Cham", + "Cher", + "Cherokee", + "Chrs", + "Chorasmian", + "Copt", + "Coptic", + "Qaac", + "Cpmn", + "Cypro_Minoan", + "Cprt", + "Cypriot", + "Cyrl", + "Cyrillic", + "Deva", + "Devanagari", + "Diak", + "Dives_Akuru", + "Dogr", + "Dogra", + "Dsrt", + "Deseret", + "Dupl", + "Duployan", + "Egyp", + "Egyptian_Hieroglyphs", + "Elba", + "Elbasan", + "Elym", + "Elymaic", + "Ethi", + "Ethiopic", + "Geor", + "Georgian", + "Glag", + "Glagolitic", + "Gong", + "Gunjala_Gondi", + "Gonm", + "Masaram_Gondi", + "Goth", + "Gothic", + "Gran", + "Grantha", + "Grek", + "Greek", + "Gujr", + "Gujarati", + "Guru", + "Gurmukhi", + "Hang", + "Hangul", + "Hani", + "Han", + "Hano", + "Hanunoo", + "Hatr", + "Hatran", + "Hebr", + "Hebrew", + "Hira", + "Hiragana", + "Hluw", + "Anatolian_Hieroglyphs", + "Hmng", + "Pahawh_Hmong", + "Hmnp", + "Nyiakeng_Puachue_Hmong", + "Hrkt", + "Katakana_Or_Hiragana", + "Hung", + "Old_Hungarian", + "Ital", + "Old_Italic", + "Java", + "Javanese", + "Kali", + "Kayah_Li", + "Kana", + "Katakana", + "Kawi", + "Khar", + "Kharoshthi", + "Khmr", + "Khmer", + "Khoj", + "Khojki", + "Kits", + "Khitan_Small_Script", + "Knda", + "Kannada", + "Kthi", + "Kaithi", + "Lana", + "Tai_Tham", + "Laoo", + "Lao", + "Latn", + "Latin", + "Lepc", + "Lepcha", + "Limb", + "Limbu", + "Lina", + "Linear_A", + "Linb", + "Linear_B", + "Lisu", + "Lyci", + "Lycian", + "Lydi", + "Lydian", + "Mahj", + "Mahajani", + "Maka", + "Makasar", + "Mand", + "Mandaic", + "Mani", + "Manichaean", + "Marc", + "Marchen", + "Medf", + "Medefaidrin", + "Mend", + "Mende_Kikakui", + "Merc", + "Meroitic_Cursive", + "Mero", + "Meroitic_Hieroglyphs", + "Mlym", + "Malayalam", + "Modi", + "Mong", + "Mongolian", + "Mroo", + "Mro", + "Mtei", + "Meetei_Mayek", + "Mult", + "Multani", + "Mymr", + "Myanmar", + "Nagm", + "Nag_Mundari", + "Nand", + "Nandinagari", + "Narb", + "Old_North_Arabian", + "Nbat", + "Nabataean", + "Newa", + "Nkoo", + "Nko", + "Nshu", + "Nushu", + "Ogam", + "Ogham", + "Olck", + "Ol_Chiki", + "Orkh", + "Old_Turkic", + "Orya", + "Oriya", + "Osge", + "Osage", + "Osma", + "Osmanya", + "Ougr", + "Old_Uyghur", + "Palm", + "Palmyrene", + "Pauc", + "Pau_Cin_Hau", + "Perm", + "Old_Permic", + "Phag", + "Phags_Pa", + "Phli", + "Inscriptional_Pahlavi", + "Phlp", + "Psalter_Pahlavi", + "Phnx", + "Phoenician", + "Plrd", + "Miao", + "Prti", + "Inscriptional_Parthian", + "Rjng", + "Rejang", + "Rohg", + "Hanifi_Rohingya", + "Runr", + "Runic", + "Samr", + "Samaritan", + "Sarb", + "Old_South_Arabian", + "Saur", + "Saurashtra", + "Sgnw", + "SignWriting", + "Shaw", + "Shavian", + "Shrd", + "Sharada", + "Sidd", + "Siddham", + "Sind", + "Khudawadi", + "Sinh", + "Sinhala", + "Sogd", + "Sogdian", + "Sogo", + "Old_Sogdian", + "Sora", + "Sora_Sompeng", + "Soyo", + "Soyombo", + "Sund", + "Sundanese", + "Sylo", + "Syloti_Nagri", + "Syrc", + "Syriac", + "Tagb", + "Tagbanwa", + "Takr", + "Takri", + "Tale", + "Tai_Le", + "Talu", + "New_Tai_Lue", + "Taml", + "Tamil", + "Tang", + "Tangut", + "Tavt", + "Tai_Viet", + "Telu", + "Telugu", + "Tfng", + "Tifinagh", + "Tglg", + "Tagalog", + "Thaa", + "Thaana", + "Thai", + "Tibt", + "Tibetan", + "Tirh", + "Tirhuta", + "Tnsa", + "Tangsa", + "Toto", + "Ugar", + "Ugaritic", + "Vaii", + "Vai", + "Vith", + "Vithkuqi", + "Wara", + "Warang_Citi", + "Wcho", + "Wancho", + "Xpeo", + "Old_Persian", + "Xsux", + "Cuneiform", + "Yezi", + "Yezidi", + "Yiii", + "Yi", + "Zanb", + "Zanabazar_Square", + "Zinh", + "Inherited", + "Qaai", + "Zyyy", + "Common", + "Zzzz", + "Unknown", +) // Map of non-binary property names to their canonical names var nonBinaryUnicodePropertyNames = map[string]string{ @@ -538,7 +540,7 @@ var nonBinaryUnicodePropertyNames = map[string]string{ } func isValidUnicodePropertyName(name string) bool { - return generalCategoryValues[name] || binaryUnicodeProperties[name] + return generalCategoryValues.Has(name) || binaryUnicodeProperties.Has(name) } func isValidNonBinaryUnicodePropertyName(name string) bool { @@ -549,10 +551,10 @@ func isValidNonBinaryUnicodePropertyName(name string) bool { func isValidUnicodeProperty(name, value string) bool { canonicalName := nonBinaryUnicodePropertyNames[name] if canonicalName == "General_Category" { - return generalCategoryValues[value] + return generalCategoryValues.Has(value) } if canonicalName == "Script" || canonicalName == "Script_Extensions" { - return scriptValues[value] + return scriptValues.Has(value) } return false } From fd90e1b522b552cf9ed04ee61f75d8df95389cd8 Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Wed, 5 Nov 2025 12:32:05 -0800 Subject: [PATCH 25/33] Small simplifications --- internal/regexpchecker/regexpchecker.go | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) diff --git a/internal/regexpchecker/regexpchecker.go b/internal/regexpchecker/regexpchecker.go index 34e0887752..4dbf16de35 100644 --- a/internal/regexpchecker/regexpchecker.go +++ b/internal/regexpchecker/regexpchecker.go @@ -837,17 +837,7 @@ func codePointAt(s string) rune { return rune((uint16(s[0]) << 8) | uint16(s[1])) } } - first, size := utf8.DecodeRuneInString(s) - // Check if it's a high surrogate (0xD800-0xDBFF) - if first >= 0xD800 && first <= 0xDBFF && len(s) > size { - second, _ := utf8.DecodeRuneInString(s[size:]) - // Check if it's a low surrogate (0xDC00-0xDFFF) - if second >= 0xDC00 && second <= 0xDFFF { - // Combine surrogates to get the code point - // CodePoint = 0x10000 + ((high & 0x3FF) << 10) | (low & 0x3FF) - return 0x10000 + ((first & 0x3FF) << 10) | (second & 0x3FF) - } - } + first, _ := utf8.DecodeRuneInString(s) return first } @@ -936,11 +926,7 @@ func (v *regExpValidator) scanSourceCharacter() string { } // Decode the next UTF-8 character from the source - r, s := utf8.DecodeRuneInString(v.text[v.pos:]) - if r == utf8.RuneError { - v.pos++ - return v.text[v.pos-1 : v.pos] - } + r, s := v.charAndSize() if v.anyUnicodeMode || r < 0x10000 { // In Unicode mode, or for BMP characters, consume and return normally From 0c95bf085d718d744af2f85af9df7a1e0ab590dd Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Wed, 5 Nov 2025 12:33:42 -0800 Subject: [PATCH 26/33] Rename func --- internal/regexpchecker/regexpchecker.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/internal/regexpchecker/regexpchecker.go b/internal/regexpchecker/regexpchecker.go index 4dbf16de35..165d90f991 100644 --- a/internal/regexpchecker/regexpchecker.go +++ b/internal/regexpchecker/regexpchecker.go @@ -822,10 +822,10 @@ func parseHexValue(text string, start, end int) int { return code } -// codePointAt returns the code point value at the start of the string -// If the string starts with a high surrogate followed by a low surrogate, they are combined -// Surrogates from escape sequences are encoded as 2-byte UTF-16BE sequences -func codePointAt(s string) rune { +// decodeCodePoint returns the code point value from a character string. +// The string can be either a UTF-8 encoded character or a UTF-16BE encoded surrogate. +// Surrogates from escape sequences are encoded as 2-byte UTF-16BE sequences. +func decodeCodePoint(s string) rune { if len(s) == 0 { return 0 } @@ -991,8 +991,8 @@ func (v *regExpValidator) scanClassRanges() { } // Check range order if atom != "" && rangeEnd != "" { - minCodePoint := codePointAt(atom) - maxCodePoint := codePointAt(rangeEnd) + minCodePoint := decodeCodePoint(atom) + maxCodePoint := decodeCodePoint(rangeEnd) // Get the expected sizes (in UTF-16 code units) minExpectedSize := charSize(minCodePoint) From 3450daea8534fc8b395b2b099051bb5dbed11a97 Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Wed, 5 Nov 2025 12:47:07 -0800 Subject: [PATCH 27/33] cleanups --- internal/regexpchecker/regexpchecker.go | 79 +++++++++++++++++-------- 1 file changed, 54 insertions(+), 25 deletions(-) diff --git a/internal/regexpchecker/regexpchecker.go b/internal/regexpchecker/regexpchecker.go index 165d90f991..09915a5189 100644 --- a/internal/regexpchecker/regexpchecker.go +++ b/internal/regexpchecker/regexpchecker.go @@ -42,6 +42,45 @@ var charCodeToRegExpFlag = map[rune]regExpFlags{ 'y': regExpFlagsSticky, } +// UTF-16 surrogate pair constants +const ( + surrogateMin = 0xD800 // Start of surrogate range + surrogateMax = 0xDFFF // End of surrogate range + highSurrogateMin = 0xD800 // Start of high surrogate range + highSurrogateMax = 0xDBFF // End of high surrogate range + lowSurrogateMin = 0xDC00 // Start of low surrogate range + lowSurrogateMax = 0xDFFF // End of low surrogate range + supplementaryMin = 0x10000 // First code point requiring surrogate pair +) + +// isSurrogate returns true if the code point is in the surrogate range +func isSurrogate(r rune) bool { + return r >= surrogateMin && r <= surrogateMax +} + +// isHighSurrogate returns true if the code point is a high surrogate +func isHighSurrogate(r rune) bool { + return r >= highSurrogateMin && r <= highSurrogateMax +} + +// isLowSurrogate returns true if the code point is a low surrogate +func isLowSurrogate(r rune) bool { + return r >= lowSurrogateMin && r <= lowSurrogateMax +} + +// combineSurrogatePair combines a high and low surrogate into a code point +func combineSurrogatePair(high, low rune) rune { + return supplementaryMin + ((high - highSurrogateMin) << 10) + (low - lowSurrogateMin) +} + +// splitToSurrogatePair splits a supplementary code point into high and low surrogates +func splitToSurrogatePair(r rune) (high, low rune) { + r -= supplementaryMin + high = highSurrogateMin + ((r >> 10) & 0x3FF) + low = lowSurrogateMin + (r & 0x3FF) + return high, low +} + // regExpValidator is used to validate regular expressions type regExpValidator struct { text string @@ -756,14 +795,14 @@ func (v *regExpValidator) scanEscapeSequence(atomEscape bool) string { // For surrogates, we need to preserve the actual value since string(rune(surrogate)) // converts to 0xFFFD. We encode the surrogate as UTF-16BE bytes. var escapedValueString string - if code >= 0xD800 && code <= 0xDFFF { + if isSurrogate(rune(code)) { // Surrogate - encode as 2-byte sequence (UTF-16BE) - escapedValueString = string([]byte{byte(code >> 8), byte(code & 0xFF)}) + escapedValueString = encodeSurrogate(rune(code)) } else { escapedValueString = string(rune(code)) } // In Unicode mode, check for surrogate pairs - if v.anyUnicodeMode && code >= 0xD800 && code <= 0xDBFF && + if v.anyUnicodeMode && isHighSurrogate(rune(code)) && v.pos+6 <= v.end && v.text[v.pos:v.pos+2] == "\\u" { // High surrogate followed by potential low surrogate nextStart := v.pos @@ -780,14 +819,11 @@ func (v *regExpValidator) scanEscapeSequence(atomEscape bool) string { // Parse the next escape nextCode := parseHexValue(v.text, nextStart+2, nextPos) // Check if it's a low surrogate - if nextCode >= 0xDC00 && nextCode <= 0xDFFF { + if isLowSurrogate(rune(nextCode)) { // Combine surrogates into a single code point - // Formula: 0x10000 + ((high - 0xD800) << 10) + (low - 0xDC00) - highSurrogate := code - lowSurrogate := nextCode - combinedCodePoint := 0x10000 + ((highSurrogate - 0xD800) << 10) + (lowSurrogate - 0xDC00) + combinedCodePoint := combineSurrogatePair(rune(code), rune(nextCode)) v.pos = nextPos - return string(rune(combinedCodePoint)) + return string(combinedCodePoint) } } } @@ -831,10 +867,9 @@ func decodeCodePoint(s string) rune { } // Check if this is a UTF-16BE encoded surrogate (2 bytes, first byte in surrogate range) if len(s) == 2 { - firstByte := uint16(s[0]) - if firstByte >= 0xD8 && firstByte <= 0xDF { - // This is a surrogate encoded as UTF-16BE - return rune((uint16(s[0]) << 8) | uint16(s[1])) + code := rune((uint16(s[0]) << 8) | uint16(s[1])) + if isSurrogate(code) { + return code } } first, _ := utf8.DecodeRuneInString(s) @@ -844,7 +879,7 @@ func decodeCodePoint(s string) rune { // charSize returns the number of UTF-16 code units needed to represent a code point // This matches JavaScript's internal string representation func charSize(ch rune) int { - if ch >= 0x10000 { + if ch >= supplementaryMin { // Code points >= 0x10000 require surrogate pairs in UTF-16 (2 code units) return 2 } @@ -861,9 +896,8 @@ func utf16Length(s string) int { // Check if this is a 2-byte UTF-16BE surrogate encoding // These are used to preserve surrogate values in patterns like \uD835 if len(s) == 2 { - firstByte := uint16(s[0]) - if firstByte >= 0xD8 && firstByte <= 0xDF { - // This is a surrogate encoded as UTF-16BE + code := rune((uint16(s[0]) << 8) | uint16(s[1])) + if isSurrogate(code) { return 1 } } @@ -871,11 +905,7 @@ func utf16Length(s string) int { // Otherwise, count UTF-16 code units from UTF-8 runes length := 0 for _, r := range s { - if r >= 0x10000 { - length += 2 // Surrogate pair - } else { - length += 1 - } + length += charSize(r) } return length } @@ -928,7 +958,7 @@ func (v *regExpValidator) scanSourceCharacter() string { // Decode the next UTF-8 character from the source r, s := v.charAndSize() - if v.anyUnicodeMode || r < 0x10000 { + if v.anyUnicodeMode || r < supplementaryMin { // In Unicode mode, or for BMP characters, consume and return normally v.pos += s return v.text[v.pos-s : v.pos] @@ -937,8 +967,7 @@ func (v *regExpValidator) scanSourceCharacter() string { // In non-Unicode mode with a supplementary character (>= U+10000): // JavaScript represents these as surrogate pairs (two UTF-16 code units). // Return the high surrogate now and save the low surrogate for the next call. - high := 0xD800 + ((r-0x10000)>>10)&0x3FF - low := 0xDC00 + ((r - 0x10000) & 0x3FF) + high, low := splitToSurrogatePair(r) v.surrogateState = &surrogatePairState{ lowSurrogate: low, From fdb5b71f5d522279c5c56f7c40a9fdc9eb6d5a2e Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Wed, 5 Nov 2025 12:52:10 -0800 Subject: [PATCH 28/33] Move utf16 junk out --- internal/regexpchecker/regexpchecker.go | 97 ---------------- internal/regexpchecker/utf16.go | 142 ++++++++++++++++++++++++ 2 files changed, 142 insertions(+), 97 deletions(-) create mode 100644 internal/regexpchecker/utf16.go diff --git a/internal/regexpchecker/regexpchecker.go b/internal/regexpchecker/regexpchecker.go index 09915a5189..fcf999fca5 100644 --- a/internal/regexpchecker/regexpchecker.go +++ b/internal/regexpchecker/regexpchecker.go @@ -42,45 +42,6 @@ var charCodeToRegExpFlag = map[rune]regExpFlags{ 'y': regExpFlagsSticky, } -// UTF-16 surrogate pair constants -const ( - surrogateMin = 0xD800 // Start of surrogate range - surrogateMax = 0xDFFF // End of surrogate range - highSurrogateMin = 0xD800 // Start of high surrogate range - highSurrogateMax = 0xDBFF // End of high surrogate range - lowSurrogateMin = 0xDC00 // Start of low surrogate range - lowSurrogateMax = 0xDFFF // End of low surrogate range - supplementaryMin = 0x10000 // First code point requiring surrogate pair -) - -// isSurrogate returns true if the code point is in the surrogate range -func isSurrogate(r rune) bool { - return r >= surrogateMin && r <= surrogateMax -} - -// isHighSurrogate returns true if the code point is a high surrogate -func isHighSurrogate(r rune) bool { - return r >= highSurrogateMin && r <= highSurrogateMax -} - -// isLowSurrogate returns true if the code point is a low surrogate -func isLowSurrogate(r rune) bool { - return r >= lowSurrogateMin && r <= lowSurrogateMax -} - -// combineSurrogatePair combines a high and low surrogate into a code point -func combineSurrogatePair(high, low rune) rune { - return supplementaryMin + ((high - highSurrogateMin) << 10) + (low - lowSurrogateMin) -} - -// splitToSurrogatePair splits a supplementary code point into high and low surrogates -func splitToSurrogatePair(r rune) (high, low rune) { - r -= supplementaryMin - high = highSurrogateMin + ((r >> 10) & 0x3FF) - low = lowSurrogateMin + (r & 0x3FF) - return high, low -} - // regExpValidator is used to validate regular expressions type regExpValidator struct { text string @@ -858,58 +819,6 @@ func parseHexValue(text string, start, end int) int { return code } -// decodeCodePoint returns the code point value from a character string. -// The string can be either a UTF-8 encoded character or a UTF-16BE encoded surrogate. -// Surrogates from escape sequences are encoded as 2-byte UTF-16BE sequences. -func decodeCodePoint(s string) rune { - if len(s) == 0 { - return 0 - } - // Check if this is a UTF-16BE encoded surrogate (2 bytes, first byte in surrogate range) - if len(s) == 2 { - code := rune((uint16(s[0]) << 8) | uint16(s[1])) - if isSurrogate(code) { - return code - } - } - first, _ := utf8.DecodeRuneInString(s) - return first -} - -// charSize returns the number of UTF-16 code units needed to represent a code point -// This matches JavaScript's internal string representation -func charSize(ch rune) int { - if ch >= supplementaryMin { - // Code points >= 0x10000 require surrogate pairs in UTF-16 (2 code units) - return 2 - } - if ch == 0 { - return 0 - } - return 1 -} - -// utf16Length returns the UTF-16 length of a string, matching JavaScript's string.length -// This counts UTF-16 code units, where surrogate pairs count as 2 units -// Handles both UTF-8 encoded strings and special 2-byte UTF-16BE surrogate encodings -func utf16Length(s string) int { - // Check if this is a 2-byte UTF-16BE surrogate encoding - // These are used to preserve surrogate values in patterns like \uD835 - if len(s) == 2 { - code := rune((uint16(s[0]) << 8) | uint16(s[1])) - if isSurrogate(code) { - return 1 - } - } - - // Otherwise, count UTF-16 code units from UTF-8 runes - length := 0 - for _, r := range s { - length += charSize(r) - } - return length -} - func (v *regExpValidator) scanGroupName(isReference bool) { tokenStart := v.pos v.scanIdentifier(v.charAtOffset(0)) @@ -977,12 +886,6 @@ func (v *regExpValidator) scanSourceCharacter() string { return encodeSurrogate(high) } -// encodeSurrogate encodes a UTF-16 surrogate value as a 2-byte UTF-16BE sequence. -// This preserves the surrogate value (which would otherwise be invalid in UTF-8/UTF-32). -func encodeSurrogate(surrogate rune) string { - return string([]byte{byte(surrogate >> 8), byte(surrogate & 0xFF)}) -} - // ClassRanges ::= ClassAtom ('-' ClassAtom)? // Scans character class content like [a-z] or [^0-9]. // Follows ECMAScript regexp grammar diff --git a/internal/regexpchecker/utf16.go b/internal/regexpchecker/utf16.go new file mode 100644 index 0000000000..dc329d4abe --- /dev/null +++ b/internal/regexpchecker/utf16.go @@ -0,0 +1,142 @@ +package regexpchecker + +import "unicode/utf8" + +// utf16.go contains utilities for handling UTF-16 surrogate pairs and encoding. +// JavaScript regular expressions use UTF-16 internally, so we need to mimic this +// behavior when validating regex patterns. This includes handling surrogate pairs +// and preserving surrogate values that would otherwise be invalid in Go strings. + +// UTF-16 surrogate pair constants +const ( + surrogateMin = 0xD800 // Start of surrogate range + surrogateMax = 0xDFFF // End of surrogate range + highSurrogateMin = 0xD800 // Start of high surrogate range + highSurrogateMax = 0xDBFF // End of high surrogate range + lowSurrogateMin = 0xDC00 // Start of low surrogate range + lowSurrogateMax = 0xDFFF // End of low surrogate range + supplementaryMin = 0x10000 // First code point requiring surrogate pair +) + +// isSurrogate returns true if the code point is in the surrogate range +func isSurrogate(r rune) bool { + return r >= surrogateMin && r <= surrogateMax +} + +// isHighSurrogate returns true if the code point is a high surrogate +func isHighSurrogate(r rune) bool { + return r >= highSurrogateMin && r <= highSurrogateMax +} + +// isLowSurrogate returns true if the code point is a low surrogate +func isLowSurrogate(r rune) bool { + return r >= lowSurrogateMin && r <= lowSurrogateMax +} + +// combineSurrogatePair combines a high and low surrogate into a code point +func combineSurrogatePair(high, low rune) rune { + return supplementaryMin + ((high - highSurrogateMin) << 10) + (low - lowSurrogateMin) +} + +// splitToSurrogatePair splits a supplementary code point into high and low surrogates +func splitToSurrogatePair(r rune) (high, low rune) { + r -= supplementaryMin + high = highSurrogateMin + ((r >> 10) & 0x3FF) + low = lowSurrogateMin + (r & 0x3FF) + return high, low +} + +// encodeSurrogate encodes a UTF-16 surrogate value as a 2-byte UTF-16BE sequence. +// This preserves the surrogate value (which would otherwise be invalid in UTF-8/UTF-32). +// Go's string(rune) converts invalid surrogates to U+FFFD, so we use this encoding +// to preserve the exact surrogate value for JavaScript regex semantics. +func encodeSurrogate(surrogate rune) string { + return string([]byte{byte(surrogate >> 8), byte(surrogate & 0xFF)}) +} + +// decodeSurrogate decodes a UTF-16BE encoded surrogate from a 2-byte string. +// Returns the surrogate value and true if successful, or 0 and false otherwise. +func decodeSurrogate(s string) (rune, bool) { + if len(s) == 2 { + code := rune((uint16(s[0]) << 8) | uint16(s[1])) + if isSurrogate(code) { + return code, true + } + } + return 0, false +} + +// decodeCodePoint returns the code point value from a character string. +// The string can be either a UTF-8 encoded character or a UTF-16BE encoded surrogate. +// Surrogates from escape sequences are encoded as 2-byte UTF-16BE sequences. +func decodeCodePoint(s string) rune { + if len(s) == 0 { + return 0 + } + // Check if this is a UTF-16BE encoded surrogate + if code, ok := decodeSurrogate(s); ok { + return code + } + first, _ := utf8.DecodeRuneInString(s) + return first +} + +// charSize returns the number of UTF-16 code units needed to represent a code point. +// This matches JavaScript's internal string representation. +func charSize(ch rune) int { + if ch >= supplementaryMin { + // Code points >= 0x10000 require surrogate pairs in UTF-16 (2 code units) + return 2 + } + if ch == 0 { + return 0 + } + return 1 +} + +// utf16Length returns the UTF-16 length of a string, matching JavaScript's string.length. +// This counts UTF-16 code units, where surrogate pairs count as 2 units. +// Handles both UTF-8 encoded strings and special 2-byte UTF-16BE surrogate encodings. +func utf16Length(s string) int { + // Check if this is a UTF-16BE surrogate encoding + // These are used to preserve surrogate values in patterns like \uD835 + if _, ok := decodeSurrogate(s); ok { + return 1 + } + + // Otherwise, count UTF-16 code units from UTF-8 runes + length := 0 + for _, r := range s { + length += charSize(r) + } + return length +} + +// regExpChar represents a single "character" in a regex pattern. +// In Unicode mode, this is a single code point. +// In non-Unicode mode, this matches JavaScript's UTF-16 representation, +// where supplementary characters are represented as surrogate pairs. +type regExpChar struct { + // The code point value. For surrogates, this is the surrogate value itself (0xD800-0xDFFF). + codePoint rune + // The UTF-16 length (1 for most characters, 2 for supplementary characters in Unicode mode) + utf16Length int +} + +// makeRegExpChar creates a regExpChar from a code point +func makeRegExpChar(codePoint rune) regExpChar { + return regExpChar{ + codePoint: codePoint, + utf16Length: charSize(codePoint), + } +} + +// String returns a string representation suitable for comparison. +// For surrogates, uses UTF-16BE encoding to preserve the surrogate value. +// For normal code points, uses standard Go string encoding. +func (c regExpChar) String() string { + if isSurrogate(c.codePoint) { + return encodeSurrogate(c.codePoint) + } + return string(c.codePoint) +} From cb08daf2e8894d49fdfd57560f646477dd2e7129 Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Wed, 5 Nov 2025 13:01:37 -0800 Subject: [PATCH 29/33] Defer to utf16 package where possible --- internal/regexpchecker/utf16.go | 38 +++++++++++++++++---------------- 1 file changed, 20 insertions(+), 18 deletions(-) diff --git a/internal/regexpchecker/utf16.go b/internal/regexpchecker/utf16.go index dc329d4abe..06fa8e1687 100644 --- a/internal/regexpchecker/utf16.go +++ b/internal/regexpchecker/utf16.go @@ -1,16 +1,17 @@ package regexpchecker -import "unicode/utf8" +import ( + "unicode/utf16" + "unicode/utf8" +) // utf16.go contains utilities for handling UTF-16 surrogate pairs and encoding. // JavaScript regular expressions use UTF-16 internally, so we need to mimic this // behavior when validating regex patterns. This includes handling surrogate pairs // and preserving surrogate values that would otherwise be invalid in Go strings. -// UTF-16 surrogate pair constants +// UTF-16 surrogate pair constants (for cases where we need finer granularity than utf16 package) const ( - surrogateMin = 0xD800 // Start of surrogate range - surrogateMax = 0xDFFF // End of surrogate range highSurrogateMin = 0xD800 // Start of high surrogate range highSurrogateMax = 0xDBFF // End of high surrogate range lowSurrogateMin = 0xDC00 // Start of low surrogate range @@ -18,9 +19,10 @@ const ( supplementaryMin = 0x10000 // First code point requiring surrogate pair ) -// isSurrogate returns true if the code point is in the surrogate range +// isSurrogate returns true if the code point is in the surrogate range. +// Delegates to stdlib utf16.IsSurrogate. func isSurrogate(r rune) bool { - return r >= surrogateMin && r <= surrogateMax + return utf16.IsSurrogate(r) } // isHighSurrogate returns true if the code point is a high surrogate @@ -33,17 +35,16 @@ func isLowSurrogate(r rune) bool { return r >= lowSurrogateMin && r <= lowSurrogateMax } -// combineSurrogatePair combines a high and low surrogate into a code point +// combineSurrogatePair combines a high and low surrogate into a code point. +// Delegates to stdlib utf16.DecodeRune. func combineSurrogatePair(high, low rune) rune { - return supplementaryMin + ((high - highSurrogateMin) << 10) + (low - lowSurrogateMin) + return utf16.DecodeRune(high, low) } -// splitToSurrogatePair splits a supplementary code point into high and low surrogates +// splitToSurrogatePair splits a supplementary code point into high and low surrogates. +// Delegates to stdlib utf16.EncodeRune. func splitToSurrogatePair(r rune) (high, low rune) { - r -= supplementaryMin - high = highSurrogateMin + ((r >> 10) & 0x3FF) - low = lowSurrogateMin + (r & 0x3FF) - return high, low + return utf16.EncodeRune(r) } // encodeSurrogate encodes a UTF-16 surrogate value as a 2-byte UTF-16BE sequence. @@ -83,15 +84,16 @@ func decodeCodePoint(s string) rune { // charSize returns the number of UTF-16 code units needed to represent a code point. // This matches JavaScript's internal string representation. +// Similar to stdlib utf16.RuneLen but handles zero specially. func charSize(ch rune) int { - if ch >= supplementaryMin { - // Code points >= 0x10000 require surrogate pairs in UTF-16 (2 code units) - return 2 - } if ch == 0 { return 0 } - return 1 + // Use stdlib for consistency, but it returns -1 for invalid runes + if n := utf16.RuneLen(ch); n > 0 { + return n + } + return 1 // fallback for invalid runes } // utf16Length returns the UTF-16 length of a string, matching JavaScript's string.length. From b63d61bf9c42b7204527533a2a0aa5478256b65a Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Wed, 5 Nov 2025 13:01:46 -0800 Subject: [PATCH 30/33] Remove unused method --- internal/regexpchecker/utf16.go | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/internal/regexpchecker/utf16.go b/internal/regexpchecker/utf16.go index 06fa8e1687..3475a4ad82 100644 --- a/internal/regexpchecker/utf16.go +++ b/internal/regexpchecker/utf16.go @@ -132,13 +132,3 @@ func makeRegExpChar(codePoint rune) regExpChar { utf16Length: charSize(codePoint), } } - -// String returns a string representation suitable for comparison. -// For surrogates, uses UTF-16BE encoding to preserve the surrogate value. -// For normal code points, uses standard Go string encoding. -func (c regExpChar) String() string { - if isSurrogate(c.codePoint) { - return encodeSurrogate(c.codePoint) - } - return string(c.codePoint) -} From 0604d23a4aabcd908d988219bd4ec1719627920a Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Wed, 5 Nov 2025 14:09:32 -0800 Subject: [PATCH 31/33] Fix named capture group stuff --- internal/regexpchecker/regexpchecker.go | 53 +++++++++-- .../regularExpressionBackslashK.errors.txt | 75 +++++++++++++++ .../compiler/regularExpressionBackslashK.js | 94 +++++++++++++++++++ .../regularExpressionBackslashK.symbols | 73 ++++++++++++++ .../regularExpressionBackslashK.types | 89 ++++++++++++++++++ .../compiler/regularExpressionBackslashK.ts | 56 +++++++++++ 6 files changed, 430 insertions(+), 10 deletions(-) create mode 100644 testdata/baselines/reference/compiler/regularExpressionBackslashK.errors.txt create mode 100644 testdata/baselines/reference/compiler/regularExpressionBackslashK.js create mode 100644 testdata/baselines/reference/compiler/regularExpressionBackslashK.symbols create mode 100644 testdata/baselines/reference/compiler/regularExpressionBackslashK.types create mode 100644 testdata/tests/cases/compiler/regularExpressionBackslashK.ts diff --git a/internal/regexpchecker/regexpchecker.go b/internal/regexpchecker/regexpchecker.go index fcf999fca5..6bfb595d66 100644 --- a/internal/regexpchecker/regexpchecker.go +++ b/internal/regexpchecker/regexpchecker.go @@ -102,36 +102,69 @@ func Check( } // Similar to the original scanRegularExpressionWorker, but since we are outside the scanner, - // we need to rescan to find the body end and recalculate flags. + // we need to rescan for some information that the scanner previously calculated. - // Find the body end (before flags) bodyEnd := strings.LastIndexByte(text, '/') if bodyEnd <= 0 { panic("regexpchecker: regex must have closing '/' (scanner should have validated)") } - // Parse flags v.pos = bodyEnd + 1 v.end = len(text) v.regExpFlags = v.scanFlags(regExpFlagsNone, false) + v.pos = 1 + v.end = bodyEnd - // Set up validation parameters v.unicodeSetsMode = v.regExpFlags®ExpFlagsUnicodeSets != 0 v.anyUnicodeMode = v.regExpFlags®ExpFlagsAnyUnicodeMode != 0 - // Always validate as if in Annex B mode v.annexB = true v.anyUnicodeModeOrNonAnnexB = v.anyUnicodeMode || !v.annexB + v.namedCaptureGroups = v.detectNamedCaptureGroups() - // Validate the pattern body - v.pos = 1 // Reset to start of pattern (after initial '/') - v.end = bodyEnd v.scanDisjunction(false) - - // Post-validation checks v.validateGroupReferences() v.validateDecimalEscapes() } +// detectNamedCaptureGroups performs a quick scan of the pattern to detect +// if it contains any named capture groups (?...). This is needed because +// the presence of named groups changes the interpretation of \k escapes: +// - Without named groups: \k is an identity escape (matches literal 'k') +// - With named groups: \k must be followed by or it's a syntax error +// This matches the behavior in scanner.ts's reScanSlashToken. +func (v *regExpValidator) detectNamedCaptureGroups() bool { + inEscape := false + inCharacterClass := false + text := v.text[v.pos:v.end] + + for i, ch := range text { + // Only check ASCII characters for the pattern (?< + if ch >= 0x80 { + continue + } + + if inEscape { + inEscape = false + } else if ch == '\\' { + inEscape = true + } else if ch == '[' { + inCharacterClass = true + } else if ch == ']' { + inCharacterClass = false + } else if !inCharacterClass && + ch == '(' && + i+3 < len(text) && + text[i+1] == '?' && + text[i+2] == '<' && + text[i+3] != '=' && + text[i+3] != '!' { + // Found (?< that's not (?<= or (?= v.end { return 0, 0 diff --git a/testdata/baselines/reference/compiler/regularExpressionBackslashK.errors.txt b/testdata/baselines/reference/compiler/regularExpressionBackslashK.errors.txt new file mode 100644 index 0000000000..7bfbf41421 --- /dev/null +++ b/testdata/baselines/reference/compiler/regularExpressionBackslashK.errors.txt @@ -0,0 +1,75 @@ +regularExpressionBackslashK.ts(7,28): error TS1510: '\k' must be followed by a capturing group name enclosed in angle brackets. +regularExpressionBackslashK.ts(10,36): error TS1510: '\k' must be followed by a capturing group name enclosed in angle brackets. +regularExpressionBackslashK.ts(16,27): error TS1510: '\k' must be followed by a capturing group name enclosed in angle brackets. +regularExpressionBackslashK.ts(30,40): error TS1510: '\k' must be followed by a capturing group name enclosed in angle brackets. +regularExpressionBackslashK.ts(33,27): error TS1510: '\k' must be followed by a capturing group name enclosed in angle brackets. +regularExpressionBackslashK.ts(50,38): error TS1510: '\k' must be followed by a capturing group name enclosed in angle brackets. + + +==== regularExpressionBackslashK.ts (6 errors) ==== + // Test that \k without < is an error when named groups are present + + // Valid: \k followed by with named groups + const validBackref = /(?a)\k/; + + // Invalid: \k not followed by < when named groups are present (even in non-Unicode mode) + const invalidK = /(?a)\k/; + ~~ +!!! error TS1510: '\k' must be followed by a capturing group name enclosed in angle brackets. + + // Invalid: \k followed by other chars when named groups are present + const invalidKWithText = /(?x)\kb/; + ~~ +!!! error TS1510: '\k' must be followed by a capturing group name enclosed in angle brackets. + + // Valid: \k without < is OK when there are NO named groups (identity escape) + const validIdentityEscape = /a\kb/; + + // Invalid: \k without < in Unicode mode (regardless of named groups) + const invalidKUnicode = /a\kb/u; + ~~ +!!! error TS1510: '\k' must be followed by a capturing group name enclosed in angle brackets. + + // Edge cases + + // Multiple named groups, valid backreferences + const multiGroup = /(?x)(?y)\k\k/; + + // Named group in alternation with \k in different branch + const alternation = /(?a)|\k/; + + // Named group with \k in lookahead + const lookahead = /(?b)(?=\k)/; + + // Named group with bare \k - should error + const bareKWithGroups = /(?.)(?.)\k/; + ~~ +!!! error TS1510: '\k' must be followed by a capturing group name enclosed in angle brackets. + + // Bare \k at start when named group comes later - should still error + const bareKBeforeGroup = /\k(?pattern)/; + ~~ +!!! error TS1510: '\k' must be followed by a capturing group name enclosed in angle brackets. + + // Identity escape \k is valid when no named groups at all + const noNamedGroups = /\ka\kb/; + + // Unicode characters + + // Unicode characters before named group + const unicodeBefore = /šŸ˜€(?a)\k/; + + // Unicode characters after named group + const unicodeAfter = /(?b)\kšŸ˜€/; + + // Unicode characters in between + const unicodeMiddle = /(?.)šŸ˜€\k/; + + // Unicode with bare \k - should error + const unicodeWithBareK = /šŸ˜€(?.)\k/; + ~~ +!!! error TS1510: '\k' must be followed by a capturing group name enclosed in angle brackets. + + // Unicode without named groups and \k - should be OK + const unicodeNoGroups = /šŸ˜€\kšŸ˜€/; + \ No newline at end of file diff --git a/testdata/baselines/reference/compiler/regularExpressionBackslashK.js b/testdata/baselines/reference/compiler/regularExpressionBackslashK.js new file mode 100644 index 0000000000..ecadc21a40 --- /dev/null +++ b/testdata/baselines/reference/compiler/regularExpressionBackslashK.js @@ -0,0 +1,94 @@ +//// [tests/cases/compiler/regularExpressionBackslashK.ts] //// + +//// [regularExpressionBackslashK.ts] +// Test that \k without < is an error when named groups are present + +// Valid: \k followed by with named groups +const validBackref = /(?a)\k/; + +// Invalid: \k not followed by < when named groups are present (even in non-Unicode mode) +const invalidK = /(?a)\k/; + +// Invalid: \k followed by other chars when named groups are present +const invalidKWithText = /(?x)\kb/; + +// Valid: \k without < is OK when there are NO named groups (identity escape) +const validIdentityEscape = /a\kb/; + +// Invalid: \k without < in Unicode mode (regardless of named groups) +const invalidKUnicode = /a\kb/u; + +// Edge cases + +// Multiple named groups, valid backreferences +const multiGroup = /(?x)(?y)\k\k/; + +// Named group in alternation with \k in different branch +const alternation = /(?a)|\k/; + +// Named group with \k in lookahead +const lookahead = /(?b)(?=\k)/; + +// Named group with bare \k - should error +const bareKWithGroups = /(?.)(?.)\k/; + +// Bare \k at start when named group comes later - should still error +const bareKBeforeGroup = /\k(?pattern)/; + +// Identity escape \k is valid when no named groups at all +const noNamedGroups = /\ka\kb/; + +// Unicode characters + +// Unicode characters before named group +const unicodeBefore = /šŸ˜€(?a)\k/; + +// Unicode characters after named group +const unicodeAfter = /(?b)\kšŸ˜€/; + +// Unicode characters in between +const unicodeMiddle = /(?.)šŸ˜€\k/; + +// Unicode with bare \k - should error +const unicodeWithBareK = /šŸ˜€(?.)\k/; + +// Unicode without named groups and \k - should be OK +const unicodeNoGroups = /šŸ˜€\kšŸ˜€/; + + +//// [regularExpressionBackslashK.js] +// Test that \k without < is an error when named groups are present +// Valid: \k followed by with named groups +const validBackref = /(?a)\k/; +// Invalid: \k not followed by < when named groups are present (even in non-Unicode mode) +const invalidK = /(?a)\k/; +// Invalid: \k followed by other chars when named groups are present +const invalidKWithText = /(?x)\kb/; +// Valid: \k without < is OK when there are NO named groups (identity escape) +const validIdentityEscape = /a\kb/; +// Invalid: \k without < in Unicode mode (regardless of named groups) +const invalidKUnicode = /a\kb/u; +// Edge cases +// Multiple named groups, valid backreferences +const multiGroup = /(?x)(?y)\k\k/; +// Named group in alternation with \k in different branch +const alternation = /(?a)|\k/; +// Named group with \k in lookahead +const lookahead = /(?b)(?=\k)/; +// Named group with bare \k - should error +const bareKWithGroups = /(?.)(?.)\k/; +// Bare \k at start when named group comes later - should still error +const bareKBeforeGroup = /\k(?pattern)/; +// Identity escape \k is valid when no named groups at all +const noNamedGroups = /\ka\kb/; +// Unicode characters +// Unicode characters before named group +const unicodeBefore = /šŸ˜€(?a)\k/; +// Unicode characters after named group +const unicodeAfter = /(?b)\kšŸ˜€/; +// Unicode characters in between +const unicodeMiddle = /(?.)šŸ˜€\k/; +// Unicode with bare \k - should error +const unicodeWithBareK = /šŸ˜€(?.)\k/; +// Unicode without named groups and \k - should be OK +const unicodeNoGroups = /šŸ˜€\kšŸ˜€/; diff --git a/testdata/baselines/reference/compiler/regularExpressionBackslashK.symbols b/testdata/baselines/reference/compiler/regularExpressionBackslashK.symbols new file mode 100644 index 0000000000..12b72e8d06 --- /dev/null +++ b/testdata/baselines/reference/compiler/regularExpressionBackslashK.symbols @@ -0,0 +1,73 @@ +//// [tests/cases/compiler/regularExpressionBackslashK.ts] //// + +=== regularExpressionBackslashK.ts === +// Test that \k without < is an error when named groups are present + +// Valid: \k followed by with named groups +const validBackref = /(?a)\k/; +>validBackref : Symbol(validBackref, Decl(regularExpressionBackslashK.ts, 3, 5)) + +// Invalid: \k not followed by < when named groups are present (even in non-Unicode mode) +const invalidK = /(?a)\k/; +>invalidK : Symbol(invalidK, Decl(regularExpressionBackslashK.ts, 6, 5)) + +// Invalid: \k followed by other chars when named groups are present +const invalidKWithText = /(?x)\kb/; +>invalidKWithText : Symbol(invalidKWithText, Decl(regularExpressionBackslashK.ts, 9, 5)) + +// Valid: \k without < is OK when there are NO named groups (identity escape) +const validIdentityEscape = /a\kb/; +>validIdentityEscape : Symbol(validIdentityEscape, Decl(regularExpressionBackslashK.ts, 12, 5)) + +// Invalid: \k without < in Unicode mode (regardless of named groups) +const invalidKUnicode = /a\kb/u; +>invalidKUnicode : Symbol(invalidKUnicode, Decl(regularExpressionBackslashK.ts, 15, 5)) + +// Edge cases + +// Multiple named groups, valid backreferences +const multiGroup = /(?x)(?y)\k\k/; +>multiGroup : Symbol(multiGroup, Decl(regularExpressionBackslashK.ts, 20, 5)) + +// Named group in alternation with \k in different branch +const alternation = /(?a)|\k/; +>alternation : Symbol(alternation, Decl(regularExpressionBackslashK.ts, 23, 5)) + +// Named group with \k in lookahead +const lookahead = /(?b)(?=\k)/; +>lookahead : Symbol(lookahead, Decl(regularExpressionBackslashK.ts, 26, 5)) + +// Named group with bare \k - should error +const bareKWithGroups = /(?.)(?.)\k/; +>bareKWithGroups : Symbol(bareKWithGroups, Decl(regularExpressionBackslashK.ts, 29, 5)) + +// Bare \k at start when named group comes later - should still error +const bareKBeforeGroup = /\k(?pattern)/; +>bareKBeforeGroup : Symbol(bareKBeforeGroup, Decl(regularExpressionBackslashK.ts, 32, 5)) + +// Identity escape \k is valid when no named groups at all +const noNamedGroups = /\ka\kb/; +>noNamedGroups : Symbol(noNamedGroups, Decl(regularExpressionBackslashK.ts, 35, 5)) + +// Unicode characters + +// Unicode characters before named group +const unicodeBefore = /šŸ˜€(?a)\k/; +>unicodeBefore : Symbol(unicodeBefore, Decl(regularExpressionBackslashK.ts, 40, 5)) + +// Unicode characters after named group +const unicodeAfter = /(?b)\kšŸ˜€/; +>unicodeAfter : Symbol(unicodeAfter, Decl(regularExpressionBackslashK.ts, 43, 5)) + +// Unicode characters in between +const unicodeMiddle = /(?.)šŸ˜€\k/; +>unicodeMiddle : Symbol(unicodeMiddle, Decl(regularExpressionBackslashK.ts, 46, 5)) + +// Unicode with bare \k - should error +const unicodeWithBareK = /šŸ˜€(?.)\k/; +>unicodeWithBareK : Symbol(unicodeWithBareK, Decl(regularExpressionBackslashK.ts, 49, 5)) + +// Unicode without named groups and \k - should be OK +const unicodeNoGroups = /šŸ˜€\kšŸ˜€/; +>unicodeNoGroups : Symbol(unicodeNoGroups, Decl(regularExpressionBackslashK.ts, 52, 5)) + diff --git a/testdata/baselines/reference/compiler/regularExpressionBackslashK.types b/testdata/baselines/reference/compiler/regularExpressionBackslashK.types new file mode 100644 index 0000000000..960f33e5e9 --- /dev/null +++ b/testdata/baselines/reference/compiler/regularExpressionBackslashK.types @@ -0,0 +1,89 @@ +//// [tests/cases/compiler/regularExpressionBackslashK.ts] //// + +=== regularExpressionBackslashK.ts === +// Test that \k without < is an error when named groups are present + +// Valid: \k followed by with named groups +const validBackref = /(?a)\k/; +>validBackref : RegExp +>/(?a)\k/ : RegExp + +// Invalid: \k not followed by < when named groups are present (even in non-Unicode mode) +const invalidK = /(?a)\k/; +>invalidK : RegExp +>/(?a)\k/ : RegExp + +// Invalid: \k followed by other chars when named groups are present +const invalidKWithText = /(?x)\kb/; +>invalidKWithText : RegExp +>/(?x)\kb/ : RegExp + +// Valid: \k without < is OK when there are NO named groups (identity escape) +const validIdentityEscape = /a\kb/; +>validIdentityEscape : RegExp +>/a\kb/ : RegExp + +// Invalid: \k without < in Unicode mode (regardless of named groups) +const invalidKUnicode = /a\kb/u; +>invalidKUnicode : RegExp +>/a\kb/u : RegExp + +// Edge cases + +// Multiple named groups, valid backreferences +const multiGroup = /(?x)(?y)\k\k/; +>multiGroup : RegExp +>/(?x)(?y)\k\k/ : RegExp + +// Named group in alternation with \k in different branch +const alternation = /(?a)|\k/; +>alternation : RegExp +>/(?a)|\k/ : RegExp + +// Named group with \k in lookahead +const lookahead = /(?b)(?=\k)/; +>lookahead : RegExp +>/(?b)(?=\k)/ : RegExp + +// Named group with bare \k - should error +const bareKWithGroups = /(?.)(?.)\k/; +>bareKWithGroups : RegExp +>/(?.)(?.)\k/ : RegExp + +// Bare \k at start when named group comes later - should still error +const bareKBeforeGroup = /\k(?pattern)/; +>bareKBeforeGroup : RegExp +>/\k(?pattern)/ : RegExp + +// Identity escape \k is valid when no named groups at all +const noNamedGroups = /\ka\kb/; +>noNamedGroups : RegExp +>/\ka\kb/ : RegExp + +// Unicode characters + +// Unicode characters before named group +const unicodeBefore = /šŸ˜€(?a)\k/; +>unicodeBefore : RegExp +>/šŸ˜€(?a)\k/ : RegExp + +// Unicode characters after named group +const unicodeAfter = /(?b)\kšŸ˜€/; +>unicodeAfter : RegExp +>/(?b)\kšŸ˜€/ : RegExp + +// Unicode characters in between +const unicodeMiddle = /(?.)šŸ˜€\k/; +>unicodeMiddle : RegExp +>/(?.)šŸ˜€\k/ : RegExp + +// Unicode with bare \k - should error +const unicodeWithBareK = /šŸ˜€(?.)\k/; +>unicodeWithBareK : RegExp +>/šŸ˜€(?.)\k/ : RegExp + +// Unicode without named groups and \k - should be OK +const unicodeNoGroups = /šŸ˜€\kšŸ˜€/; +>unicodeNoGroups : RegExp +>/šŸ˜€\kšŸ˜€/ : RegExp + diff --git a/testdata/tests/cases/compiler/regularExpressionBackslashK.ts b/testdata/tests/cases/compiler/regularExpressionBackslashK.ts new file mode 100644 index 0000000000..4721ce7c1e --- /dev/null +++ b/testdata/tests/cases/compiler/regularExpressionBackslashK.ts @@ -0,0 +1,56 @@ +// @target: esnext +// @strict: true + +// Test that \k without < is an error when named groups are present + +// Valid: \k followed by with named groups +const validBackref = /(?a)\k/; + +// Invalid: \k not followed by < when named groups are present (even in non-Unicode mode) +const invalidK = /(?a)\k/; + +// Invalid: \k followed by other chars when named groups are present +const invalidKWithText = /(?x)\kb/; + +// Valid: \k without < is OK when there are NO named groups (identity escape) +const validIdentityEscape = /a\kb/; + +// Invalid: \k without < in Unicode mode (regardless of named groups) +const invalidKUnicode = /a\kb/u; + +// Edge cases + +// Multiple named groups, valid backreferences +const multiGroup = /(?x)(?y)\k\k/; + +// Named group in alternation with \k in different branch +const alternation = /(?a)|\k/; + +// Named group with \k in lookahead +const lookahead = /(?b)(?=\k)/; + +// Named group with bare \k - should error +const bareKWithGroups = /(?.)(?.)\k/; + +// Bare \k at start when named group comes later - should still error +const bareKBeforeGroup = /\k(?pattern)/; + +// Identity escape \k is valid when no named groups at all +const noNamedGroups = /\ka\kb/; + +// Unicode characters + +// Unicode characters before named group +const unicodeBefore = /šŸ˜€(?a)\k/; + +// Unicode characters after named group +const unicodeAfter = /(?b)\kšŸ˜€/; + +// Unicode characters in between +const unicodeMiddle = /(?.)šŸ˜€\k/; + +// Unicode with bare \k - should error +const unicodeWithBareK = /šŸ˜€(?.)\k/; + +// Unicode without named groups and \k - should be OK +const unicodeNoGroups = /šŸ˜€\kšŸ˜€/; From 082cbcc8a1adeb51c9f3b0903dc7ab1589f8f91f Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Wed, 5 Nov 2025 14:33:02 -0800 Subject: [PATCH 32/33] Fix porting difference --- internal/regexpchecker/regexpchecker.go | 33 ++++++++++++++----------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/internal/regexpchecker/regexpchecker.go b/internal/regexpchecker/regexpchecker.go index 6bfb595d66..f806a0a51c 100644 --- a/internal/regexpchecker/regexpchecker.go +++ b/internal/regexpchecker/regexpchecker.go @@ -1002,28 +1002,31 @@ func (v *regExpValidator) isClassContentExit(ch rune) bool { // | SourceCharacter but not one of '\' or ']' // | '\' ClassEscape // -// Follows ECMAScript regexp grammar -func (v *regExpValidator) scanClassAtom() string { - if v.charAtOffset(0) == '\\' { - v.pos++ - return v.scanClassEscape() - } - return v.scanSourceCharacter() -} - // ClassEscape ::= // // | 'b' // | '-' // | CharacterClassEscape // | CharacterEscape -// -// Follows ECMAScript regexp grammar -func (v *regExpValidator) scanClassEscape() string { - if v.scanCharacterClassEscape() { - return "" +func (v *regExpValidator) scanClassAtom() string { + if v.charAtOffset(0) == '\\' { + v.pos++ + ch := v.charAtOffset(0) + switch ch { + case 'b': + v.pos++ + return "\b" // backspace character + case '-': + v.pos++ + return string(ch) // hyphen character + default: + if v.scanCharacterClassEscape() { + return "" + } + return v.scanCharacterEscape(false) + } } - return v.scanCharacterEscape(false) + return v.scanSourceCharacter() } type classSetExpressionType int From 320e435982172a5d2c4c20c2c7e8d47f87689207 Mon Sep 17 00:00:00 2001 From: Jake Bailey <5341706+jakebailey@users.noreply.github.com> Date: Wed, 5 Nov 2025 14:52:56 -0800 Subject: [PATCH 33/33] fix escaping --- internal/regexpchecker/regexpchecker.go | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/internal/regexpchecker/regexpchecker.go b/internal/regexpchecker/regexpchecker.go index f806a0a51c..244b5a1ebd 100644 --- a/internal/regexpchecker/regexpchecker.go +++ b/internal/regexpchecker/regexpchecker.go @@ -717,9 +717,18 @@ func (v *regExpValidator) scanEscapeSequence(atomEscape bool) string { } return string(ch) - case 'b', 't', 'n', 'v', 'f', 'r': - // Standard escape sequences - return string(ch) + case 'b': + return "\b" + case 't': + return "\t" + case 'n': + return "\n" + case 'v': + return "\v" + case 'f': + return "\f" + case 'r': + return "\r" case 'x': // Hex escape '\xDD' @@ -1126,8 +1135,9 @@ func (v *regExpValidator) scanClassSetExpression() { } secondStart := v.pos secondOperand := v.scanClassSetOperand() - // Don't report TS1518 for the second operand of a range - // expressionMayContainStrings tracking is still needed + if isCharacterComplement && v.mayContainStrings { + v.error(diagnostics.Anything_that_would_possibly_match_more_than_a_single_character_is_invalid_inside_a_negated_character_class, secondStart, v.pos-secondStart) + } expressionMayContainStrings = expressionMayContainStrings || v.mayContainStrings if secondOperand == "" { v.error(diagnostics.A_character_class_range_must_not_be_bounded_by_another_character_class, secondStart, v.pos-secondStart)