From 6f4fc7a4b9eca6faf7f89b59ca48df4d880a2470 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Burzy=C5=84ski?= Date: Sat, 21 Feb 2026 20:29:36 +0100 Subject: [PATCH 01/43] Port "Provide Syntax Checking for Regular Expressions" Co-authored-by: =?UTF-8?q?=E5=BD=A2=E7=B4=A0=E5=8F=A2=E9=9B=86=E3=83=BB=E3=81=90?= =?UTF-8?q?=E3=82=89=E3=81=B5=E3=81=83=E3=83=BC=E3=82=80?= --- internal/parser/parser.go | 15 +- internal/scanner/regexp.go | 1005 +++++++++++++++++ internal/scanner/scanner.go | 141 ++- internal/scanner/unicodeproperties.go | 166 +++ ...acketInCharClass(target=es2015).errors.txt | 12 + ...InCharClass(target=es2015).errors.txt.diff | 22 +- ...acketInCharClass(target=esnext).errors.txt | 12 + ...InCharClass(target=esnext).errors.txt.diff | 16 - .../regularExpressionAnnexB.errors.txt | 341 ++++++ .../regularExpressionAnnexB.errors.txt.diff | 385 ++----- ...ressionCharacterClassRangeOrder.errors.txt | 46 + ...onCharacterClassRangeOrder.errors.txt.diff | 79 +- ...rExpressionGroupNameSuggestions.errors.txt | 9 + ...essionGroupNameSuggestions.errors.txt.diff | 17 +- ...pressionScanning(target=es2015).errors.txt | 643 +++++++++++ ...ionScanning(target=es2015).errors.txt.diff | 829 ++++---------- ...pressionScanning(target=esnext).errors.txt | 643 +++++++++++ ...ionScanning(target=esnext).errors.txt.diff | 677 +---------- ...ssionSuggestions(target=es2015).errors.txt | 25 + ...Suggestions(target=es2015).errors.txt.diff | 40 +- ...egularExpressionWithNonBMPFlags.errors.txt | 26 + ...rExpressionWithNonBMPFlags.errors.txt.diff | 36 +- .../compiler/shebangError.errors.txt | 8 +- .../compiler/shebangError.errors.txt.diff | 29 + ...numericSeparators.unicodeEscape.errors.txt | 62 +- ...icSeparators.unicodeEscape.errors.txt.diff | 175 --- .../conformance/parser579071.errors.txt | 7 + .../conformance/parser579071.errors.txt.diff | 11 - .../parserRegularExpression1.errors.txt | 7 + .../parserRegularExpression1.errors.txt.diff | 11 + ...gularExpressionDivideAmbiguity3.errors.txt | 5 +- ...ExpressionDivideAmbiguity3.errors.txt.diff | 14 - ...egularExpressions07(target=es6).errors.txt | 10 + ...rExpressions07(target=es6).errors.txt.diff | 14 - ...egularExpressions12(target=es6).errors.txt | 8 + ...rExpressions12(target=es6).errors.txt.diff | 12 - ...egularExpressions14(target=es6).errors.txt | 12 + ...rExpressions14(target=es6).errors.txt.diff | 16 - ...egularExpressions17(target=es6).errors.txt | 23 + ...rExpressions17(target=es6).errors.txt.diff | 27 - ...egularExpressions19(target=es6).errors.txt | 8 + ...rExpressions19(target=es6).errors.txt.diff | 12 - 42 files changed, 3683 insertions(+), 1973 deletions(-) create mode 100644 internal/scanner/regexp.go create mode 100644 internal/scanner/unicodeproperties.go create mode 100644 testdata/baselines/reference/submodule/compiler/regExpWithOpenBracketInCharClass(target=es2015).errors.txt 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 create mode 100644 testdata/baselines/reference/submodule/compiler/regularExpressionCharacterClassRangeOrder.errors.txt create mode 100644 testdata/baselines/reference/submodule/compiler/regularExpressionGroupNameSuggestions.errors.txt create mode 100644 testdata/baselines/reference/submodule/compiler/regularExpressionScanning(target=es2015).errors.txt create mode 100644 testdata/baselines/reference/submodule/compiler/regularExpressionScanning(target=esnext).errors.txt create mode 100644 testdata/baselines/reference/submodule/compiler/regularExpressionUnicodePropertyValueExpressionSuggestions(target=es2015).errors.txt create mode 100644 testdata/baselines/reference/submodule/compiler/regularExpressionWithNonBMPFlags.errors.txt create mode 100644 testdata/baselines/reference/submodule/compiler/shebangError.errors.txt.diff delete mode 100644 testdata/baselines/reference/submodule/conformance/parser.numericSeparators.unicodeEscape.errors.txt.diff create mode 100644 testdata/baselines/reference/submodule/conformance/parser579071.errors.txt delete mode 100644 testdata/baselines/reference/submodule/conformance/parser579071.errors.txt.diff create mode 100644 testdata/baselines/reference/submodule/conformance/parserRegularExpression1.errors.txt create mode 100644 testdata/baselines/reference/submodule/conformance/parserRegularExpression1.errors.txt.diff delete mode 100644 testdata/baselines/reference/submodule/conformance/parserRegularExpressionDivideAmbiguity3.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=es6).errors.txt delete mode 100644 testdata/baselines/reference/submodule/conformance/unicodeExtendedEscapesInRegularExpressions12(target=es6).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=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=es6).errors.txt delete mode 100644 testdata/baselines/reference/submodule/conformance/unicodeExtendedEscapesInRegularExpressions19(target=es6).errors.txt.diff diff --git a/internal/parser/parser.go b/internal/parser/parser.go index ac11b89decd..dadab90e915 100644 --- a/internal/parser/parser.go +++ b/internal/parser/parser.go @@ -251,7 +251,20 @@ func (p *Parser) initializeState(opts ast.SourceFileParseOptions, sourceText str } func (p *Parser) scanError(message *diagnostics.Message, pos int, length int, args ...any) { - p.parseErrorAtRange(core.NewTextRange(pos, pos+length), message, args...) + lastError := p.lastDiagnostic() + if message.Category() == diagnostics.CategoryMessage && lastError != nil && pos == lastError.Pos() && length == lastError.Len() { + related := ast.NewDiagnostic(nil, core.NewTextRange(pos, pos+length), message, args...) + lastError.AddRelatedInfo(related) + } else { + p.parseErrorAtRange(core.NewTextRange(pos, pos+length), message, args...) + } +} + +func (p *Parser) lastDiagnostic() *ast.Diagnostic { + if len(p.diagnostics) > 0 { + return p.diagnostics[len(p.diagnostics)-1] + } + return nil } func (p *Parser) parseErrorAt(pos int, end int, message *diagnostics.Message, args ...any) *ast.Diagnostic { diff --git a/internal/scanner/regexp.go b/internal/scanner/regexp.go new file mode 100644 index 00000000000..0a590e6e7bf --- /dev/null +++ b/internal/scanner/regexp.go @@ -0,0 +1,1005 @@ +package scanner + +import ( + "strconv" + "unicode/utf8" + + "github.com/microsoft/typescript-go/internal/core" + "github.com/microsoft/typescript-go/internal/diagnostics" + "github.com/microsoft/typescript-go/internal/stringutil" +) + +type RegularExpressionFlags int32 + +const ( + RegularExpressionFlagsNone RegularExpressionFlags = 0 + RegularExpressionFlagsHasIndices RegularExpressionFlags = 1 << 0 // d + RegularExpressionFlagsGlobal RegularExpressionFlags = 1 << 1 // g + RegularExpressionFlagsIgnoreCase RegularExpressionFlags = 1 << 2 // i + RegularExpressionFlagsMultiline RegularExpressionFlags = 1 << 3 // m + RegularExpressionFlagsDotAll RegularExpressionFlags = 1 << 4 // s + RegularExpressionFlagsUnicode RegularExpressionFlags = 1 << 5 // u + RegularExpressionFlagsUnicodeSets RegularExpressionFlags = 1 << 6 // v + RegularExpressionFlagsSticky RegularExpressionFlags = 1 << 7 // y + RegularExpressionFlagsUnicodeMode RegularExpressionFlags = RegularExpressionFlagsUnicode | RegularExpressionFlagsUnicodeSets + RegularExpressionFlagsModifiers RegularExpressionFlags = RegularExpressionFlagsIgnoreCase | RegularExpressionFlagsMultiline | RegularExpressionFlagsDotAll +) + +var charToRegExpFlag = map[rune]RegularExpressionFlags{ + 'd': RegularExpressionFlagsHasIndices, + 'g': RegularExpressionFlagsGlobal, + 'i': RegularExpressionFlagsIgnoreCase, + 'm': RegularExpressionFlagsMultiline, + 's': RegularExpressionFlagsDotAll, + 'u': RegularExpressionFlagsUnicode, + 'v': RegularExpressionFlagsUnicodeSets, + 'y': RegularExpressionFlagsSticky, +} + +var regExpFlagToFirstAvailableLanguageVersion = map[RegularExpressionFlags]core.ScriptTarget{ + RegularExpressionFlagsHasIndices: core.ScriptTargetES2022, + RegularExpressionFlagsGlobal: core.ScriptTargetES5, // ES3 doesn't exist in Go; ES5 is the lowest + RegularExpressionFlagsIgnoreCase: core.ScriptTargetES5, + RegularExpressionFlagsMultiline: core.ScriptTargetES5, + RegularExpressionFlagsDotAll: core.ScriptTargetES2018, + RegularExpressionFlagsUnicode: core.ScriptTargetES2015, + RegularExpressionFlagsUnicodeSets: core.ScriptTargetESNext, + RegularExpressionFlagsSticky: core.ScriptTargetES2015, +} + +func CharacterToRegularExpressionFlag(ch rune) (RegularExpressionFlags, bool) { + flag, ok := charToRegExpFlag[ch] + return flag, ok +} + +type classSetExpressionType int + +const ( + classSetExpressionTypeUnknown classSetExpressionType = iota + classSetExpressionTypeClassUnion + classSetExpressionTypeClassIntersection + classSetExpressionTypeClassSubtraction +) + +type groupNameReference struct { + pos int + end int + name string +} + +type decimalEscapeValue struct { + pos int + end int + value int +} + +type regExpParser struct { + scanner *Scanner + end int + regExpFlags RegularExpressionFlags + isUnterminated bool + unicodeMode bool + unicodeSetsMode bool + + mayContainStrings bool + numberOfCapturingGroups int + groupSpecifiers map[string]bool + groupNameReferences []groupNameReference + decimalEscapes []decimalEscapeValue + namedCapturingGroups []map[string]bool +} + +func (p *regExpParser) pos() int { + return p.scanner.pos +} + +func (p *regExpParser) setPos(v int) { + p.scanner.pos = v +} + +func (p *regExpParser) incPos(n int) { + p.scanner.pos += n +} + +func (p *regExpParser) charAt(pos int) rune { + if pos < p.end { + return rune(p.scanner.text[pos]) + } + return -1 +} + +func (p *regExpParser) error(msg *diagnostics.Message, pos int, length int, args ...any) { + p.scanner.errorAt(msg, pos, length, args...) +} + +func (p *regExpParser) text() string { + return p.scanner.text +} + +// Disjunction ::= Alternative ('|' Alternative)* +func (p *regExpParser) scanDisjunction(isInGroup bool) { + for { + p.namedCapturingGroups = append(p.namedCapturingGroups, make(map[string]bool)) + p.scanAlternative(isInGroup) + p.namedCapturingGroups = p.namedCapturingGroups[:len(p.namedCapturingGroups)-1] + if p.charAt(p.pos()) != '|' { + return + } + p.incPos(1) + } +} + +// Alternative ::= Term* +// Term ::= +// | Assertion +// | Atom Quantifier? +// Assertion ::= +// | '^' +// | '$' +// | '\b' +// | '\B' +// | '(?=' Disjunction ')' +// | '(?!' Disjunction ')' +// | '(?<=' Disjunction ')' +// | '(?' Disjunction ')' +// | '(?' RegularExpressionFlags ('-' RegularExpressionFlags)? ':' Disjunction ')' +// CharacterClass ::= unicodeMode +// ? '[' ClassRanges ']' +// : '[' ClassSetExpression ']' +func (p *regExpParser) scanAlternative(isInGroup bool) { + isPreviousTermQuantifiable := false + for p.pos() < p.end { + start := p.pos() + ch := p.charAt(p.pos()) + switch ch { + case '^', '$': + p.incPos(1) + isPreviousTermQuantifiable = false + case '\\': + p.incPos(1) + switch p.charAt(p.pos()) { + case 'b', 'B': + p.incPos(1) + isPreviousTermQuantifiable = false + default: + p.scanAtomEscape() + isPreviousTermQuantifiable = true + } + case '(': + p.incPos(1) + if p.charAt(p.pos()) == '?' { + p.incPos(1) + switch p.charAt(p.pos()) { + case '=', '!': + p.incPos(1) + isPreviousTermQuantifiable = false + case '<': + groupNameStart := p.pos() + p.incPos(1) + switch p.charAt(p.pos()) { + case '=', '!': + p.incPos(1) + isPreviousTermQuantifiable = false + default: + p.scanGroupName(false /*isReference*/) + p.scanExpectedChar('>') + if p.scanner.languageVersion() < core.ScriptTargetES2018 { + p.error(diagnostics.Named_capturing_groups_are_only_available_when_targeting_ES2018_or_later, groupNameStart, p.pos()-groupNameStart) + } + p.numberOfCapturingGroups++ + isPreviousTermQuantifiable = true + } + default: + flagsStart := p.pos() + setFlags := p.scanPatternModifiers(RegularExpressionFlagsNone) + if p.charAt(p.pos()) == '-' { + p.incPos(1) + p.scanPatternModifiers(setFlags) + if p.pos() == flagsStart+1 { + p.error(diagnostics.Subpattern_flags_must_be_present_when_there_is_a_minus_sign, flagsStart, p.pos()-flagsStart) + } + } + p.scanExpectedChar(':') + isPreviousTermQuantifiable = true + } + } else { + p.numberOfCapturingGroups++ + isPreviousTermQuantifiable = true + } + p.scanDisjunction(true /*isInGroup*/) + p.scanExpectedChar(')') + case '{': + p.incPos(1) + digitsStart := p.pos() + p.scanDigits() + min := p.scanner.tokenValue + if p.charAt(p.pos()) == ',' { + p.incPos(1) + p.scanDigits() + max := p.scanner.tokenValue + if min == "" { + if max != "" || p.charAt(p.pos()) == '}' { + p.error(diagnostics.Incomplete_quantifier_Digit_expected, digitsStart, 0) + } else { + if p.unicodeMode { + p.error(diagnostics.Unexpected_0_Did_you_mean_to_escape_it_with_backslash, start, 1, string(ch)) + } + isPreviousTermQuantifiable = true + continue + } + } + if max != "" { + minVal, _ := strconv.Atoi(min) + maxVal, _ := strconv.Atoi(max) + if minVal > maxVal { + p.error(diagnostics.Numbers_out_of_order_in_quantifier, digitsStart, p.pos()-digitsStart) + } + } + } else if min == "" { + if p.unicodeMode { + p.error(diagnostics.Unexpected_0_Did_you_mean_to_escape_it_with_backslash, start, 1, string(ch)) + } + isPreviousTermQuantifiable = true + continue + } + p.scanExpectedChar('}') + p.incPos(-1) + // falls through to quantifier handling + fallthrough + case '*', '+', '?': + p.incPos(1) + if p.charAt(p.pos()) == '?' { + p.incPos(1) + } + if !isPreviousTermQuantifiable { + p.error(diagnostics.There_is_nothing_available_for_repetition, start, p.pos()-start) + } + isPreviousTermQuantifiable = false + case '.': + p.incPos(1) + isPreviousTermQuantifiable = true + case '[': + p.incPos(1) + if p.unicodeSetsMode { + p.scanClassSetExpression() + } else { + p.scanClassRanges() + } + p.scanExpectedChar(']') + isPreviousTermQuantifiable = true + case ')': + if isInGroup { + return + } + fallthrough + case ']', '}': + if p.isUnterminated && !isInGroup { + return + } + if p.unicodeMode || ch == ')' { + p.error(diagnostics.Unexpected_0_Did_you_mean_to_escape_it_with_backslash, p.pos(), 1, string(ch)) + } + p.incPos(1) + isPreviousTermQuantifiable = true + case '/', '|': + return + default: + p.scanSourceCharacter() + isPreviousTermQuantifiable = true + } + } +} + +func (p *regExpParser) scanPatternModifiers(currFlags RegularExpressionFlags) RegularExpressionFlags { + for p.pos() < p.end { + ch := p.charAt(p.pos()) + if !IsIdentifierPart(ch) { + break + } + flag, ok := CharacterToRegularExpressionFlag(ch) + if !ok { + p.error(diagnostics.Unknown_regular_expression_flag, p.pos(), 1) + } else if currFlags&flag != 0 { + p.error(diagnostics.Duplicate_regular_expression_flag, p.pos(), 1) + } else if flag&RegularExpressionFlagsModifiers == 0 { + p.error(diagnostics.This_regular_expression_flag_cannot_be_toggled_within_a_subpattern, p.pos(), 1) + } else { + currFlags |= flag + availableFrom := regExpFlagToFirstAvailableLanguageVersion[flag] + if p.scanner.languageVersion() < availableFrom { + p.error(diagnostics.This_regular_expression_flag_is_only_available_when_targeting_0_or_later, p.pos(), 1, GetNameOfScriptTarget(availableFrom)) + } + } + p.incPos(1) + } + return currFlags +} + +// AtomEscape ::= +// | DecimalEscape +// | CharacterClassEscape +// | CharacterEscape +// | 'k<' RegExpIdentifierName '>' +func (p *regExpParser) scanAtomEscape() { + switch p.charAt(p.pos()) { + case 'k': + p.incPos(1) + if p.charAt(p.pos()) == '<' { + p.incPos(1) + p.scanGroupName(true /*isReference*/) + p.scanExpectedChar('>') + } else if p.unicodeMode { + p.error(diagnostics.X_k_must_be_followed_by_a_capturing_group_name_enclosed_in_angle_brackets, p.pos()-2, 2) + } + case 'q': + if p.unicodeSetsMode { + p.incPos(1) + p.error(diagnostics.X_q_is_only_available_inside_character_class, p.pos()-2, 2) + return + } + fallthrough + default: + if !p.scanCharacterClassEscape() && !p.scanDecimalEscape() { + p.scanCharacterEscape(true /*atomEscape*/) + } + } +} + +// DecimalEscape ::= [1-9] [0-9]* +func (p *regExpParser) scanDecimalEscape() bool { + ch := p.charAt(p.pos()) + if ch >= '1' && ch <= '9' { + start := p.pos() + p.scanDigits() + val, _ := strconv.Atoi(p.scanner.tokenValue) + p.decimalEscapes = append(p.decimalEscapes, decimalEscapeValue{pos: start, end: p.pos(), value: val}) + return true + } + return false +} + +// CharacterEscape ::= +// | `c` ControlLetter +// | IdentityEscape +// | (Other sequences handled by `scanEscapeSequence`) +// IdentityEscape ::= +// | '^' | '$' | '/' | '\' | '.' | '*' | '+' | '?' | '(' | ')' | '[' | ']' | '{' | '}' | '|' +// | [~UnicodeMode] (any other non-identifier characters) +func (p *regExpParser) scanCharacterEscape(atomEscape bool) string { + ch := p.charAt(p.pos()) + switch ch { + case 'c': + p.incPos(1) + ch = p.charAt(p.pos()) + if stringutil.IsASCIILetter(ch) { + p.incPos(1) + return string(rune(ch & 0x1f)) + } + if p.unicodeMode { + p.error(diagnostics.X_c_must_be_followed_by_an_ASCII_letter, p.pos()-2, 2) + } + return string(ch) + case '^', '$', '/', '\\', '.', '*', '+', '?', '(', ')', '[', ']', '{', '}', '|': + p.incPos(1) + return string(ch) + default: + if p.pos() >= p.end { + p.error(diagnostics.Undetermined_character_escape, p.pos()-1, 1) + return "\\" + } + p.incPos(-1) // back up to include the backslash for scanEscapeSequence + flags := EscapeSequenceScanningFlagsRegularExpression | EscapeSequenceScanningFlagsAnnexB + if p.unicodeMode { + flags |= EscapeSequenceScanningFlagsReportErrors | EscapeSequenceScanningFlagsAnyUnicodeMode + } + if atomEscape { + flags |= EscapeSequenceScanningFlagsAtomEscape + } + return p.scanner.scanEscapeSequence(flags) + } +} + +func (p *regExpParser) scanGroupName(isReference bool) { + p.scanner.tokenStart = p.pos() + p.scanner.scanIdentifier(0) + if p.pos() == p.scanner.tokenStart { + p.error(diagnostics.Expected_a_capturing_group_name, p.pos(), 0) + } else if isReference { + p.groupNameReferences = append(p.groupNameReferences, groupNameReference{pos: p.scanner.tokenStart, end: p.pos(), name: p.scanner.tokenValue}) + } else if p.namedCapturingGroupsContains(p.scanner.tokenValue) { + p.error(diagnostics.Named_capturing_groups_with_the_same_name_must_be_mutually_exclusive_to_each_other, p.scanner.tokenStart, p.pos()-p.scanner.tokenStart) + } else { + if len(p.namedCapturingGroups) > 0 { + p.namedCapturingGroups[len(p.namedCapturingGroups)-1][p.scanner.tokenValue] = true + } + p.groupSpecifiers[p.scanner.tokenValue] = true + } +} + +func (p *regExpParser) namedCapturingGroupsContains(name string) bool { + for _, group := range p.namedCapturingGroups { + if group[name] { + return true + } + } + return false +} + +func (p *regExpParser) isClassContentExit(ch rune) bool { + return ch == ']' || p.pos() >= p.end +} + +// ClassRanges ::= '^'? (ClassAtom ('-' ClassAtom)?)* +func (p *regExpParser) scanClassRanges() { + if p.charAt(p.pos()) == '^' { + p.incPos(1) + } + for p.pos() < p.end { + ch := p.charAt(p.pos()) + if p.isClassContentExit(ch) { + return + } + minStart := p.pos() + minCharacter := p.scanClassAtom() + if p.charAt(p.pos()) == '-' { + p.incPos(1) + ch = p.charAt(p.pos()) + if p.isClassContentExit(ch) { + return + } + if minCharacter == "" { + p.error(diagnostics.A_character_class_range_must_not_be_bounded_by_another_character_class, minStart, p.pos()-1-minStart) + } + maxStart := p.pos() + maxCharacter := p.scanClassAtom() + if maxCharacter == "" { + p.error(diagnostics.A_character_class_range_must_not_be_bounded_by_another_character_class, maxStart, p.pos()-maxStart) + continue + } + if minCharacter == "" { + continue + } + minCharacterValue, minSize := utf8.DecodeRuneInString(minCharacter) + maxCharacterValue, maxSize := utf8.DecodeRuneInString(maxCharacter) + if len(minCharacter) == minSize && len(maxCharacter) == maxSize && minCharacterValue > maxCharacterValue { + p.error(diagnostics.Range_out_of_order_in_character_class, minStart, p.pos()-minStart) + } + } + } +} + +// ClassSetExpression ::= '^'? (ClassUnion | ClassIntersection | ClassSubtraction) +// ClassUnion ::= (ClassSetRange | ClassSetOperand)* +// ClassIntersection ::= ClassSetOperand ('&&' ClassSetOperand)+ +// ClassSubtraction ::= ClassSetOperand ('--' ClassSetOperand)+ +// ClassSetRange ::= ClassSetCharacter '-' ClassSetCharacter +func (p *regExpParser) scanClassSetExpression() { + isCharacterComplement := false + if p.charAt(p.pos()) == '^' { + p.incPos(1) + isCharacterComplement = true + } + expressionMayContainStrings := false + ch := p.charAt(p.pos()) + if p.isClassContentExit(ch) { + return + } + start := p.pos() + var operand string + twoChars := "" + if p.pos()+1 < p.end { + twoChars = p.text()[p.pos() : p.pos()+2] + } + switch twoChars { + case "--", "&&": + p.error(diagnostics.Expected_a_class_set_operand, p.pos(), 0) + p.mayContainStrings = false + default: + operand = p.scanClassSetOperand() + } + switch p.charAt(p.pos()) { + case '-': + if p.pos()+1 < p.end && p.charAt(p.pos()+1) == '-' { + if isCharacterComplement && p.mayContainStrings { + p.error(diagnostics.Anything_that_would_possibly_match_more_than_a_single_character_is_invalid_inside_a_negated_character_class, start, p.pos()-start) + } + expressionMayContainStrings = p.mayContainStrings + p.scanClassSetSubExpression(classSetExpressionTypeClassSubtraction) + p.mayContainStrings = !isCharacterComplement && expressionMayContainStrings + return + } + case '&': + if p.pos()+1 < p.end && p.charAt(p.pos()+1) == '&' { + p.scanClassSetSubExpression(classSetExpressionTypeClassIntersection) + if isCharacterComplement && p.mayContainStrings { + p.error(diagnostics.Anything_that_would_possibly_match_more_than_a_single_character_is_invalid_inside_a_negated_character_class, start, p.pos()-start) + } + expressionMayContainStrings = p.mayContainStrings + p.mayContainStrings = !isCharacterComplement && expressionMayContainStrings + return + } else { + p.error(diagnostics.Unexpected_0_Did_you_mean_to_escape_it_with_backslash, p.pos(), 1, string(ch)) + } + default: + if isCharacterComplement && p.mayContainStrings { + p.error(diagnostics.Anything_that_would_possibly_match_more_than_a_single_character_is_invalid_inside_a_negated_character_class, start, p.pos()-start) + } + expressionMayContainStrings = p.mayContainStrings + } + for p.pos() < p.end { + ch = p.charAt(p.pos()) + switch ch { + case '-': + p.incPos(1) + ch = p.charAt(p.pos()) + if p.isClassContentExit(ch) { + p.mayContainStrings = !isCharacterComplement && expressionMayContainStrings + return + } + if ch == '-' { + p.incPos(1) + p.error(diagnostics.Operators_must_not_be_mixed_within_a_character_class_Wrap_it_in_a_nested_class_instead, p.pos()-2, 2) + start = p.pos() - 2 + operand = p.text()[start:p.pos()] + continue + } else { + if operand == "" { + p.error(diagnostics.A_character_class_range_must_not_be_bounded_by_another_character_class, start, p.pos()-1-start) + } + secondStart := p.pos() + secondOperand := p.scanClassSetOperand() + if isCharacterComplement && p.mayContainStrings { + p.error(diagnostics.Anything_that_would_possibly_match_more_than_a_single_character_is_invalid_inside_a_negated_character_class, secondStart, p.pos()-secondStart) + } + expressionMayContainStrings = expressionMayContainStrings || p.mayContainStrings + if secondOperand == "" { + p.error(diagnostics.A_character_class_range_must_not_be_bounded_by_another_character_class, secondStart, p.pos()-secondStart) + } else if operand != "" { + minCharacterValue, minSize := utf8.DecodeRuneInString(operand) + maxCharacterValue, maxSize := utf8.DecodeRuneInString(secondOperand) + if len(operand) == minSize && len(secondOperand) == maxSize && minCharacterValue > maxCharacterValue { + p.error(diagnostics.Range_out_of_order_in_character_class, start, p.pos()-start) + } + } + } + case '&': + start = p.pos() + p.incPos(1) + if p.charAt(p.pos()) == '&' { + p.incPos(1) + p.error(diagnostics.Operators_must_not_be_mixed_within_a_character_class_Wrap_it_in_a_nested_class_instead, p.pos()-2, 2) + if p.charAt(p.pos()) == '&' { + p.error(diagnostics.Unexpected_0_Did_you_mean_to_escape_it_with_backslash, p.pos(), 1, string(ch)) + p.incPos(1) + } + } else { + p.error(diagnostics.Unexpected_0_Did_you_mean_to_escape_it_with_backslash, p.pos()-1, 1, string(ch)) + } + operand = p.text()[start:p.pos()] + continue + } + if p.isClassContentExit(p.charAt(p.pos())) { + break + } + start = p.pos() + twoChars = "" + if p.pos()+1 < p.end { + twoChars = p.text()[p.pos() : p.pos()+2] + } + switch twoChars { + case "--", "&&": + p.error(diagnostics.Operators_must_not_be_mixed_within_a_character_class_Wrap_it_in_a_nested_class_instead, p.pos(), 2) + p.incPos(2) + operand = p.text()[start:p.pos()] + default: + operand = p.scanClassSetOperand() + } + } + p.mayContainStrings = !isCharacterComplement && expressionMayContainStrings +} + +func (p *regExpParser) scanClassSetSubExpression(expressionType classSetExpressionType) { + expressionMayContainStrings := p.mayContainStrings + for p.pos() < p.end { + ch := p.charAt(p.pos()) + if p.isClassContentExit(ch) { + break + } + switch ch { + case '-': + p.incPos(1) + if p.charAt(p.pos()) == '-' { + p.incPos(1) + if expressionType != classSetExpressionTypeClassSubtraction { + p.error(diagnostics.Operators_must_not_be_mixed_within_a_character_class_Wrap_it_in_a_nested_class_instead, p.pos()-2, 2) + } + } else { + p.error(diagnostics.Operators_must_not_be_mixed_within_a_character_class_Wrap_it_in_a_nested_class_instead, p.pos()-1, 1) + } + case '&': + p.incPos(1) + if p.charAt(p.pos()) == '&' { + p.incPos(1) + if expressionType != classSetExpressionTypeClassIntersection { + p.error(diagnostics.Operators_must_not_be_mixed_within_a_character_class_Wrap_it_in_a_nested_class_instead, p.pos()-2, 2) + } + if p.charAt(p.pos()) == '&' { + p.error(diagnostics.Unexpected_0_Did_you_mean_to_escape_it_with_backslash, p.pos(), 1, string(ch)) + p.incPos(1) + } + } else { + p.error(diagnostics.Unexpected_0_Did_you_mean_to_escape_it_with_backslash, p.pos()-1, 1, string(ch)) + } + default: + switch expressionType { + case classSetExpressionTypeClassSubtraction: + p.error(diagnostics.X_0_expected, p.pos(), 0, "--") + case classSetExpressionTypeClassIntersection: + p.error(diagnostics.X_0_expected, p.pos(), 0, "&&") + } + } + ch = p.charAt(p.pos()) + if p.isClassContentExit(ch) { + p.error(diagnostics.Expected_a_class_set_operand, p.pos(), 0) + break + } + p.scanClassSetOperand() + if expressionType == classSetExpressionTypeClassIntersection { + expressionMayContainStrings = expressionMayContainStrings && p.mayContainStrings + } + } + p.mayContainStrings = expressionMayContainStrings +} + +// ClassSetOperand ::= +// | '[' ClassSetExpression ']' +// | '\' CharacterClassEscape +// | '\q{' ClassStringDisjunctionContents '}' +// | ClassSetCharacter +func (p *regExpParser) scanClassSetOperand() string { + p.mayContainStrings = false + switch p.charAt(p.pos()) { + case '[': + p.incPos(1) + p.scanClassSetExpression() + p.scanExpectedChar(']') + return "" + case '\\': + p.incPos(1) + if p.scanCharacterClassEscape() { + return "" + } else if p.charAt(p.pos()) == 'q' { + p.incPos(1) + if p.charAt(p.pos()) == '{' { + p.incPos(1) + p.scanClassStringDisjunctionContents() + p.scanExpectedChar('}') + return "" + } else { + p.error(diagnostics.X_q_must_be_followed_by_string_alternatives_enclosed_in_braces, p.pos()-2, 2) + return "q" + } + } + p.incPos(-1) + fallthrough + default: + return p.scanClassSetCharacter() + } +} + +// ClassStringDisjunctionContents ::= ClassSetCharacter* ('|' ClassSetCharacter*)* +func (p *regExpParser) scanClassStringDisjunctionContents() { + characterCount := 0 + for p.pos() < p.end { + ch := p.charAt(p.pos()) + switch ch { + case '}': + if characterCount != 1 { + p.mayContainStrings = true + } + return + case '|': + if characterCount != 1 { + p.mayContainStrings = true + } + p.incPos(1) + characterCount = 0 + default: + p.scanClassSetCharacter() + characterCount++ + } + } +} + +// ClassSetCharacter ::= +// | SourceCharacter -- ClassSetSyntaxCharacter -- ClassSetReservedDoublePunctuator +// | '\' (CharacterEscape | ClassSetReservedPunctuator | 'b') +func (p *regExpParser) scanClassSetCharacter() string { + ch := p.charAt(p.pos()) + if ch == '\\' { + p.incPos(1) + innerCh := p.charAt(p.pos()) + switch innerCh { + case 'b': + p.incPos(1) + return "\b" + case '&', '-', '!', '#', '%', ',', ':', ';', '<', '=', '>', '@', '`', '~': + p.incPos(1) + return string(innerCh) + default: + return p.scanCharacterEscape(false /*atomEscape*/) + } + } else if p.pos()+1 < p.end && ch == rune(p.scanner.text[p.pos()+1]) { + switch ch { + case '&', '!', '#', '%', '*', '+', ',', '.', ':', ';', '<', '=', '>', '?', '@', '`', '~': + p.error(diagnostics.A_character_class_must_not_contain_a_reserved_double_punctuator_Did_you_mean_to_escape_it_with_backslash, p.pos(), 2) + p.incPos(2) + return p.text()[p.pos()-2 : p.pos()] + } + } + switch ch { + case '/', '(', ')', '[', ']', '{', '}', '-', '|': + p.error(diagnostics.Unexpected_0_Did_you_mean_to_escape_it_with_backslash, p.pos(), 1, string(ch)) + p.incPos(1) + return string(ch) + } + return p.scanSourceCharacter() +} + +// ClassAtom ::= +// | SourceCharacter but not one of '\' or ']' +// | '\' ClassEscape +// ClassEscape ::= +// | 'b' +// | '-' +// | CharacterClassEscape +// | CharacterEscape +func (p *regExpParser) scanClassAtom() string { + if p.charAt(p.pos()) == '\\' { + p.incPos(1) + ch := p.charAt(p.pos()) + switch ch { + case 'b': + p.incPos(1) + return "\b" + case '-': + p.incPos(1) + return string(ch) + default: + if p.scanCharacterClassEscape() { + return "" + } + return p.scanCharacterEscape(false /*atomEscape*/) + } + } else { + return p.scanSourceCharacter() + } +} + +// CharacterClassEscape ::= +// | 'd' | 'D' | 's' | 'S' | 'w' | 'W' +// | [+UnicodeMode] ('P' | 'p') '{' UnicodePropertyValueExpression '}' +func (p *regExpParser) scanCharacterClassEscape() bool { + isCharacterComplement := false + start := p.pos() - 1 + ch := p.charAt(p.pos()) + switch ch { + case 'd', 'D', 's', 'S', 'w', 'W': + p.incPos(1) + return true + case 'P': + isCharacterComplement = true + fallthrough + case 'p': + p.incPos(1) + if p.charAt(p.pos()) == '{' { + p.incPos(1) + propertyNameOrValueStart := p.pos() + propertyNameOrValue := p.scanWordCharacters() + if p.charAt(p.pos()) == '=' { + propertyName := nonBinaryUnicodeProperties[propertyNameOrValue] + if p.pos() == propertyNameOrValueStart { + p.error(diagnostics.Expected_a_Unicode_property_name, p.pos(), 0) + } else if propertyName == "" { + p.error(diagnostics.Unknown_Unicode_property_name, propertyNameOrValueStart, p.pos()-propertyNameOrValueStart) + suggestion := p.getSpellingSuggestionForUnicodePropertyName(propertyNameOrValue) + if suggestion != "" { + p.error(diagnostics.Did_you_mean_0, propertyNameOrValueStart, p.pos()-propertyNameOrValueStart, suggestion) + } + } + p.incPos(1) + propertyValueStart := p.pos() + propertyValue := p.scanWordCharacters() + if p.pos() == propertyValueStart { + p.error(diagnostics.Expected_a_Unicode_property_value, p.pos(), 0) + } else if propertyName != "" { + values := valuesOfNonBinaryUnicodeProperties[propertyName] + if values != nil && !values[propertyValue] { + p.error(diagnostics.Unknown_Unicode_property_value, propertyValueStart, p.pos()-propertyValueStart) + suggestion := p.getSpellingSuggestionForUnicodePropertyValue(propertyName, propertyValue) + if suggestion != "" { + p.error(diagnostics.Did_you_mean_0, propertyValueStart, p.pos()-propertyValueStart, suggestion) + } + } + } + } else { + if p.pos() == propertyNameOrValueStart { + p.error(diagnostics.Expected_a_Unicode_property_name_or_value, p.pos(), 0) + } else if binaryUnicodePropertiesOfStrings[propertyNameOrValue] { + if !p.unicodeSetsMode { + p.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, p.pos()-propertyNameOrValueStart) + } else if isCharacterComplement { + p.error(diagnostics.Anything_that_would_possibly_match_more_than_a_single_character_is_invalid_inside_a_negated_character_class, propertyNameOrValueStart, p.pos()-propertyNameOrValueStart) + } else { + p.mayContainStrings = true + } + } else if !valuesOfNonBinaryUnicodeProperties["General_Category"][propertyNameOrValue] && !binaryUnicodeProperties[propertyNameOrValue] { + p.error(diagnostics.Unknown_Unicode_property_name_or_value, propertyNameOrValueStart, p.pos()-propertyNameOrValueStart) + suggestion := p.getSpellingSuggestionForUnicodePropertyNameOrValue(propertyNameOrValue) + if suggestion != "" { + p.error(diagnostics.Did_you_mean_0, propertyNameOrValueStart, p.pos()-propertyNameOrValueStart, suggestion) + } + } + } + p.scanExpectedChar('}') + if !p.unicodeMode { + p.error(diagnostics.Unicode_property_value_expressions_are_only_available_when_the_Unicode_u_flag_or_the_Unicode_Sets_v_flag_is_set, start, p.pos()-start) + } + } else if p.unicodeMode { + p.error(diagnostics.X_0_must_be_followed_by_a_Unicode_property_value_expression_enclosed_in_braces, p.pos()-2, 2, string(ch)) + } + return true + } + return false +} + +func (p *regExpParser) getSpellingSuggestionForUnicodePropertyName(name string) string { + candidates := make([]string, 0, len(nonBinaryUnicodeProperties)) + for k := range nonBinaryUnicodeProperties { + candidates = append(candidates, k) + } + return core.GetSpellingSuggestion(name, candidates, func(s string) string { return s }) +} + +func (p *regExpParser) getSpellingSuggestionForUnicodePropertyValue(propertyName string, value string) string { + values := valuesOfNonBinaryUnicodeProperties[propertyName] + if values == nil { + return "" + } + candidates := make([]string, 0, len(values)) + for k := range values { + candidates = append(candidates, k) + } + return core.GetSpellingSuggestion(value, candidates, func(s string) string { return s }) +} + +func (p *regExpParser) getSpellingSuggestionForUnicodePropertyNameOrValue(name string) string { + var candidates []string + for k := range valuesOfNonBinaryUnicodeProperties["General_Category"] { + candidates = append(candidates, k) + } + for k := range binaryUnicodeProperties { + candidates = append(candidates, k) + } + for k := range binaryUnicodePropertiesOfStrings { + candidates = append(candidates, k) + } + return core.GetSpellingSuggestion(name, candidates, func(s string) string { return s }) +} + +func (p *regExpParser) scanWordCharacters() string { + start := p.pos() + for p.pos() < p.end { + ch := p.charAt(p.pos()) + if !isWordCharacter(ch) { + break + } + p.incPos(1) + } + return p.text()[start:p.pos()] +} + +func (p *regExpParser) scanSourceCharacter() string { + if p.unicodeMode { + ch, size := utf8.DecodeRuneInString(p.text()[p.pos():]) + if size == 0 || ch == utf8.RuneError { + return "" + } + p.incPos(size) + return string(ch) + } + if p.pos() < p.end { + ch := p.text()[p.pos()] + p.incPos(1) + return string(ch) + } + return "" +} + +func (p *regExpParser) scanExpectedChar(ch rune) { + if p.charAt(p.pos()) == ch { + p.incPos(1) + } else { + p.error(diagnostics.X_0_expected, p.pos(), 0, string(ch)) + } +} + +func (p *regExpParser) scanDigits() { + start := p.pos() + for p.pos() < p.end && stringutil.IsDigit(p.charAt(p.pos())) { + p.incPos(1) + } + p.scanner.tokenValue = p.text()[start:p.pos()] +} + +func (p *regExpParser) run() { + p.scanDisjunction(false /*isInGroup*/) + + for _, reference := range p.groupNameReferences { + if !p.groupSpecifiers[reference.name] { + p.error(diagnostics.There_is_no_capturing_group_named_0_in_this_regular_expression, reference.pos, reference.end-reference.pos, reference.name) + if len(p.groupSpecifiers) > 0 { + specifiers := make([]string, 0, len(p.groupSpecifiers)) + for k := range p.groupSpecifiers { + specifiers = append(specifiers, k) + } + suggestion := core.GetSpellingSuggestion(reference.name, specifiers, func(s string) string { return s }) + if suggestion != "" { + p.error(diagnostics.Did_you_mean_0, reference.pos, reference.end-reference.pos, suggestion) + } + } + } + } + for _, escape := range p.decimalEscapes { + if escape.value > p.numberOfCapturingGroups { + if p.numberOfCapturingGroups > 0 { + p.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, p.numberOfCapturingGroups) + } else { + p.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 GetNameOfScriptTarget(target core.ScriptTarget) string { + switch target { + case core.ScriptTargetES5: + return "es5" + case core.ScriptTargetES2015: + return "es2015" + case core.ScriptTargetES2016: + return "es2016" + case core.ScriptTargetES2017: + return "es2017" + case core.ScriptTargetES2018: + return "es2018" + case core.ScriptTargetES2019: + return "es2019" + case core.ScriptTargetES2020: + return "es2020" + case core.ScriptTargetES2021: + return "es2021" + case core.ScriptTargetES2022: + return "es2022" + case core.ScriptTargetES2023: + return "es2023" + case core.ScriptTargetES2024: + return "es2024" + case core.ScriptTargetESNext: + return "esnext" + default: + return "" + } +} diff --git a/internal/scanner/scanner.go b/internal/scanner/scanner.go index 623a2eff141..f8428f1fec1 100644 --- a/internal/scanner/scanner.go +++ b/internal/scanner/scanner.go @@ -212,6 +212,7 @@ type ScannerState struct { type Scanner struct { text string languageVariant core.LanguageVariant + scriptTarget core.ScriptTarget onError ErrorCallback skipTrivia bool scriptKind core.ScriptKind @@ -418,6 +419,17 @@ func (s *Scanner) SetLanguageVariant(languageVariant core.LanguageVariant) { s.languageVariant = languageVariant } +func (s *Scanner) SetScriptTarget(scriptTarget core.ScriptTarget) { + s.scriptTarget = scriptTarget +} + +func (s *Scanner) languageVersion() core.ScriptTarget { + if s.scriptTarget == core.ScriptTargetNone { + return core.ScriptTargetLatest + } + return s.scriptTarget +} + func (s *Scanner) error(diagnostic *diagnostics.Message) { s.errorAt(diagnostic, s.pos, 0) } @@ -1034,50 +1046,58 @@ func (s *Scanner) ReScanAsteriskEqualsToken() ast.Kind { return s.token } -// !!! https://github.com/microsoft/TypeScript/pull/55600 func (s *Scanner) ReScanSlashToken() ast.Kind { if s.token == ast.KindSlashToken || s.token == ast.KindSlashEqualsToken { - s.pos = s.tokenStart + 1 - startOfRegExpBody := s.pos + // Quickly get to the end of regex such that we know the flags + startOfRegExpBody := s.tokenStart + 1 + p := startOfRegExpBody inEscape := false + // Although nested character classes are allowed in Unicode Sets mode, + // an unescaped slash is nevertheless invalid even in a character class in Unicode mode. + // Additionally, parsing nested character classes will misinterpret regexes like `/[[]/` + // as unterminated, consuming characters beyond the slash. (This even applies to `/[[]/v`, + // which should be parsed as a well-terminated regex with an incomplete character class.) + // Thus we must not handle nested character classes in the first pass. inCharacterClass := false loop: for { - ch, size := s.charAndSize() - // If we reach the end of a file, or hit a newline, then this is an unterminated - // regex. Report error and return what we have so far. - switch { - case size == 0 || stringutil.IsLineBreak(ch): + if p >= len(s.text) { s.tokenFlags |= ast.TokenFlagsUnterminated break loop - case inEscape: - // Parsing an escape character; - // reset the flag and just advance to the next char. + } + ch := rune(s.text[p]) + if stringutil.IsLineBreak(ch) { + s.tokenFlags |= ast.TokenFlagsUnterminated + break loop + } + if inEscape { inEscape = false - case ch == '/' && !inCharacterClass: - // A slash within a character class is permissible, - // but in general it signals the end of the regexp literal. + } else if ch == '/' && !inCharacterClass { break loop - case ch == '[': + } else if ch == '[' { inCharacterClass = true - case ch == '\\': + } else if ch == '\\' { inEscape = true - case ch == ']': + } else if ch == ']' { inCharacterClass = false } - s.pos += size + p++ } - if s.tokenFlags&ast.TokenFlagsUnterminated != 0 { - // Search for the nearest unbalanced bracket for better recovery. Since the expression is - // invalid anyways, we take nested square brackets into consideration for the best guess. - endOfRegExpBody := s.pos - s.pos = startOfRegExpBody + + isUnterminated := s.tokenFlags&ast.TokenFlagsUnterminated != 0 + endOfBody := p + var regExpFlags RegularExpressionFlags + + if isUnterminated { + // Search for the nearest unbalanced bracket for better recovery + endOfScan := p + p = startOfRegExpBody inEscape = false characterClassDepth := 0 inDecimalQuantifier := false groupDepth := 0 - for s.pos < endOfRegExpBody { - ch, size := s.charAndSize() + for p < endOfScan { + ch := rune(s.text[p]) if inEscape { inEscape = false } else if ch == '\\' { @@ -1097,34 +1117,66 @@ func (s *Scanner) ReScanSlashToken() ast.Kind { } else if ch == ')' && groupDepth != 0 { groupDepth-- } else if ch == ')' || ch == ']' || ch == '}' { - // We encountered an unbalanced bracket outside a character class. Treat this position as the end of regex. break } } } - s.pos += size + p++ } - // Whitespaces and semicolons at the end are not likely to be part of the regex - for { - ch, size := utf8.DecodeLastRuneInString(s.text[:s.pos]) + for p > startOfRegExpBody { + ch, size := utf8.DecodeLastRuneInString(s.text[:p]) if stringutil.IsWhiteSpaceLike(ch) || ch == ';' { - s.pos -= size + p -= size } else { break } } - s.errorAt(diagnostics.Unterminated_regular_expression_literal, s.tokenStart, s.pos-s.tokenStart) + endOfBody = p + s.errorAt(diagnostics.Unterminated_regular_expression_literal, s.tokenStart, p-s.tokenStart) } else { - // Consume the slash character - s.pos++ - for { - ch, size := s.charAndSize() - if size == 0 || !IsIdentifierPart(ch) { + // Skip past the closing '/' + p++ + // Scan and validate flags + for p < len(s.text) { + ch, size := utf8.DecodeRuneInString(s.text[p:]) + if !IsIdentifierPart(ch) { break } - s.pos += size + flag, ok := CharacterToRegularExpressionFlag(ch) + if !ok { + s.errorAt(diagnostics.Unknown_regular_expression_flag, p, size) + } else if regExpFlags&flag != 0 { + s.errorAt(diagnostics.Duplicate_regular_expression_flag, p, size) + } else if (regExpFlags|flag)&RegularExpressionFlagsUnicodeMode == RegularExpressionFlagsUnicodeMode { + s.errorAt(diagnostics.The_Unicode_u_flag_and_the_Unicode_Sets_v_flag_cannot_be_set_simultaneously, p, size) + } else { + regExpFlags |= flag + availableFrom := regExpFlagToFirstAvailableLanguageVersion[flag] + if s.languageVersion() < availableFrom { + s.errorAt(diagnostics.This_regular_expression_flag_is_only_available_when_targeting_0_or_later, p, size, GetNameOfScriptTarget(availableFrom)) + } + } + p += size } } + + s.pos = startOfRegExpBody + saveTokenPos := s.tokenStart + saveTokenFlags := s.tokenFlags + parser := ®ExpParser{ + scanner: s, + end: endOfBody, + regExpFlags: regExpFlags, + isUnterminated: isUnterminated, + unicodeMode: regExpFlags&RegularExpressionFlagsUnicodeMode != 0, + unicodeSetsMode: regExpFlags&RegularExpressionFlagsUnicodeSets != 0, + groupSpecifiers: make(map[string]bool), + } + parser.run() + s.tokenStart = saveTokenPos + s.tokenFlags = saveTokenFlags + + s.pos = p s.tokenValue = s.text[s.tokenStart:s.pos] s.token = ast.KindRegularExpressionLiteral } @@ -1629,7 +1681,7 @@ func (s *Scanner) scanEscapeSequence(flags EscapeSequenceScanningFlags) string { if flags&EscapeSequenceScanningFlagsReportInvalidEscapeErrors != 0 { code, _ := strconv.ParseInt(s.text[start+1:s.pos], 8, 32) if flags&EscapeSequenceScanningFlagsRegularExpression != 0 && flags&EscapeSequenceScanningFlagsAtomEscape == 0 && ch != '0' { - s.errorAt(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, s.pos-start, fmt.Sprintf("%02x", code)) + s.errorAt(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, s.pos-start, "\\x"+fmt.Sprintf("%02x", code)) } else { s.errorAt(diagnostics.Octal_escape_sequences_are_not_allowed_Use_the_syntax_0, start, s.pos-start, "\\x"+fmt.Sprintf("%02x", code)) } @@ -1735,21 +1787,26 @@ func (s *Scanner) scanUnicodeEscape(shouldEmitInvalidEscapeError bool) rune { } hexValue, _ := strconv.ParseInt(hexDigits, 16, 32) if extended { + isInvalidExtendedEscape := false if hexValue > 0x10FFFF { s.tokenFlags |= ast.TokenFlagsContainsInvalidEscape if shouldEmitInvalidEscapeError { s.errorAt(diagnostics.An_extended_Unicode_escape_value_must_be_between_0x0_and_0x10FFFF_inclusive, start+1, s.pos-start-1) } - return -1 + isInvalidExtendedEscape = true } - if s.char() != '}' { + if s.char() == '}' { + s.pos++ + } else { s.tokenFlags |= ast.TokenFlagsContainsInvalidEscape if shouldEmitInvalidEscapeError { s.error(diagnostics.Unterminated_Unicode_escape_sequence) } + isInvalidExtendedEscape = true + } + if isInvalidExtendedEscape { return -1 } - s.pos++ } return rune(hexValue) } diff --git a/internal/scanner/unicodeproperties.go b/internal/scanner/unicodeproperties.go new file mode 100644 index 00000000000..9de4786e745 --- /dev/null +++ b/internal/scanner/unicodeproperties.go @@ -0,0 +1,166 @@ +package scanner + +// Table 66: Non-binary Unicode property aliases and their canonical property names +// https://tc39.es/ecma262/#table-nonbinary-unicode-properties +var nonBinaryUnicodeProperties = map[string]string{ + "General_Category": "General_Category", + "gc": "General_Category", + "Script": "Script", + "sc": "Script", + "Script_Extensions": "Script_Extensions", + "scx": "Script_Extensions", +} + +// Table 67: Binary Unicode property aliases and their canonical property names +// https://tc39.es/ecma262/#table-binary-unicode-properties +var binaryUnicodeProperties = newStringSet( + "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 = newStringSet( + "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 +var valuesOfNonBinaryUnicodeProperties = map[string]map[string]bool{ + "General_Category": newStringSet( + "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", + ), + "Script": newStringSet( + "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", + ), + "Script_Extensions": nil, // set to Script values in init() +} + +func init() { + valuesOfNonBinaryUnicodeProperties["Script_Extensions"] = valuesOfNonBinaryUnicodeProperties["Script"] +} + +func newStringSet(values ...string) map[string]bool { + m := make(map[string]bool, len(values)) + for _, v := range values { + m[v] = true + } + return m +} 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 00000000000..fb5540bc6ba --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/regExpWithOpenBracketInCharClass(target=es2015).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=es2015).errors.txt.diff b/testdata/baselines/reference/submodule/compiler/regExpWithOpenBracketInCharClass(target=es2015).errors.txt.diff index 2b831805329..a9778523c99 100644 --- a/testdata/baselines/reference/submodule/compiler/regExpWithOpenBracketInCharClass(target=es2015).errors.txt.diff +++ b/testdata/baselines/reference/submodule/compiler/regExpWithOpenBracketInCharClass(target=es2015).errors.txt.diff @@ -1,19 +1,21 @@ --- 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,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. ++ ++ ++==== regExpWithOpenBracketInCharClass.ts (1 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 + ]; + \ 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 00000000000..fb5540bc6ba --- /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 52ebf56baa6..00000000000 --- 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 00000000000..0c3852afade --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/regularExpressionAnnexB.errors.txt @@ -0,0 +1,341 @@ +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(4,9): error TS1516: A character class range must not be bounded by another character class. +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(15,4): error TS1507: There is nothing available for repetition. +regularExpressionAnnexB.ts(15,5): error TS1505: Incomplete quantifier. Digit expected. +regularExpressionAnnexB.ts(15,7): error TS1005: '}' expected. +regularExpressionAnnexB.ts(15,8): error TS1507: There is nothing available for repetition. +regularExpressionAnnexB.ts(16,4): error TS1507: There is nothing available for repetition. +regularExpressionAnnexB.ts(16,6): error TS1005: '}' expected. +regularExpressionAnnexB.ts(16,7): error TS1507: There is nothing available for repetition. +regularExpressionAnnexB.ts(17,4): error TS1507: There is nothing available for repetition. +regularExpressionAnnexB.ts(17,7): error TS1005: '}' expected. +regularExpressionAnnexB.ts(17,8): error TS1507: There is nothing available for repetition. +regularExpressionAnnexB.ts(18,4): error TS1507: There is nothing available for repetition. +regularExpressionAnnexB.ts(18,8): error TS1005: '}' expected. +regularExpressionAnnexB.ts(18,9): error TS1507: There is nothing available for repetition. +regularExpressionAnnexB.ts(19,4): error TS1507: There is nothing available for repetition. +regularExpressionAnnexB.ts(19,5): error TS1506: Numbers out of order in quantifier. +regularExpressionAnnexB.ts(19,8): error TS1005: '}' expected. +regularExpressionAnnexB.ts(19,9): error TS1507: There is nothing available for repetition. +regularExpressionAnnexB.ts(21,4): error TS1507: There is nothing available for repetition. +regularExpressionAnnexB.ts(21,5): error TS1505: Incomplete quantifier. Digit expected. +regularExpressionAnnexB.ts(21,8): error TS1507: There is nothing available for repetition. +regularExpressionAnnexB.ts(22,4): error TS1507: There is nothing available for repetition. +regularExpressionAnnexB.ts(22,5): error TS1505: Incomplete quantifier. Digit expected. +regularExpressionAnnexB.ts(22,9): error TS1507: There is nothing available for repetition. +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 (98 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-_]/, + ~~ +!!! error TS1516: A character class range must not be bounded by another character class. + + // 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??/, + ~~~~ +!!! 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??/, + ~~~ +!!! error TS1507: There is nothing available for repetition. + +!!! error TS1005: '}' expected. + ~ +!!! error TS1507: There is nothing available for repetition. + /{1,??/, + ~~~~ +!!! error TS1507: There is nothing available for repetition. + +!!! error TS1005: '}' expected. + ~ +!!! error TS1507: There is nothing available for repetition. + /{1,2??/, + ~~~~~ +!!! error TS1507: There is nothing available for repetition. + +!!! error TS1005: '}' expected. + ~ +!!! 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 TS1005: '}' expected. + ~ +!!! error TS1507: There is nothing available for repetition. + /{}??/, + /{,}??/, + ~~~~ +!!! error TS1507: There is nothing available for repetition. + +!!! error TS1505: Incomplete quantifier. Digit expected. + ~ +!!! error TS1507: There is nothing available for repetition. + /{,1}??/, + ~~~~~ +!!! error TS1507: There is nothing available for repetition. + +!!! error TS1505: Incomplete quantifier. Digit expected. + ~ +!!! 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,}??/, + ~~~~~ +!!! 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 index fa48818b0d5..433267a2060 100644 --- a/testdata/baselines/reference/submodule/compiler/regularExpressionAnnexB.errors.txt.diff +++ b/testdata/baselines/reference/submodule/compiler/regularExpressionAnnexB.errors.txt.diff @@ -1,273 +1,118 @@ --- 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. -- -- +@@= skipped -3, +3 lines =@@ + 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(4,9): error TS1516: A character class range must not be bounded by another character class. + 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. +@@= skipped -23, +24 lines =@@ + 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(15,4): error TS1507: There is nothing available for repetition. ++regularExpressionAnnexB.ts(15,5): error TS1505: Incomplete quantifier. Digit expected. ++regularExpressionAnnexB.ts(15,7): error TS1005: '}' expected. ++regularExpressionAnnexB.ts(15,8): error TS1507: There is nothing available for repetition. ++regularExpressionAnnexB.ts(16,4): error TS1507: There is nothing available for repetition. ++regularExpressionAnnexB.ts(16,6): error TS1005: '}' expected. ++regularExpressionAnnexB.ts(16,7): error TS1507: There is nothing available for repetition. ++regularExpressionAnnexB.ts(17,4): error TS1507: There is nothing available for repetition. ++regularExpressionAnnexB.ts(17,7): error TS1005: '}' expected. ++regularExpressionAnnexB.ts(17,8): error TS1507: There is nothing available for repetition. ++regularExpressionAnnexB.ts(18,4): error TS1507: There is nothing available for repetition. ++regularExpressionAnnexB.ts(18,8): error TS1005: '}' expected. ++regularExpressionAnnexB.ts(18,9): error TS1507: There is nothing available for repetition. ++regularExpressionAnnexB.ts(19,4): error TS1507: There is nothing available for repetition. ++regularExpressionAnnexB.ts(19,5): error TS1506: Numbers out of order in quantifier. ++regularExpressionAnnexB.ts(19,8): error TS1005: '}' expected. ++regularExpressionAnnexB.ts(19,9): error TS1507: There is nothing available for repetition. ++regularExpressionAnnexB.ts(21,4): error TS1507: There is nothing available for repetition. ++regularExpressionAnnexB.ts(21,5): error TS1505: Incomplete quantifier. Digit expected. ++regularExpressionAnnexB.ts(21,8): error TS1507: There is nothing available for repetition. ++regularExpressionAnnexB.ts(22,4): error TS1507: There is nothing available for repetition. ++regularExpressionAnnexB.ts(22,5): error TS1505: Incomplete quantifier. Digit expected. ++regularExpressionAnnexB.ts(22,9): error TS1507: There is nothing available for repetition. + 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. +@@= skipped -47, +70 lines =@@ + 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 ++==== regularExpressionAnnexB.ts (98 errors) ==== + const regexes: RegExp[] = [ + /\q\u\i\c\k\_\f\o\x\-\j\u\m\p\s/, + +@@= skipped -17, +17 lines =@@ + + !!! error TS1125: Hexadecimal digit expected. + /\P[\P\w-_]/, ++ ~~ ++!!! error TS1516: A character class range must not be bounded by another character class. + + // Compare to + /\q\u\i\c\k\_\f\o\x\-\j\u\m\p\s/u, +@@= skipped -57, +59 lines =@@ + /{??/, + /{,??/, + /{,1??/, ++ ~~~~ ++!!! 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??/, ++ ~~~ ++!!! error TS1507: There is nothing available for repetition. ++ ++!!! error TS1005: '}' expected. ++ ~ ++!!! error TS1507: There is nothing available for repetition. + /{1,??/, ++ ~~~~ ++!!! error TS1507: There is nothing available for repetition. ++ ++!!! error TS1005: '}' expected. ++ ~ ++!!! error TS1507: There is nothing available for repetition. + /{1,2??/, ++ ~~~~~ ++!!! error TS1507: There is nothing available for repetition. ++ ++!!! error TS1005: '}' expected. ++ ~ ++!!! 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 TS1005: '}' expected. ++ ~ ++!!! error TS1507: There is nothing available for repetition. + /{}??/, + /{,}??/, ++ ~~~~ ++!!! error TS1507: There is nothing available for repetition. ++ ++!!! error TS1505: Incomplete quantifier. Digit expected. ++ ~ ++!!! error TS1507: There is nothing available for repetition. + /{,1}??/, ++ ~~~~~ ++!!! error TS1507: There is nothing available for repetition. ++ ++!!! error TS1505: Incomplete quantifier. Digit expected. ++ ~ ++!!! error TS1507: There is nothing available for repetition. + /{1}??/, + ~~~~ + !!! 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 00000000000..4a0b74ec925 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/regularExpressionCharacterClassRangeOrder.errors.txt @@ -0,0 +1,46 @@ +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,25): error TS1517: Range out of order in character class. +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,31): 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 (8 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, + ~~~ +!!! 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}]/, + ~~~~~~~~~~~~~~~~~~~ +!!! error TS1517: Range out of order in character class. + /[\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. + /[\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 09a02fe00bf..fa863fcd662 100644 --- a/testdata/baselines/reference/submodule/compiler/regularExpressionCharacterClassRangeOrder.errors.txt.diff +++ b/testdata/baselines/reference/submodule/compiler/regularExpressionCharacterClassRangeOrder.errors.txt.diff @@ -8,64 +8,63 @@ -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(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,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(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(15,31): 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 (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 (8 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, +15 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, ++ ~~~ + !!! 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}]/, ++ ~~~ + !!! 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 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]/, + /[\u{1D608}-\u{1D621}][\u{1D621}-\u{1D608}]/u, + ~~~~~~~~~~~~~~~~~~~ + !!! error TS1517: Range out of order in character class. +@@= skipped -30, +18 lines =@@ + !!! 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 ++ ~~~~~~~~~~~~~~~~~~~~~~~~~ + !!! error TS1517: Range out of order in character class. + /[\uD835\uDE08-\uD835\uDE21][\uD835\uDE21-\uD835\uDE08]/u, + ~~~~~~~~~~~~~~~~~~~~~~~~~ \ 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 00000000000..fae8550f527 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/regularExpressionGroupNameSuggestions.errors.txt @@ -0,0 +1,9 @@ +regularExpressionGroupNameSuggestions.ts(1,27): error TS1532: There is no capturing group named 'Foo' in this regular expression. + + +==== regularExpressionGroupNameSuggestions.ts (1 errors) ==== + const regex = /(?)\k/; + ~~~ +!!! error TS1532: There is no capturing group named 'Foo' in this regular expression. +!!! related TS1369 regularExpressionGroupNameSuggestions.ts:1:27: 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 index d269c48fd15..2ef93445c7c 100644 --- a/testdata/baselines/reference/submodule/compiler/regularExpressionGroupNameSuggestions.errors.txt.diff +++ b/testdata/baselines/reference/submodule/compiler/regularExpressionGroupNameSuggestions.errors.txt.diff @@ -2,15 +2,16 @@ +++ 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(1,27): error TS1532: There is no capturing group named 'Foo' in this regular expression. + + -==== regularExpressionGroupNameSuggestions.ts (2 errors) ==== -- const regex = /(?)\k/; ++==== regularExpressionGroupNameSuggestions.ts (1 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. + ~~~ + !!! 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 ++!!! related TS1369 regularExpressionGroupNameSuggestions.ts:1:27: 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 00000000000..39f64480484 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/regularExpressionScanning(target=es2015).errors.txt @@ -0,0 +1,643 @@ +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(17,61): error TS1505: Incomplete quantifier. Digit expected. +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,22): error TS1516: A character class range must not be bounded by another character class. +regularExpressionScanning.ts(19,28): error TS1517: Range out of order in character class. +regularExpressionScanning.ts(19,33): error TS1516: A character class range must not be bounded by another character class. +regularExpressionScanning.ts(19,36): error TS1516: A character class range must not be bounded by another 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 (197 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. + +!!! error TS1505: Incomplete quantifier. Digit expected. + // 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 TS1516: A character class range must not be bounded by another character class. + ~~~~~ +!!! error TS1517: Range out of order in character class. + ~~ +!!! error TS1516: A character class range must not be bounded by another character class. + ~~ +!!! error TS1516: A character class range must not be bounded by another 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=es2015).errors.txt.diff b/testdata/baselines/reference/submodule/compiler/regularExpressionScanning(target=es2015).errors.txt.diff index c0d8a52a11d..5fac0651913 100644 --- a/testdata/baselines/reference/submodule/compiler/regularExpressionScanning(target=es2015).errors.txt.diff +++ b/testdata/baselines/reference/submodule/compiler/regularExpressionScanning(target=es2015).errors.txt.diff @@ -3,326 +3,135 @@ @@= 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,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(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. +@@= skipped -40, +37 lines =@@ + 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,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(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(17,61): error TS1505: Incomplete quantifier. Digit expected. + 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,22): error TS1516: A character class range must not be bounded by another character class. + regularExpressionScanning.ts(19,28): error TS1517: Range out of order in character class. ++regularExpressionScanning.ts(19,33): error TS1516: A character class range must not be bounded by another character class. ++regularExpressionScanning.ts(19,36): error TS1516: A character class range must not be bounded by another 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. +@@= skipped -31, +26 lines =@@ + 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(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. +@@= skipped -36, +35 lines =@@ + 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(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. +@@= skipped -16, +15 lines =@@ + 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(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. +@@= skipped -32, +31 lines =@@ + 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(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. +@@= skipped -35, +34 lines =@@ + 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,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,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,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,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,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,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,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, ++ ++ ++==== regularExpressionScanning.ts (197 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 TS1502: The Unicode (u) flag and the Unicode Sets (v) flag cannot be set simultaneously. + ~ +@@= skipped -48, +34 lines =@@ + !!! 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 TS1500: Duplicate regular expression flag. + ~ +@@= skipped -81, +79 lines =@@ + ~~~ + !!! 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. - ~~~~~ @@ -333,9 +142,9 @@ -!!! 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. + /(\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. - ~~~~~ @@ -344,370 +153,132 @@ -!!! 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 TS1515: Named capturing groups with the same name must be mutually exclusive to each other. + // Quantifiers +@@= skipped -31, +13 lines =@@ + !!! error TS1506: Numbers out of order in quantifier. + ~~~~~~~~~ + !!! error TS1507: There is nothing available for repetition. ++ ++!!! error TS1505: Incomplete quantifier. Digit expected. + // 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 TS1516: A character class range must not be bounded by another character class. + ~~~~~ + !!! error TS1517: Range out of order in character class. ++ ~~ ++!!! error TS1516: A character class range must not be bounded by another character class. ++ ~~ ++!!! error TS1516: A character class range must not be bounded by another 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. +@@= skipped -39, +47 lines =@@ + !!! 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. + /\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. +@@= skipped -75, +73 lines =@@ + !!! 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. + /\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. +@@= skipped -35, +33 lines =@@ + !!! 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. + // Character escapes + /\c[\c0\ca\cQ\c\C]\c1\C/, + /\c[\c0\ca\cQ\c\C]\c1\C/u, +@@= skipped -70, +68 lines =@@ + !!! 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. + // Unicode sets notation + /[a--b[--][\d++[]]&&[[&0-9--]&&[\p{L}]--\P{L}-_-]]&&&\q{foo}[0---9][&&q&&&\q{bar}&&]/, + ~~~ +@@= skipped -74, +72 lines =@@ + !!! 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. + /[[^\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, + /[^\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. + /[^\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. + /[^\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. +@@= skipped -26, +18 lines =@@ + !!! 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, + /[^\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. + /[^[[\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. + /[^[[\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. +@@= skipped -19, +13 lines =@@ + !!! 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. + /[^\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. + /[^[[\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 + ]; + \ 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 00000000000..39f64480484 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/regularExpressionScanning(target=esnext).errors.txt @@ -0,0 +1,643 @@ +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(17,61): error TS1505: Incomplete quantifier. Digit expected. +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,22): error TS1516: A character class range must not be bounded by another character class. +regularExpressionScanning.ts(19,28): error TS1517: Range out of order in character class. +regularExpressionScanning.ts(19,33): error TS1516: A character class range must not be bounded by another character class. +regularExpressionScanning.ts(19,36): error TS1516: A character class range must not be bounded by another 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 (197 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. + +!!! error TS1505: Incomplete quantifier. Digit expected. + // 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 TS1516: A character class range must not be bounded by another character class. + ~~~~~ +!!! error TS1517: Range out of order in character class. + ~~ +!!! error TS1516: A character class range must not be bounded by another character class. + ~~ +!!! error TS1516: A character class range must not be bounded by another 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 index 427334cc4b8..9d73f20db1c 100644 --- a/testdata/baselines/reference/submodule/compiler/regularExpressionScanning(target=esnext).errors.txt.diff +++ b/testdata/baselines/reference/submodule/compiler/regularExpressionScanning(target=esnext).errors.txt.diff @@ -1,635 +1,48 @@ --- 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. -- -- +@@= skipped -42, +42 lines =@@ + 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(17,61): error TS1505: Incomplete quantifier. Digit expected. + 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,22): error TS1516: A character class range must not be bounded by another character class. + regularExpressionScanning.ts(19,28): error TS1517: Range out of order in character class. ++regularExpressionScanning.ts(19,33): error TS1516: A character class range must not be bounded by another character class. ++regularExpressionScanning.ts(19,36): error TS1516: A character class range must not be bounded by another 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. +@@= skipped -150, +154 lines =@@ + regularExpressionScanning.ts(47,89): error TS1518: Anything that would possibly match more than a single character is invalid inside a negated character class. + + -==== regularExpressionScanning.ts (193 errors) ==== -- 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 ++==== regularExpressionScanning.ts (197 errors) ==== + const regexes: RegExp[] = [ + // Flags + /foo/visualstudiocode, +@@= skipped -108, +108 lines =@@ + !!! error TS1506: Numbers out of order in quantifier. + ~~~~~~~~~ + !!! error TS1507: There is nothing available for repetition. ++ ++!!! error TS1505: Incomplete quantifier. Digit expected. + // 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 TS1516: A character class range must not be bounded by another character class. + ~~~~~ + !!! error TS1517: Range out of order in character class. ++ ~~ ++!!! error TS1516: A character class range must not be bounded by another character class. ++ ~~ ++!!! error TS1516: A character class range must not be bounded by another 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. \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/regularExpressionUnicodePropertyValueExpressionSuggestions(target=es2015).errors.txt b/testdata/baselines/reference/submodule/compiler/regularExpressionUnicodePropertyValueExpressionSuggestions(target=es2015).errors.txt new file mode 100644 index 00000000000..81ed855de4b --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/regularExpressionUnicodePropertyValueExpressionSuggestions(target=es2015).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 regularExpressionUnicodePropertyValueExpressionSuggestions.ts:1:19: Did you mean 'ASCII'? + ~~ +!!! error TS1524: Unknown Unicode property name. +!!! related TS1369 regularExpressionUnicodePropertyValueExpressionSuggestions.ts:1:28: Did you mean 'sc'? + ~~~~~~~~ +!!! error TS1526: Unknown Unicode property value. +!!! related TS1369 regularExpressionUnicodePropertyValueExpressionSuggestions.ts:1:45: Did you mean 'Unknown'? + ~~~~~~~~~~~~~~~~~~ +!!! error TS1524: Unknown Unicode property name. +!!! related TS1369 regularExpressionUnicodePropertyValueExpressionSuggestions.ts:1:57: Did you mean 'Script_Extensions'? + ~~~~~~~ +!!! error TS1526: Unknown Unicode property value. +!!! related TS1369 regularExpressionUnicodePropertyValueExpressionSuggestions.ts:1:93: Did you mean 'Inherited'? + \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/regularExpressionUnicodePropertyValueExpressionSuggestions(target=es2015).errors.txt.diff b/testdata/baselines/reference/submodule/compiler/regularExpressionUnicodePropertyValueExpressionSuggestions(target=es2015).errors.txt.diff index 5c6454b8273..5f6753c5d5b 100644 --- a/testdata/baselines/reference/submodule/compiler/regularExpressionUnicodePropertyValueExpressionSuggestions(target=es2015).errors.txt.diff +++ b/testdata/baselines/reference/submodule/compiler/regularExpressionUnicodePropertyValueExpressionSuggestions(target=es2015).errors.txt.diff @@ -1,29 +1,25 @@ --- old.regularExpressionUnicodePropertyValueExpressionSuggestions(target=es2015).errors.txt +++ new.regularExpressionUnicodePropertyValueExpressionSuggestions(target=es2015).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. +@@= skipped -8, +8 lines =@@ + 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 regularExpressionUnicodePropertyValueExpressionSuggestions.ts:1:19: Did you mean 'ASCII'? + ~~ + !!! error TS1524: Unknown Unicode property name. -!!! related TS1369: Did you mean 'sc'? -- ~~~~~~~~ --!!! error TS1526: Unknown Unicode property value. ++!!! related TS1369 regularExpressionUnicodePropertyValueExpressionSuggestions.ts:1:28: Did you mean 'sc'? + ~~~~~~~~ + !!! error TS1526: Unknown Unicode property value. -!!! related TS1369: Did you mean 'Unknown'? -- ~~~~~~~~~~~~~~~~~~ --!!! error TS1524: Unknown Unicode property name. ++!!! related TS1369 regularExpressionUnicodePropertyValueExpressionSuggestions.ts:1:45: 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 regularExpressionUnicodePropertyValueExpressionSuggestions.ts:1:57: Did you mean 'Script_Extensions'? + ~~~~~~~ + !!! error TS1526: Unknown Unicode property value. -!!! related TS1369: Did you mean 'Inherited'? -- -+ \ No newline at end of file ++!!! related TS1369 regularExpressionUnicodePropertyValueExpressionSuggestions.ts:1:93: 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 00000000000..aa6f71cec40 --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/regularExpressionWithNonBMPFlags.errors.txt @@ -0,0 +1,26 @@ +regularExpressionWithNonBMPFlags.ts(7,18): error TS1499: Unknown regular expression flag. +regularExpressionWithNonBMPFlags.ts(7,19): error TS1005: ':' expected. +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 (5 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 TS1005: ':' expected. + ~ +!!! 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 cd423f64ac8..48dabf10b7f 100644 --- a/testdata/baselines/reference/submodule/compiler/regularExpressionWithNonBMPFlags.errors.txt.diff +++ b/testdata/baselines/reference/submodule/compiler/regularExpressionWithNonBMPFlags.errors.txt.diff @@ -10,13 +10,21 @@ - - -==== 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 TS1005: ':' expected. ++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 (5 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) +@@= skipped -13, +12 lines =@@ + // + // See https://en.wikipedia.org/wiki/Mathematical_Alphanumeric_Symbols + const 𝘳𝘦𝘨𝘦𝘹 = /(?𝘴𝘪-𝘮:^𝘧𝘰𝘰.)/𝘨𝘮𝘶; - ~~ -!!! error TS1499: Unknown regular expression flag. - ~~ @@ -28,6 +36,14 @@ - ~~ -!!! 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 TS1005: ':' expected. ++ ~ ++!!! 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/shebangError.errors.txt b/testdata/baselines/reference/submodule/compiler/shebangError.errors.txt index 63d8730735c..1667c8d9ed8 100644 --- a/testdata/baselines/reference/submodule/compiler/shebangError.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/shebangError.errors.txt @@ -1,12 +1,14 @@ shebangError.ts(2,1): error TS18026: '#!' can only be used at the start of a file. shebangError.ts(2,2): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type. shebangError.ts(2,3): error TS2872: This kind of expression is always truthy. +shebangError.ts(2,8): error TS1499: Unknown regular expression flag. +shebangError.ts(2,10): error TS1499: Unknown regular expression flag. shebangError.ts(2,12): error TS2304: Cannot find name 'env'. shebangError.ts(2,16): error TS1005: ';' expected. shebangError.ts(2,16): error TS2304: Cannot find name 'node'. -==== shebangError.ts (6 errors) ==== +==== shebangError.ts (8 errors) ==== var foo = 'Shebang is only allowed on the first line'; #!/usr/bin/env node ~~ @@ -15,6 +17,10 @@ shebangError.ts(2,16): error TS2304: Cannot find name 'node'. !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type. ~~~~~~~~ !!! error TS2872: This kind of expression is always truthy. + ~ +!!! error TS1499: Unknown regular expression flag. + ~ +!!! error TS1499: Unknown regular expression flag. ~~~ !!! error TS2304: Cannot find name 'env'. ~~~~ diff --git a/testdata/baselines/reference/submodule/compiler/shebangError.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/shebangError.errors.txt.diff new file mode 100644 index 00000000000..ce8fb26689a --- /dev/null +++ b/testdata/baselines/reference/submodule/compiler/shebangError.errors.txt.diff @@ -0,0 +1,29 @@ +--- old.shebangError.errors.txt ++++ new.shebangError.errors.txt +@@= skipped -0, +0 lines =@@ + shebangError.ts(2,1): error TS18026: '#!' can only be used at the start of a file. + shebangError.ts(2,2): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type. + shebangError.ts(2,3): error TS2872: This kind of expression is always truthy. ++shebangError.ts(2,8): error TS1499: Unknown regular expression flag. ++shebangError.ts(2,10): error TS1499: Unknown regular expression flag. + shebangError.ts(2,12): error TS2304: Cannot find name 'env'. + shebangError.ts(2,16): error TS1005: ';' expected. + shebangError.ts(2,16): error TS2304: Cannot find name 'node'. + + +-==== shebangError.ts (6 errors) ==== ++==== shebangError.ts (8 errors) ==== + var foo = 'Shebang is only allowed on the first line'; + #!/usr/bin/env node + ~~ +@@= skipped -14, +16 lines =@@ + !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type. + ~~~~~~~~ + !!! error TS2872: This kind of expression is always truthy. ++ ~ ++!!! error TS1499: Unknown regular expression flag. ++ ~ ++!!! error TS1499: Unknown regular expression flag. + ~~~ + !!! error TS2304: Cannot find name 'env'. + ~~~~ \ 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 3540eee22fa..6e8015ba664 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,5): 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,11): 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? +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? 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. 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. 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. 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 deleted file mode 100644 index 474fe947cef..00000000000 --- a/testdata/baselines/reference/submodule/conformance/parser.numericSeparators.unicodeEscape.errors.txt.diff +++ /dev/null @@ -1,175 +0,0 @@ ---- old.parser.numericSeparators.unicodeEscape.errors.txt -+++ new.parser.numericSeparators.unicodeEscape.errors.txt -@@= skipped -0, +0 lines =@@ - 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,5): 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,11): 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? --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? - 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. - 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. - 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. - 9.ts(1,5): error TS1125: Hexadecimal digit expected. - - -@@= skipped -58, +44 lines =@@ - - !!! error TS1199: Unterminated Unicode escape sequence. - --==== 4.ts (2 errors) ==== -+==== 4.ts (0 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. - --==== 8.ts (1 errors) ==== -+==== 8.ts (0 errors) ==== - /\uff_ff/u -- --!!! error TS1125: Hexadecimal digit expected. - - ==== 9.ts (1 errors) ==== - "\xf_f" -@@= skipped -20, +18 lines =@@ - - !!! error TS1125: Hexadecimal digit expected. - --==== 12.ts (1 errors) ==== -+==== 12.ts (0 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. - --==== 28.ts (2 errors) ==== -+==== 28.ts (0 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. - --==== 40.ts (2 errors) ==== -+==== 40.ts (0 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. - --==== 44.ts (1 errors) ==== -+==== 44.ts (0 errors) ==== - /\uff__ff/u -- --!!! error TS1125: Hexadecimal digit expected. - - ==== 45.ts (1 errors) ==== - "\xf__f" -@@= skipped -20, +18 lines =@@ - - !!! error TS1125: Hexadecimal digit expected. - --==== 48.ts (1 errors) ==== -+==== 48.ts (0 errors) ==== - /\xf__f/u -- --!!! 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 00000000000..577810615d8 --- /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 b5039f71917..00000000000 --- 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/parserRegularExpression1.errors.txt b/testdata/baselines/reference/submodule/conformance/parserRegularExpression1.errors.txt new file mode 100644 index 00000000000..baa62032beb --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/parserRegularExpression1.errors.txt @@ -0,0 +1,7 @@ +parserRegularExpression1.ts(1,27): error TS1516: A character class range must not be bounded by another character class. + + +==== parserRegularExpression1.ts (1 errors) ==== + /(#?-?\d*\.\d\w*%?)|(@?#?[\w-?]+%?)/g; + ~~ +!!! error TS1516: A character class range must not be bounded by another character class. \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/parserRegularExpression1.errors.txt.diff b/testdata/baselines/reference/submodule/conformance/parserRegularExpression1.errors.txt.diff new file mode 100644 index 00000000000..b415611df90 --- /dev/null +++ b/testdata/baselines/reference/submodule/conformance/parserRegularExpression1.errors.txt.diff @@ -0,0 +1,11 @@ +--- old.parserRegularExpression1.errors.txt ++++ new.parserRegularExpression1.errors.txt +@@= skipped -0, +0 lines =@@ +- ++parserRegularExpression1.ts(1,27): error TS1516: A character class range must not be bounded by another character class. ++ ++ ++==== parserRegularExpression1.ts (1 errors) ==== ++ /(#?-?\d*\.\d\w*%?)|(@?#?[\w-?]+%?)/g; ++ ~~ ++!!! error TS1516: A character class range must not be bounded by another character class. \ 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 1c021a9ba8d..8c8babab6a1 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 8834a567f08..00000000000 --- 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/unicodeExtendedEscapesInRegularExpressions07(target=es6).errors.txt b/testdata/baselines/reference/submodule/conformance/unicodeExtendedEscapesInRegularExpressions07(target=es6).errors.txt new file mode 100644 index 00000000000..51228e4c875 --- /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 095c977c6bb..00000000000 --- 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=es6).errors.txt b/testdata/baselines/reference/submodule/conformance/unicodeExtendedEscapesInRegularExpressions12(target=es6).errors.txt new file mode 100644 index 00000000000..71bc964c777 --- /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 3ce7eaec315..00000000000 --- 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 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 00000000000..2f7010fdb3d --- /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 0dfb17a99f9..00000000000 --- 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=es6).errors.txt b/testdata/baselines/reference/submodule/conformance/unicodeExtendedEscapesInRegularExpressions17(target=es6).errors.txt new file mode 100644 index 00000000000..25e6af14987 --- /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 87176ce8574..00000000000 --- 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=es6).errors.txt b/testdata/baselines/reference/submodule/conformance/unicodeExtendedEscapesInRegularExpressions19(target=es6).errors.txt new file mode 100644 index 00000000000..dadcab40d98 --- /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 347886dd631..00000000000 --- 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 From a37d9641c7fc31fac371480815c637310d69c01f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Burzy=C5=84ski?= Date: Sun, 22 Feb 2026 20:56:02 +0100 Subject: [PATCH 02/43] Port "Improve Recovery of Unterminated Regular Expressions" Co-authored-by: graphemecluster --- internal/parser/parser.go | 8 +-- internal/scanner/regexp.go | 37 ++++++------- internal/scanner/scanner.go | 53 +++++++++---------- ...rExpressionGroupNameSuggestions.errors.txt | 1 - ...essionGroupNameSuggestions.errors.txt.diff | 1 - ...ssionSuggestions(target=es2015).errors.txt | 5 -- ...Suggestions(target=es2015).errors.txt.diff | 5 -- 7 files changed, 41 insertions(+), 69 deletions(-) diff --git a/internal/parser/parser.go b/internal/parser/parser.go index dadab90e915..18a595ad755 100644 --- a/internal/parser/parser.go +++ b/internal/parser/parser.go @@ -251,13 +251,7 @@ func (p *Parser) initializeState(opts ast.SourceFileParseOptions, sourceText str } func (p *Parser) scanError(message *diagnostics.Message, pos int, length int, args ...any) { - lastError := p.lastDiagnostic() - if message.Category() == diagnostics.CategoryMessage && lastError != nil && pos == lastError.Pos() && length == lastError.Len() { - related := ast.NewDiagnostic(nil, core.NewTextRange(pos, pos+length), message, args...) - lastError.AddRelatedInfo(related) - } else { - p.parseErrorAtRange(core.NewTextRange(pos, pos+length), message, args...) - } + p.parseErrorAtRange(core.NewTextRange(pos, pos+length), message, args...) } func (p *Parser) lastDiagnostic() *ast.Diagnostic { diff --git a/internal/scanner/regexp.go b/internal/scanner/regexp.go index 0a590e6e7bf..9085755059a 100644 --- a/internal/scanner/regexp.go +++ b/internal/scanner/regexp.go @@ -21,7 +21,7 @@ const ( RegularExpressionFlagsUnicode RegularExpressionFlags = 1 << 5 // u RegularExpressionFlagsUnicodeSets RegularExpressionFlags = 1 << 6 // v RegularExpressionFlagsSticky RegularExpressionFlags = 1 << 7 // y - RegularExpressionFlagsUnicodeMode RegularExpressionFlags = RegularExpressionFlagsUnicode | RegularExpressionFlagsUnicodeSets + RegularExpressionFlagsAnyUnicodeMode RegularExpressionFlags = RegularExpressionFlagsUnicode | RegularExpressionFlagsUnicodeSets RegularExpressionFlagsModifiers RegularExpressionFlags = RegularExpressionFlagsIgnoreCase | RegularExpressionFlagsMultiline | RegularExpressionFlagsDotAll ) @@ -77,8 +77,7 @@ type regExpParser struct { scanner *Scanner end int regExpFlags RegularExpressionFlags - isUnterminated bool - unicodeMode bool + anyUnicodeMode bool unicodeSetsMode bool mayContainStrings bool @@ -233,7 +232,7 @@ func (p *regExpParser) scanAlternative(isInGroup bool) { if max != "" || p.charAt(p.pos()) == '}' { p.error(diagnostics.Incomplete_quantifier_Digit_expected, digitsStart, 0) } else { - if p.unicodeMode { + if p.anyUnicodeMode { p.error(diagnostics.Unexpected_0_Did_you_mean_to_escape_it_with_backslash, start, 1, string(ch)) } isPreviousTermQuantifiable = true @@ -248,7 +247,7 @@ func (p *regExpParser) scanAlternative(isInGroup bool) { } } } else if min == "" { - if p.unicodeMode { + if p.anyUnicodeMode { p.error(diagnostics.Unexpected_0_Did_you_mean_to_escape_it_with_backslash, start, 1, string(ch)) } isPreviousTermQuantifiable = true @@ -285,10 +284,7 @@ func (p *regExpParser) scanAlternative(isInGroup bool) { } fallthrough case ']', '}': - if p.isUnterminated && !isInGroup { - return - } - if p.unicodeMode || ch == ')' { + if p.anyUnicodeMode || ch == ')' { p.error(diagnostics.Unexpected_0_Did_you_mean_to_escape_it_with_backslash, p.pos(), 1, string(ch)) } p.incPos(1) @@ -340,7 +336,7 @@ func (p *regExpParser) scanAtomEscape() { p.incPos(1) p.scanGroupName(true /*isReference*/) p.scanExpectedChar('>') - } else if p.unicodeMode { + } else if p.anyUnicodeMode { p.error(diagnostics.X_k_must_be_followed_by_a_capturing_group_name_enclosed_in_angle_brackets, p.pos()-2, 2) } case 'q': @@ -376,10 +372,13 @@ func (p *regExpParser) scanDecimalEscape() bool { // | (Other sequences handled by `scanEscapeSequence`) // IdentityEscape ::= // | '^' | '$' | '/' | '\' | '.' | '*' | '+' | '?' | '(' | ')' | '[' | ']' | '{' | '}' | '|' -// | [~UnicodeMode] (any other non-identifier characters) +// | [~AnyUnicodeMode] (any other non-identifier characters) func (p *regExpParser) scanCharacterEscape(atomEscape bool) string { ch := p.charAt(p.pos()) switch ch { + case -1: + p.error(diagnostics.Undetermined_character_escape, p.pos()-1, 1) + return "\\" case 'c': p.incPos(1) ch = p.charAt(p.pos()) @@ -387,7 +386,7 @@ func (p *regExpParser) scanCharacterEscape(atomEscape bool) string { p.incPos(1) return string(rune(ch & 0x1f)) } - if p.unicodeMode { + if p.anyUnicodeMode { p.error(diagnostics.X_c_must_be_followed_by_an_ASCII_letter, p.pos()-2, 2) } return string(ch) @@ -395,13 +394,9 @@ func (p *regExpParser) scanCharacterEscape(atomEscape bool) string { p.incPos(1) return string(ch) default: - if p.pos() >= p.end { - p.error(diagnostics.Undetermined_character_escape, p.pos()-1, 1) - return "\\" - } p.incPos(-1) // back up to include the backslash for scanEscapeSequence flags := EscapeSequenceScanningFlagsRegularExpression | EscapeSequenceScanningFlagsAnnexB - if p.unicodeMode { + if p.anyUnicodeMode { flags |= EscapeSequenceScanningFlagsReportErrors | EscapeSequenceScanningFlagsAnyUnicodeMode } if atomEscape { @@ -790,7 +785,7 @@ func (p *regExpParser) scanClassAtom() string { // CharacterClassEscape ::= // | 'd' | 'D' | 's' | 'S' | 'w' | 'W' -// | [+UnicodeMode] ('P' | 'p') '{' UnicodePropertyValueExpression '}' +// | [+AnyUnicodeMode] ('P' | 'p') '{' UnicodePropertyValueExpression '}' func (p *regExpParser) scanCharacterClassEscape() bool { isCharacterComplement := false start := p.pos() - 1 @@ -854,10 +849,10 @@ func (p *regExpParser) scanCharacterClassEscape() bool { } } p.scanExpectedChar('}') - if !p.unicodeMode { + if !p.anyUnicodeMode { p.error(diagnostics.Unicode_property_value_expressions_are_only_available_when_the_Unicode_u_flag_or_the_Unicode_Sets_v_flag_is_set, start, p.pos()-start) } - } else if p.unicodeMode { + } else if p.anyUnicodeMode { p.error(diagnostics.X_0_must_be_followed_by_a_Unicode_property_value_expression_enclosed_in_braces, p.pos()-2, 2, string(ch)) } return true @@ -912,7 +907,7 @@ func (p *regExpParser) scanWordCharacters() string { } func (p *regExpParser) scanSourceCharacter() string { - if p.unicodeMode { + if p.anyUnicodeMode { ch, size := utf8.DecodeRuneInString(p.text()[p.pos():]) if size == 0 || ch == utf8.RuneError { return "" diff --git a/internal/scanner/scanner.go b/internal/scanner/scanner.go index f8428f1fec1..fe00591ee26 100644 --- a/internal/scanner/scanner.go +++ b/internal/scanner/scanner.go @@ -1053,7 +1053,7 @@ func (s *Scanner) ReScanSlashToken() ast.Kind { p := startOfRegExpBody inEscape := false // Although nested character classes are allowed in Unicode Sets mode, - // an unescaped slash is nevertheless invalid even in a character class in Unicode mode. + // an unescaped slash is nevertheless invalid even in a character class in any Unicode mode. // Additionally, parsing nested character classes will misinterpret regexes like `/[[]/` // as unterminated, consuming characters beyond the slash. (This even applies to `/[[]/v`, // which should be parsed as a well-terminated regex with an incomplete character class.) @@ -1084,19 +1084,16 @@ func (s *Scanner) ReScanSlashToken() ast.Kind { p++ } - isUnterminated := s.tokenFlags&ast.TokenFlagsUnterminated != 0 - endOfBody := p - var regExpFlags RegularExpressionFlags - - if isUnterminated { - // Search for the nearest unbalanced bracket for better recovery - endOfScan := p + endOfRegExpBody := p + if s.tokenFlags&ast.TokenFlagsUnterminated != 0 { + // Search for the nearest unbalanced bracket for better recovery. Since the expression is + // invalid anyways, we take nested square brackets into consideration for the best guess. p = startOfRegExpBody inEscape = false characterClassDepth := 0 inDecimalQuantifier := false groupDepth := 0 - for p < endOfScan { + for p < endOfRegExpBody { ch := rune(s.text[p]) if inEscape { inEscape = false @@ -1123,6 +1120,7 @@ func (s *Scanner) ReScanSlashToken() ast.Kind { } p++ } + // Whitespaces and semicolons at the end are not likely to be part of the regex for p > startOfRegExpBody { ch, size := utf8.DecodeLastRuneInString(s.text[:p]) if stringutil.IsWhiteSpaceLike(ch) || ch == ';' { @@ -1131,12 +1129,11 @@ func (s *Scanner) ReScanSlashToken() ast.Kind { break } } - endOfBody = p s.errorAt(diagnostics.Unterminated_regular_expression_literal, s.tokenStart, p-s.tokenStart) } else { - // Skip past the closing '/' + // Consume the slash character p++ - // Scan and validate flags + var regExpFlags RegularExpressionFlags for p < len(s.text) { ch, size := utf8.DecodeRuneInString(s.text[p:]) if !IsIdentifierPart(ch) { @@ -1147,7 +1144,7 @@ func (s *Scanner) ReScanSlashToken() ast.Kind { s.errorAt(diagnostics.Unknown_regular_expression_flag, p, size) } else if regExpFlags&flag != 0 { s.errorAt(diagnostics.Duplicate_regular_expression_flag, p, size) - } else if (regExpFlags|flag)&RegularExpressionFlagsUnicodeMode == RegularExpressionFlagsUnicodeMode { + } else if (regExpFlags|flag)&RegularExpressionFlagsAnyUnicodeMode == RegularExpressionFlagsAnyUnicodeMode { s.errorAt(diagnostics.The_Unicode_u_flag_and_the_Unicode_Sets_v_flag_cannot_be_set_simultaneously, p, size) } else { regExpFlags |= flag @@ -1158,24 +1155,22 @@ func (s *Scanner) ReScanSlashToken() ast.Kind { } p += size } + s.pos = startOfRegExpBody + saveTokenPos := s.tokenStart + saveTokenFlags := s.tokenFlags + parser := ®ExpParser{ + scanner: s, + end: endOfRegExpBody, + regExpFlags: regExpFlags, + anyUnicodeMode: regExpFlags&RegularExpressionFlagsAnyUnicodeMode != 0, + unicodeSetsMode: regExpFlags&RegularExpressionFlagsUnicodeSets != 0, + groupSpecifiers: make(map[string]bool), + } + parser.run() + s.tokenStart = saveTokenPos + s.tokenFlags = saveTokenFlags } - s.pos = startOfRegExpBody - saveTokenPos := s.tokenStart - saveTokenFlags := s.tokenFlags - parser := ®ExpParser{ - scanner: s, - end: endOfBody, - regExpFlags: regExpFlags, - isUnterminated: isUnterminated, - unicodeMode: regExpFlags&RegularExpressionFlagsUnicodeMode != 0, - unicodeSetsMode: regExpFlags&RegularExpressionFlagsUnicodeSets != 0, - groupSpecifiers: make(map[string]bool), - } - parser.run() - s.tokenStart = saveTokenPos - s.tokenFlags = saveTokenFlags - s.pos = p s.tokenValue = s.text[s.tokenStart:s.pos] s.token = ast.KindRegularExpressionLiteral diff --git a/testdata/baselines/reference/submodule/compiler/regularExpressionGroupNameSuggestions.errors.txt b/testdata/baselines/reference/submodule/compiler/regularExpressionGroupNameSuggestions.errors.txt index fae8550f527..bbb5d0c1927 100644 --- a/testdata/baselines/reference/submodule/compiler/regularExpressionGroupNameSuggestions.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/regularExpressionGroupNameSuggestions.errors.txt @@ -5,5 +5,4 @@ regularExpressionGroupNameSuggestions.ts(1,27): error TS1532: There is no captur const regex = /(?)\k/; ~~~ !!! error TS1532: There is no capturing group named 'Foo' in this regular expression. -!!! related TS1369 regularExpressionGroupNameSuggestions.ts:1:27: 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 index 2ef93445c7c..0e554ac1c9c 100644 --- a/testdata/baselines/reference/submodule/compiler/regularExpressionGroupNameSuggestions.errors.txt.diff +++ b/testdata/baselines/reference/submodule/compiler/regularExpressionGroupNameSuggestions.errors.txt.diff @@ -13,5 +13,4 @@ ~~~ !!! error TS1532: There is no capturing group named 'Foo' in this regular expression. -!!! related TS1369: Did you mean 'foo'? -+!!! related TS1369 regularExpressionGroupNameSuggestions.ts:1:27: Did you mean 'foo'? \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/regularExpressionUnicodePropertyValueExpressionSuggestions(target=es2015).errors.txt b/testdata/baselines/reference/submodule/compiler/regularExpressionUnicodePropertyValueExpressionSuggestions(target=es2015).errors.txt index 81ed855de4b..904863c7add 100644 --- a/testdata/baselines/reference/submodule/compiler/regularExpressionUnicodePropertyValueExpressionSuggestions(target=es2015).errors.txt +++ b/testdata/baselines/reference/submodule/compiler/regularExpressionUnicodePropertyValueExpressionSuggestions(target=es2015).errors.txt @@ -9,17 +9,12 @@ regularExpressionUnicodePropertyValueExpressionSuggestions.ts(1,93): error TS152 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 regularExpressionUnicodePropertyValueExpressionSuggestions.ts:1:19: Did you mean 'ASCII'? ~~ !!! error TS1524: Unknown Unicode property name. -!!! related TS1369 regularExpressionUnicodePropertyValueExpressionSuggestions.ts:1:28: Did you mean 'sc'? ~~~~~~~~ !!! error TS1526: Unknown Unicode property value. -!!! related TS1369 regularExpressionUnicodePropertyValueExpressionSuggestions.ts:1:45: Did you mean 'Unknown'? ~~~~~~~~~~~~~~~~~~ !!! error TS1524: Unknown Unicode property name. -!!! related TS1369 regularExpressionUnicodePropertyValueExpressionSuggestions.ts:1:57: Did you mean 'Script_Extensions'? ~~~~~~~ !!! error TS1526: Unknown Unicode property value. -!!! related TS1369 regularExpressionUnicodePropertyValueExpressionSuggestions.ts:1:93: Did you mean 'Inherited'? \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/regularExpressionUnicodePropertyValueExpressionSuggestions(target=es2015).errors.txt.diff b/testdata/baselines/reference/submodule/compiler/regularExpressionUnicodePropertyValueExpressionSuggestions(target=es2015).errors.txt.diff index 5f6753c5d5b..5c4651e5727 100644 --- a/testdata/baselines/reference/submodule/compiler/regularExpressionUnicodePropertyValueExpressionSuggestions(target=es2015).errors.txt.diff +++ b/testdata/baselines/reference/submodule/compiler/regularExpressionUnicodePropertyValueExpressionSuggestions(target=es2015).errors.txt.diff @@ -5,21 +5,16 @@ ~~~~~ !!! error TS1529: Unknown Unicode property name or value. -!!! related TS1369: Did you mean 'ASCII'? -+!!! related TS1369 regularExpressionUnicodePropertyValueExpressionSuggestions.ts:1:19: Did you mean 'ASCII'? ~~ !!! error TS1524: Unknown Unicode property name. -!!! related TS1369: Did you mean 'sc'? -+!!! related TS1369 regularExpressionUnicodePropertyValueExpressionSuggestions.ts:1:28: Did you mean 'sc'? ~~~~~~~~ !!! error TS1526: Unknown Unicode property value. -!!! related TS1369: Did you mean 'Unknown'? -+!!! related TS1369 regularExpressionUnicodePropertyValueExpressionSuggestions.ts:1:45: Did you mean 'Unknown'? ~~~~~~~~~~~~~~~~~~ !!! error TS1524: Unknown Unicode property name. -!!! related TS1369: Did you mean 'Script_Extensions'? -+!!! related TS1369 regularExpressionUnicodePropertyValueExpressionSuggestions.ts:1:57: Did you mean 'Script_Extensions'? ~~~~~~~ !!! error TS1526: Unknown Unicode property value. -!!! related TS1369: Did you mean 'Inherited'? -+!!! related TS1369 regularExpressionUnicodePropertyValueExpressionSuggestions.ts:1:93: Did you mean 'Inherited'? \ No newline at end of file From fa64311c2c421e11b27fb48f10b68af908e5e9f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Burzy=C5=84ski?= Date: Sun, 22 Feb 2026 23:21:58 +0100 Subject: [PATCH 03/43] Port "Move RegExp flag version mapping to LanguageFeatureMinimumTarget" Co-authored-by: Jake Bailey <5341706+jakebailey@users.noreply.github.com> --- internal/checker/types.go | 4 + internal/scanner/regexp.go | 151 ++++++++++++++++++++---------------- internal/scanner/scanner.go | 5 +- 3 files changed, 90 insertions(+), 70 deletions(-) diff --git a/internal/checker/types.go b/internal/checker/types.go index 9fe27235cae..4cdec86110c 100644 --- a/internal/checker/types.go +++ b/internal/checker/types.go @@ -1256,6 +1256,8 @@ const ( type TypeComparer func(s *Type, t *Type, reportErrors bool) Ternary type LanguageFeatureMinimumTargetMap struct { + RegularExpressionFlagsUnicode core.ScriptTarget + RegularExpressionFlagsSticky core.ScriptTarget Exponentiation core.ScriptTarget AsyncFunctions core.ScriptTarget ForAwaitOf core.ScriptTarget @@ -1279,6 +1281,8 @@ type LanguageFeatureMinimumTargetMap struct { } var LanguageFeatureMinimumTarget = LanguageFeatureMinimumTargetMap{ + RegularExpressionFlagsUnicode: core.ScriptTargetES2015, + RegularExpressionFlagsSticky: core.ScriptTargetES2015, Exponentiation: core.ScriptTargetES2016, AsyncFunctions: core.ScriptTargetES2017, ForAwaitOf: core.ScriptTargetES2018, diff --git a/internal/scanner/regexp.go b/internal/scanner/regexp.go index 9085755059a..f524b0e2af0 100644 --- a/internal/scanner/regexp.go +++ b/internal/scanner/regexp.go @@ -12,17 +12,17 @@ import ( type RegularExpressionFlags int32 const ( - RegularExpressionFlagsNone RegularExpressionFlags = 0 - RegularExpressionFlagsHasIndices RegularExpressionFlags = 1 << 0 // d - RegularExpressionFlagsGlobal RegularExpressionFlags = 1 << 1 // g - RegularExpressionFlagsIgnoreCase RegularExpressionFlags = 1 << 2 // i - RegularExpressionFlagsMultiline RegularExpressionFlags = 1 << 3 // m - RegularExpressionFlagsDotAll RegularExpressionFlags = 1 << 4 // s - RegularExpressionFlagsUnicode RegularExpressionFlags = 1 << 5 // u - RegularExpressionFlagsUnicodeSets RegularExpressionFlags = 1 << 6 // v - RegularExpressionFlagsSticky RegularExpressionFlags = 1 << 7 // y + RegularExpressionFlagsNone RegularExpressionFlags = 0 + RegularExpressionFlagsHasIndices RegularExpressionFlags = 1 << 0 // d + RegularExpressionFlagsGlobal RegularExpressionFlags = 1 << 1 // g + RegularExpressionFlagsIgnoreCase RegularExpressionFlags = 1 << 2 // i + RegularExpressionFlagsMultiline RegularExpressionFlags = 1 << 3 // m + RegularExpressionFlagsDotAll RegularExpressionFlags = 1 << 4 // s + RegularExpressionFlagsUnicode RegularExpressionFlags = 1 << 5 // u + RegularExpressionFlagsUnicodeSets RegularExpressionFlags = 1 << 6 // v + RegularExpressionFlagsSticky RegularExpressionFlags = 1 << 7 // y RegularExpressionFlagsAnyUnicodeMode RegularExpressionFlags = RegularExpressionFlagsUnicode | RegularExpressionFlagsUnicodeSets - RegularExpressionFlagsModifiers RegularExpressionFlags = RegularExpressionFlagsIgnoreCase | RegularExpressionFlagsMultiline | RegularExpressionFlagsDotAll + RegularExpressionFlagsModifiers RegularExpressionFlags = RegularExpressionFlagsIgnoreCase | RegularExpressionFlagsMultiline | RegularExpressionFlagsDotAll ) var charToRegExpFlag = map[rune]RegularExpressionFlags{ @@ -38,9 +38,6 @@ var charToRegExpFlag = map[rune]RegularExpressionFlags{ var regExpFlagToFirstAvailableLanguageVersion = map[RegularExpressionFlags]core.ScriptTarget{ RegularExpressionFlagsHasIndices: core.ScriptTargetES2022, - RegularExpressionFlagsGlobal: core.ScriptTargetES5, // ES3 doesn't exist in Go; ES5 is the lowest - RegularExpressionFlagsIgnoreCase: core.ScriptTargetES5, - RegularExpressionFlagsMultiline: core.ScriptTargetES5, RegularExpressionFlagsDotAll: core.ScriptTargetES2018, RegularExpressionFlagsUnicode: core.ScriptTargetES2015, RegularExpressionFlagsUnicodeSets: core.ScriptTargetESNext, @@ -52,6 +49,12 @@ func CharacterToRegularExpressionFlag(ch rune) (RegularExpressionFlags, bool) { return flag, ok } +func (s *Scanner) checkRegularExpressionFlagAvailable(flag RegularExpressionFlags, pos int) { + if availableFrom, ok := regExpFlagToFirstAvailableLanguageVersion[flag]; ok && s.languageVersion() < availableFrom { + s.errorAt(diagnostics.This_regular_expression_flag_is_only_available_when_targeting_0_or_later, pos, 1, GetNameOfScriptTarget(availableFrom)) + } +} + type classSetExpressionType int const ( @@ -74,10 +77,10 @@ type decimalEscapeValue struct { } type regExpParser struct { - scanner *Scanner - end int - regExpFlags RegularExpressionFlags - anyUnicodeMode bool + scanner *Scanner + end int + regExpFlags RegularExpressionFlags + anyUnicodeMode bool unicodeSetsMode bool mayContainStrings bool @@ -130,33 +133,42 @@ func (p *regExpParser) scanDisjunction(isInGroup bool) { // Alternative ::= Term* // Term ::= -// | Assertion -// | Atom Quantifier? +// +// | Assertion +// | Atom Quantifier? +// // Assertion ::= -// | '^' -// | '$' -// | '\b' -// | '\B' -// | '(?=' Disjunction ')' -// | '(?!' Disjunction ')' -// | '(?<=' Disjunction ')' -// | '(?' Disjunction ')' -// | '(?' RegularExpressionFlags ('-' RegularExpressionFlags)? ':' Disjunction ')' +// +// | PatternCharacter +// | '.' +// | '\' AtomEscape +// | CharacterClass +// | '(?<' RegExpIdentifierName '>' Disjunction ')' +// | '(?' RegularExpressionFlags ('-' RegularExpressionFlags)? ':' Disjunction ')' +// // CharacterClass ::= unicodeMode -// ? '[' ClassRanges ']' -// : '[' ClassSetExpression ']' +// +// ? '[' ClassRanges ']' +// : '[' ClassSetExpression ']' func (p *regExpParser) scanAlternative(isInGroup bool) { isPreviousTermQuantifiable := false for p.pos() < p.end { @@ -313,10 +325,7 @@ func (p *regExpParser) scanPatternModifiers(currFlags RegularExpressionFlags) Re p.error(diagnostics.This_regular_expression_flag_cannot_be_toggled_within_a_subpattern, p.pos(), 1) } else { currFlags |= flag - availableFrom := regExpFlagToFirstAvailableLanguageVersion[flag] - if p.scanner.languageVersion() < availableFrom { - p.error(diagnostics.This_regular_expression_flag_is_only_available_when_targeting_0_or_later, p.pos(), 1, GetNameOfScriptTarget(availableFrom)) - } + p.scanner.checkRegularExpressionFlagAvailable(flag, p.pos()) } p.incPos(1) } @@ -324,10 +333,11 @@ func (p *regExpParser) scanPatternModifiers(currFlags RegularExpressionFlags) Re } // AtomEscape ::= -// | DecimalEscape -// | CharacterClassEscape -// | CharacterEscape -// | 'k<' RegExpIdentifierName '>' +// +// | DecimalEscape +// | CharacterClassEscape +// | CharacterEscape +// | 'k<' RegExpIdentifierName '>' func (p *regExpParser) scanAtomEscape() { switch p.charAt(p.pos()) { case 'k': @@ -367,12 +377,15 @@ func (p *regExpParser) scanDecimalEscape() bool { } // CharacterEscape ::= -// | `c` ControlLetter -// | IdentityEscape -// | (Other sequences handled by `scanEscapeSequence`) +// +// | `c` ControlLetter +// | IdentityEscape +// | (Other sequences handled by `scanEscapeSequence`) +// // IdentityEscape ::= -// | '^' | '$' | '/' | '\' | '.' | '*' | '+' | '?' | '(' | ')' | '[' | ']' | '{' | '}' | '|' -// | [~AnyUnicodeMode] (any other non-identifier characters) +// +// | '^' | '$' | '/' | '\' | '.' | '*' | '+' | '?' | '(' | ')' | '[' | ']' | '{' | '}' | '|' +// | [~AnyUnicodeMode] (any other non-identifier characters) func (p *regExpParser) scanCharacterEscape(atomEscape bool) string { ch := p.charAt(p.pos()) switch ch { @@ -659,10 +672,11 @@ func (p *regExpParser) scanClassSetSubExpression(expressionType classSetExpressi } // ClassSetOperand ::= -// | '[' ClassSetExpression ']' -// | '\' CharacterClassEscape -// | '\q{' ClassStringDisjunctionContents '}' -// | ClassSetCharacter +// +// | '[' ClassSetExpression ']' +// | '\' CharacterClassEscape +// | '\q{' ClassStringDisjunctionContents '}' +// | ClassSetCharacter func (p *regExpParser) scanClassSetOperand() string { p.mayContainStrings = false switch p.charAt(p.pos()) { @@ -719,8 +733,9 @@ func (p *regExpParser) scanClassStringDisjunctionContents() { } // ClassSetCharacter ::= -// | SourceCharacter -- ClassSetSyntaxCharacter -- ClassSetReservedDoublePunctuator -// | '\' (CharacterEscape | ClassSetReservedPunctuator | 'b') +// +// | SourceCharacter -- ClassSetSyntaxCharacter -- ClassSetReservedDoublePunctuator +// | '\' (CharacterEscape | ClassSetReservedPunctuator | 'b') func (p *regExpParser) scanClassSetCharacter() string { ch := p.charAt(p.pos()) if ch == '\\' { @@ -754,13 +769,16 @@ func (p *regExpParser) scanClassSetCharacter() string { } // ClassAtom ::= -// | SourceCharacter but not one of '\' or ']' -// | '\' ClassEscape +// +// | SourceCharacter but not one of '\' or ']' +// | '\' ClassEscape +// // ClassEscape ::= -// | 'b' -// | '-' -// | CharacterClassEscape -// | CharacterEscape +// +// | 'b' +// | '-' +// | CharacterClassEscape +// | CharacterEscape func (p *regExpParser) scanClassAtom() string { if p.charAt(p.pos()) == '\\' { p.incPos(1) @@ -784,8 +802,9 @@ func (p *regExpParser) scanClassAtom() string { } // CharacterClassEscape ::= -// | 'd' | 'D' | 's' | 'S' | 'w' | 'W' -// | [+AnyUnicodeMode] ('P' | 'p') '{' UnicodePropertyValueExpression '}' +// +// | 'd' | 'D' | 's' | 'S' | 'w' | 'W' +// | [+AnyUnicodeMode] ('P' | 'p') '{' UnicodePropertyValueExpression '}' func (p *regExpParser) scanCharacterClassEscape() bool { isCharacterComplement := false start := p.pos() - 1 diff --git a/internal/scanner/scanner.go b/internal/scanner/scanner.go index fe00591ee26..f0a3c3d052e 100644 --- a/internal/scanner/scanner.go +++ b/internal/scanner/scanner.go @@ -1148,10 +1148,7 @@ func (s *Scanner) ReScanSlashToken() ast.Kind { s.errorAt(diagnostics.The_Unicode_u_flag_and_the_Unicode_Sets_v_flag_cannot_be_set_simultaneously, p, size) } else { regExpFlags |= flag - availableFrom := regExpFlagToFirstAvailableLanguageVersion[flag] - if s.languageVersion() < availableFrom { - s.errorAt(diagnostics.This_regular_expression_flag_is_only_available_when_targeting_0_or_later, p, size, GetNameOfScriptTarget(availableFrom)) - } + s.checkRegularExpressionFlagAvailable(flag, p) } p += size } From 0499a15db38bc4fcc8b7bc11372eb1e54d472dad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Burzy=C5=84ski?= Date: Mon, 23 Feb 2026 08:36:06 +0100 Subject: [PATCH 04/43] Port "Report RegExp errors in grammar check, use Annex B grammar" Co-authored-by: Ron Buckton --- internal/checker/checker.go | 1 + internal/checker/grammarchecks.go | 63 ++--- internal/scanner/regexp.go | 24 +- internal/scanner/scanner.go | 67 +++-- ...angeYourTargetLibraryES2016Plus.errors.txt | 20 +- ...ourTargetLibraryES2016Plus.errors.txt.diff | 47 ---- ...acketInCharClass(target=es2015).errors.txt | 5 +- ...InCharClass(target=es2015).errors.txt.diff | 18 +- .../regularExpressionAnnexB.errors.txt | 5 +- .../regularExpressionAnnexB.errors.txt.diff | 23 +- ...rExpressionGroupNameSuggestions.errors.txt | 6 +- ...essionGroupNameSuggestions.errors.txt.diff | 13 +- ...pressionScanning(target=es2015).errors.txt | 125 +++++---- ...ionScanning(target=es2015).errors.txt.diff | 241 +++++++++--------- ...pressionScanning(target=esnext).errors.txt | 47 +--- ...ionScanning(target=esnext).errors.txt.diff | 87 +++++-- ...ssionSuggestions(target=es2015).errors.txt | 5 + ...Suggestions(target=es2015).errors.txt.diff | 5 + .../compiler/shebangError.errors.txt | 8 +- .../compiler/shebangError.errors.txt.diff | 29 --- .../parserRegularExpression1.errors.txt | 7 - .../parserRegularExpression1.errors.txt.diff | 11 - 22 files changed, 401 insertions(+), 456 deletions(-) delete mode 100644 testdata/baselines/reference/submodule/compiler/doYouNeedToChangeYourTargetLibraryES2016Plus.errors.txt.diff delete mode 100644 testdata/baselines/reference/submodule/compiler/shebangError.errors.txt.diff delete mode 100644 testdata/baselines/reference/submodule/conformance/parserRegularExpression1.errors.txt delete mode 100644 testdata/baselines/reference/submodule/conformance/parserRegularExpression1.errors.txt.diff diff --git a/internal/checker/checker.go b/internal/checker/checker.go index c74ebdf17ed..000fafea32d 100644 --- a/internal/checker/checker.go +++ b/internal/checker/checker.go @@ -680,6 +680,7 @@ type Checker struct { markedAssignmentSymbolLinks core.LinkStore[*ast.Symbol, MarkedAssignmentSymbolLinks] symbolContainerLinks core.LinkStore[*ast.Symbol, ContainingSymbolLinks] sourceFileLinks core.LinkStore[*ast.SourceFile, SourceFileLinks] + regExpScanner *scanner.Scanner patternForType map[*Type]*ast.Node contextFreeTypes map[*ast.Node]*Type anyType *Type diff --git a/internal/checker/grammarchecks.go b/internal/checker/grammarchecks.go index 6eba92c3c7f..4a2450184a9 100644 --- a/internal/checker/grammarchecks.go +++ b/internal/checker/grammarchecks.go @@ -54,43 +54,34 @@ 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 { + sourceFile := ast.GetSourceFileOfNode(node.AsNode()) + if !c.hasParseDiagnostics(sourceFile) { + var lastError *ast.Diagnostic + if c.regExpScanner == nil { + c.regExpScanner = scanner.NewScanner() + } + c.regExpScanner.SetScriptTarget(c.languageVersion) + c.regExpScanner.SetLanguageVariant(sourceFile.LanguageVariant) + c.regExpScanner.SetOnError(func(message *diagnostics.Message, start int, length int, args ...any) { + 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) + } + }) + c.regExpScanner.SetText(sourceFile.Text()) + c.regExpScanner.ResetTokenState(node.AsNode().Pos()) + c.regExpScanner.Scan() + tokenIsRegularExpressionLiteral := c.regExpScanner.ReScanSlashToken(true) == ast.KindRegularExpressionLiteral + c.regExpScanner.SetText("") + c.regExpScanner.SetOnError(nil) + debug.Assert(tokenIsRegularExpressionLiteral) + return lastError != nil + } 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/scanner/regexp.go b/internal/scanner/regexp.go index f524b0e2af0..9797cea97fe 100644 --- a/internal/scanner/regexp.go +++ b/internal/scanner/regexp.go @@ -82,6 +82,7 @@ type regExpParser struct { regExpFlags RegularExpressionFlags anyUnicodeMode bool unicodeSetsMode bool + annexB bool mayContainStrings bool numberOfCapturingGroups int @@ -195,7 +196,8 @@ func (p *regExpParser) scanAlternative(isInGroup bool) { switch p.charAt(p.pos()) { case '=', '!': p.incPos(1) - isPreviousTermQuantifiable = false + // In Annex B, `(?=Disjunction)` and `(?!Disjunction)` are quantifiable + isPreviousTermQuantifiable = p.annexB case '<': groupNameStart := p.pos() p.incPos(1) @@ -401,6 +403,9 @@ func (p *regExpParser) scanCharacterEscape(atomEscape bool) string { } if p.anyUnicodeMode { p.error(diagnostics.X_c_must_be_followed_by_an_ASCII_letter, p.pos()-2, 2) + } else if atomEscape && p.annexB { + p.incPos(-1) + return "\\" } return string(ch) case '^', '$', '/', '\\', '.', '*', '+', '?', '(', ')', '[', ']', '{', '}', '|': @@ -408,7 +413,10 @@ func (p *regExpParser) scanCharacterEscape(atomEscape bool) string { return string(ch) default: p.incPos(-1) // back up to include the backslash for scanEscapeSequence - flags := EscapeSequenceScanningFlagsRegularExpression | EscapeSequenceScanningFlagsAnnexB + flags := EscapeSequenceScanningFlagsRegularExpression + if p.annexB { + flags |= EscapeSequenceScanningFlagsAnnexB + } if p.anyUnicodeMode { flags |= EscapeSequenceScanningFlagsReportErrors | EscapeSequenceScanningFlagsAnyUnicodeMode } @@ -467,12 +475,12 @@ func (p *regExpParser) scanClassRanges() { if p.isClassContentExit(ch) { return } - if minCharacter == "" { + if minCharacter == "" && !p.annexB { p.error(diagnostics.A_character_class_range_must_not_be_bounded_by_another_character_class, minStart, p.pos()-1-minStart) } maxStart := p.pos() maxCharacter := p.scanClassAtom() - if maxCharacter == "" { + if maxCharacter == "" && !p.annexB { p.error(diagnostics.A_character_class_range_must_not_be_bounded_by_another_character_class, maxStart, p.pos()-maxStart) continue } @@ -959,6 +967,10 @@ func (p *regExpParser) scanDigits() { } func (p *regExpParser) run() { + if p.anyUnicodeMode { + p.annexB = false + } + p.scanDisjunction(false /*isInGroup*/) for _, reference := range p.groupNameReferences { @@ -977,7 +989,9 @@ func (p *regExpParser) run() { } } for _, escape := range p.decimalEscapes { - if escape.value > p.numberOfCapturingGroups { + // in AnnexB, if a DecimalEscape is greater than the number of capturing groups then it is treated as + // either a LegacyOctalEscapeSequence or IdentityEscape + if !p.annexB && escape.value > p.numberOfCapturingGroups { if p.numberOfCapturingGroups > 0 { p.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, p.numberOfCapturingGroups) } else { diff --git a/internal/scanner/scanner.go b/internal/scanner/scanner.go index f0a3c3d052e..2aee905df09 100644 --- a/internal/scanner/scanner.go +++ b/internal/scanner/scanner.go @@ -1046,7 +1046,8 @@ func (s *Scanner) ReScanAsteriskEqualsToken() ast.Kind { return s.token } -func (s *Scanner) ReScanSlashToken() ast.Kind { +func (s *Scanner) ReScanSlashToken(reportErrors ...bool) ast.Kind { + shouldReportErrors := len(reportErrors) > 0 && reportErrors[0] if s.token == ast.KindSlashToken || s.token == ast.KindSlashEqualsToken { // Quickly get to the end of regex such that we know the flags startOfRegExpBody := s.tokenStart + 1 @@ -1139,33 +1140,41 @@ func (s *Scanner) ReScanSlashToken() ast.Kind { if !IsIdentifierPart(ch) { break } - flag, ok := CharacterToRegularExpressionFlag(ch) - if !ok { - s.errorAt(diagnostics.Unknown_regular_expression_flag, p, size) - } else if regExpFlags&flag != 0 { - s.errorAt(diagnostics.Duplicate_regular_expression_flag, p, size) - } else if (regExpFlags|flag)&RegularExpressionFlagsAnyUnicodeMode == RegularExpressionFlagsAnyUnicodeMode { - s.errorAt(diagnostics.The_Unicode_u_flag_and_the_Unicode_Sets_v_flag_cannot_be_set_simultaneously, p, size) - } else { - regExpFlags |= flag - s.checkRegularExpressionFlagAvailable(flag, p) + if shouldReportErrors { + flag, ok := CharacterToRegularExpressionFlag(ch) + if !ok { + s.errorAt(diagnostics.Unknown_regular_expression_flag, p, size) + } else if regExpFlags&flag != 0 { + s.errorAt(diagnostics.Duplicate_regular_expression_flag, p, size) + } else if (regExpFlags|flag)&RegularExpressionFlagsAnyUnicodeMode == RegularExpressionFlagsAnyUnicodeMode { + s.errorAt(diagnostics.The_Unicode_u_flag_and_the_Unicode_Sets_v_flag_cannot_be_set_simultaneously, p, size) + } else { + regExpFlags |= flag + s.checkRegularExpressionFlagAvailable(flag, p) + } } p += size } - s.pos = startOfRegExpBody - saveTokenPos := s.tokenStart - saveTokenFlags := s.tokenFlags - parser := ®ExpParser{ - scanner: s, - end: endOfRegExpBody, - regExpFlags: regExpFlags, - anyUnicodeMode: regExpFlags&RegularExpressionFlagsAnyUnicodeMode != 0, - unicodeSetsMode: regExpFlags&RegularExpressionFlagsUnicodeSets != 0, - groupSpecifiers: make(map[string]bool), + if shouldReportErrors { + s.pos = startOfRegExpBody + saveTokenPos := s.tokenStart + saveTokenFlags := s.tokenFlags + parser := ®ExpParser{ + scanner: s, + end: endOfRegExpBody, + regExpFlags: regExpFlags, + anyUnicodeMode: regExpFlags&RegularExpressionFlagsAnyUnicodeMode != 0, + unicodeSetsMode: regExpFlags&RegularExpressionFlagsUnicodeSets != 0, + annexB: true, + groupSpecifiers: make(map[string]bool), + } + parser.run() + s.pos = p + s.tokenStart = saveTokenPos + s.tokenFlags = saveTokenFlags + } else { + s.pos = p } - parser.run() - s.tokenStart = saveTokenPos - s.tokenFlags = saveTokenFlags } s.pos = p @@ -1672,10 +1681,12 @@ func (s *Scanner) scanEscapeSequence(flags EscapeSequenceScanningFlags) string { s.tokenFlags |= ast.TokenFlagsContainsInvalidEscape if flags&EscapeSequenceScanningFlagsReportInvalidEscapeErrors != 0 { code, _ := strconv.ParseInt(s.text[start+1:s.pos], 8, 32) - if flags&EscapeSequenceScanningFlagsRegularExpression != 0 && flags&EscapeSequenceScanningFlagsAtomEscape == 0 && ch != '0' { - s.errorAt(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, s.pos-start, "\\x"+fmt.Sprintf("%02x", code)) - } else { - s.errorAt(diagnostics.Octal_escape_sequences_are_not_allowed_Use_the_syntax_0, start, s.pos-start, "\\x"+fmt.Sprintf("%02x", code)) + if flags&EscapeSequenceScanningFlagsAnnexB == 0 { + if flags&EscapeSequenceScanningFlagsRegularExpression != 0 && flags&EscapeSequenceScanningFlagsAtomEscape == 0 && ch != '0' { + s.errorAt(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, s.pos-start, "\\x"+fmt.Sprintf("%02x", code)) + } else { + s.errorAt(diagnostics.Octal_escape_sequences_are_not_allowed_Use_the_syntax_0, start, s.pos-start, "\\x"+fmt.Sprintf("%02x", code)) + } } return string(rune(code)) } diff --git a/testdata/baselines/reference/submodule/compiler/doYouNeedToChangeYourTargetLibraryES2016Plus.errors.txt b/testdata/baselines/reference/submodule/compiler/doYouNeedToChangeYourTargetLibraryES2016Plus.errors.txt index a7240a31cc5..15df2d938b1 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. @@ -34,7 +40,7 @@ doYouNeedToChangeYourTargetLibraryES2016Plus.ts(44,33): error TS2550: Property ' doYouNeedToChangeYourTargetLibraryES2016Plus.ts(47,46): error TS2550: Property 'toTemporalInstant' does not exist on type 'Date'. Do you need to change your target library? Try changing the 'lib' compiler option to 'esnext' or later. -==== doYouNeedToChangeYourTargetLibraryES2016Plus.ts (34 errors) ==== +==== doYouNeedToChangeYourTargetLibraryES2016Plus.ts (40 errors) ==== // es2016 const testIncludes = ["hello"].includes("world"); ~~~~~~~~ @@ -71,9 +77,21 @@ doYouNeedToChangeYourTargetLibraryES2016Plus.ts(47,46): 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 143334c8331..00000000000 --- 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 -32, +26 lines =@@ - doYouNeedToChangeYourTargetLibraryES2016Plus.ts(47,46): error TS2550: Property 'toTemporalInstant' does not exist on type 'Date'. Do you need to change your target library? Try changing the 'lib' compiler option to 'esnext' or later. - - --==== doYouNeedToChangeYourTargetLibraryES2016Plus.ts (40 errors) ==== -+==== doYouNeedToChangeYourTargetLibraryES2016Plus.ts (34 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 index fb5540bc6ba..eb71d3c8153 100644 --- a/testdata/baselines/reference/submodule/compiler/regExpWithOpenBracketInCharClass(target=es2015).errors.txt +++ b/testdata/baselines/reference/submodule/compiler/regExpWithOpenBracketInCharClass(target=es2015).errors.txt @@ -1,12 +1,15 @@ regExpWithOpenBracketInCharClass.ts(4,7): error TS1005: ']' expected. +regExpWithOpenBracketInCharClass.ts(4,8): error TS1501: This regular expression flag is only available when targeting 'esnext' or later. -==== regExpWithOpenBracketInCharClass.ts (1 errors) ==== +==== 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 'esnext' 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 index a9778523c99..db83779eeaa 100644 --- a/testdata/baselines/reference/submodule/compiler/regExpWithOpenBracketInCharClass(target=es2015).errors.txt.diff +++ b/testdata/baselines/reference/submodule/compiler/regExpWithOpenBracketInCharClass(target=es2015).errors.txt.diff @@ -3,19 +3,15 @@ @@= 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) ==== -+ -+ -+==== regExpWithOpenBracketInCharClass.ts (1 errors) ==== - const regexes: RegExp[] = [ - /[[]/, // Valid - /[[]/u, // Valid - /[[]/v, // Well-terminated regex with an incomplete character class ++regExpWithOpenBracketInCharClass.ts(4,8): error TS1501: This regular expression flag is only available when targeting 'esnext' or later. + + + ==== regExpWithOpenBracketInCharClass.ts (2 errors) ==== +@@= skipped -9, +9 lines =@@ !!! error TS1005: ']' expected. -- ~ + ~ -!!! 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 'esnext' or later. ]; \ 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 index 0c3852afade..d8d00e737f9 100644 --- a/testdata/baselines/reference/submodule/compiler/regularExpressionAnnexB.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/regularExpressionAnnexB.errors.txt @@ -4,7 +4,6 @@ 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(4,9): error TS1516: A character class range must not be bounded by another character class. 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. @@ -98,7 +97,7 @@ regularExpressionAnnexB.ts(42,5): error TS1506: Numbers out of order in quantifi regularExpressionAnnexB.ts(42,10): error TS1507: There is nothing available for repetition. -==== regularExpressionAnnexB.ts (98 errors) ==== +==== regularExpressionAnnexB.ts (97 errors) ==== const regexes: RegExp[] = [ /\q\u\i\c\k\_\f\o\x\-\j\u\m\p\s/, @@ -115,8 +114,6 @@ regularExpressionAnnexB.ts(42,10): error TS1507: There is nothing available for !!! error TS1125: Hexadecimal digit expected. /\P[\P\w-_]/, - ~~ -!!! error TS1516: A character class range must not be bounded by another character class. // Compare to /\q\u\i\c\k\_\f\o\x\-\j\u\m\p\s/u, diff --git a/testdata/baselines/reference/submodule/compiler/regularExpressionAnnexB.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/regularExpressionAnnexB.errors.txt.diff index 433267a2060..10916305475 100644 --- a/testdata/baselines/reference/submodule/compiler/regularExpressionAnnexB.errors.txt.diff +++ b/testdata/baselines/reference/submodule/compiler/regularExpressionAnnexB.errors.txt.diff @@ -1,14 +1,6 @@ --- old.regularExpressionAnnexB.errors.txt +++ new.regularExpressionAnnexB.errors.txt -@@= skipped -3, +3 lines =@@ - 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(4,9): error TS1516: A character class range must not be bounded by another character class. - 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. -@@= skipped -23, +24 lines =@@ +@@= skipped -26, +26 lines =@@ 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. @@ -43,20 +35,11 @@ -==== regularExpressionAnnexB.ts (74 errors) ==== -+==== regularExpressionAnnexB.ts (98 errors) ==== ++==== regularExpressionAnnexB.ts (97 errors) ==== const regexes: RegExp[] = [ /\q\u\i\c\k\_\f\o\x\-\j\u\m\p\s/, -@@= skipped -17, +17 lines =@@ - - !!! error TS1125: Hexadecimal digit expected. - /\P[\P\w-_]/, -+ ~~ -+!!! error TS1516: A character class range must not be bounded by another character class. - - // Compare to - /\q\u\i\c\k\_\f\o\x\-\j\u\m\p\s/u, -@@= skipped -57, +59 lines =@@ +@@= skipped -74, +74 lines =@@ /{??/, /{,??/, /{,1??/, diff --git a/testdata/baselines/reference/submodule/compiler/regularExpressionGroupNameSuggestions.errors.txt b/testdata/baselines/reference/submodule/compiler/regularExpressionGroupNameSuggestions.errors.txt index bbb5d0c1927..dd244b2851d 100644 --- a/testdata/baselines/reference/submodule/compiler/regularExpressionGroupNameSuggestions.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/regularExpressionGroupNameSuggestions.errors.txt @@ -1,8 +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 (1 errors) ==== +==== 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 regularExpressionGroupNameSuggestions.ts:1:27: 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 index 0e554ac1c9c..fe8737b4d30 100644 --- a/testdata/baselines/reference/submodule/compiler/regularExpressionGroupNameSuggestions.errors.txt.diff +++ b/testdata/baselines/reference/submodule/compiler/regularExpressionGroupNameSuggestions.errors.txt.diff @@ -1,16 +1,9 @@ --- 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) ==== -+==== regularExpressionGroupNameSuggestions.ts (1 errors) ==== - const regex = /(?)\k/; -- ~~~~~ --!!! error TS1503: Named capturing groups are only available when targeting 'ES2018' or later. +@@= skipped -7, +7 lines =@@ + !!! 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'? ++!!! related TS1369 regularExpressionGroupNameSuggestions.ts:1:27: 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 index 39f64480484..23a680bac96 100644 --- a/testdata/baselines/reference/submodule/compiler/regularExpressionScanning(target=es2015).errors.txt +++ b/testdata/baselines/reference/submodule/compiler/regularExpressionScanning(target=es2015).errors.txt @@ -1,9 +1,12 @@ +regularExpressionScanning.ts(3,7): error TS1501: This regular expression flag is only available when targeting 'esnext' 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. @@ -14,19 +17,7 @@ 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'. @@ -38,7 +29,16 @@ regularExpressionScanning.ts(13,47): error TS1533: This backreference refers to 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. @@ -46,10 +46,7 @@ regularExpressionScanning.ts(17,40): error TS1507: There is nothing available fo regularExpressionScanning.ts(17,61): error TS1505: Incomplete quantifier. Digit expected. 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,22): error TS1516: A character class range must not be bounded by another character class. regularExpressionScanning.ts(19,28): error TS1517: Range out of order in character class. -regularExpressionScanning.ts(19,33): error TS1516: A character class range must not be bounded by another character class. -regularExpressionScanning.ts(19,36): error TS1516: A character class range must not be bounded by another 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. @@ -64,6 +61,7 @@ regularExpressionScanning.ts(21,28): error TS1529: Unknown Unicode property name 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 'esnext' 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. @@ -99,6 +97,7 @@ regularExpressionScanning.ts(25,53): error TS1531: '\p' must be followed by a Un 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 'esnext' 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. @@ -114,6 +113,7 @@ regularExpressionScanning.ts(27,47): error TS1528: Any Unicode property that wou 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 'esnext' 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. @@ -145,6 +145,7 @@ regularExpressionScanning.ts(34,42): error TS1508: Unexpected ']'. Did you mean 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 'esnext' 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. @@ -179,28 +180,42 @@ 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 'esnext' 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 'esnext' or later. +regularExpressionScanning.ts(40,83): error TS1501: This regular expression flag is only available when targeting 'esnext' 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 'esnext' 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 'esnext' or later. +regularExpressionScanning.ts(43,95): error TS1501: This regular expression flag is only available when targeting 'esnext' 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 'esnext' 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 'esnext' 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 'esnext' 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 'esnext' or later. -==== regularExpressionScanning.ts (197 errors) ==== +==== regularExpressionScanning.ts (208 errors) ==== const regexes: RegExp[] = [ // Flags /foo/visualstudiocode, + ~ +!!! error TS1501: This regular expression flag is only available when targeting 'esnext' 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. ~ @@ -213,6 +228,8 @@ regularExpressionScanning.ts(47,89): error TS1518: Anything that would possibly !!! 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. ~ @@ -238,36 +255,12 @@ regularExpressionScanning.ts(47,89): error TS1518: Anything that would possibly // 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. @@ -292,9 +285,27 @@ regularExpressionScanning.ts(47,89): error TS1518: Anything that would possibly ~~~ !!! 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 @@ -313,14 +324,8 @@ regularExpressionScanning.ts(47,89): error TS1518: Anything that would possibly !!! error TS1517: Range out of order in character class. ~~~ !!! error TS1517: Range out of order in character class. - ~~ -!!! error TS1516: A character class range must not be bounded by another character class. ~~~~~ !!! error TS1517: Range out of order in character class. - ~~ -!!! error TS1516: A character class range must not be bounded by another character class. - ~~ -!!! error TS1516: A character class range must not be bounded by another 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. @@ -352,6 +357,8 @@ regularExpressionScanning.ts(47,89): error TS1518: Anything that would possibly !!! 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 'esnext' 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. @@ -425,6 +432,8 @@ regularExpressionScanning.ts(47,89): error TS1518: Anything that would possibly !!! 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 'esnext' 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. @@ -458,6 +467,8 @@ regularExpressionScanning.ts(47,89): error TS1518: Anything that would possibly !!! error TS1518: Anything that would possibly match more than a single character is invalid inside a negated character class. ~~~~~~~~~ !!! 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 'esnext' or later. // Character escapes /\c[\c0\ca\cQ\c\C]\c1\C/, /\c[\c0\ca\cQ\c\C]\c1\C/u, @@ -526,6 +537,8 @@ regularExpressionScanning.ts(47,89): error TS1518: Anything that would possibly !!! 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 'esnext' or later. // Unicode sets notation /[a--b[--][\d++[]]&&[[&0-9--]&&[\p{L}]--\P{L}-_-]]&&&\q{foo}[0---9][&&q&&&\q{bar}&&]/, ~~~ @@ -598,17 +611,25 @@ regularExpressionScanning.ts(47,89): error TS1518: Anything that would possibly !!! 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 'esnext' 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 'esnext' 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 'esnext' 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 'esnext' 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. @@ -616,12 +637,18 @@ regularExpressionScanning.ts(47,89): error TS1518: Anything that would possibly !!! error TS1518: Anything that would possibly match more than a single character is invalid inside a negated character class. ~~~~~~~~~~~~~~~~~~~~~~ !!! 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 'esnext' 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 'esnext' 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 'esnext' 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. @@ -629,15 +656,21 @@ regularExpressionScanning.ts(47,89): error TS1518: Anything that would possibly !!! error TS1518: Anything that would possibly match more than a single character is invalid inside a negated character class. ~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! 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 'esnext' 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 'esnext' 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 'esnext' 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 index 5fac0651913..fd28b32cd20 100644 --- a/testdata/baselines/reference/submodule/compiler/regularExpressionScanning(target=es2015).errors.txt.diff +++ b/testdata/baselines/reference/submodule/compiler/regularExpressionScanning(target=es2015).errors.txt.diff @@ -2,161 +2,167 @@ +++ 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,7): error TS1501: This regular expression flag is only available when targeting 'esnext' 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. -@@= skipped -40, +37 lines =@@ - 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. +@@= skipped -16, +16 lines =@@ + 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'. +@@= skipped -38, +26 lines =@@ 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(17,61): error TS1505: Incomplete quantifier. Digit expected. 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,22): error TS1516: A character class range must not be bounded by another character class. regularExpressionScanning.ts(19,28): error TS1517: Range out of order in character class. -+regularExpressionScanning.ts(19,33): error TS1516: A character class range must not be bounded by another character class. -+regularExpressionScanning.ts(19,36): error TS1516: A character class range must not be bounded by another 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. -@@= skipped -31, +26 lines =@@ +@@= skipped -17, +18 lines =@@ 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(22,72): error TS1501: This regular expression flag is only available when targeting 'esnext' 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. -@@= skipped -36, +35 lines =@@ +@@= skipped -36, +36 lines =@@ 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(25,67): error TS1501: This regular expression flag is only available when targeting 'esnext' 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. -@@= skipped -16, +15 lines =@@ +@@= skipped -16, +16 lines =@@ 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(28,59): error TS1501: This regular expression flag is only available when targeting 'esnext' 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. -@@= skipped -32, +31 lines =@@ +@@= skipped -32, +32 lines =@@ 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(34,47): error TS1501: This regular expression flag is only available when targeting 'esnext' 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. -@@= skipped -35, +34 lines =@@ +@@= skipped -35, +35 lines =@@ 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(38,87): error TS1501: This regular expression flag is only available when targeting 'esnext' 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(39,77): error TS1501: This regular expression flag is only available when targeting 'esnext' or later. ++regularExpressionScanning.ts(40,83): error TS1501: This regular expression flag is only available when targeting 'esnext' 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(41,83): error TS1501: This regular expression flag is only available when targeting 'esnext' 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(42,77): error TS1501: This regular expression flag is only available when targeting 'esnext' or later. ++regularExpressionScanning.ts(43,95): error TS1501: This regular expression flag is only available when targeting 'esnext' 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(44,95): error TS1501: This regular expression flag is only available when targeting 'esnext' 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(45,89): error TS1501: This regular expression flag is only available when targeting 'esnext' 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(46,91): error TS1501: This regular expression flag is only available when targeting 'esnext' 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) ==== ++regularExpressionScanning.ts(47,101): error TS1501: This regular expression flag is only available when targeting 'esnext' or later. + + -+==== regularExpressionScanning.ts (197 errors) ==== ++==== regularExpressionScanning.ts (208 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 TS1501: This regular expression flag is only available when targeting 'esnext' 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. - ~ -@@= skipped -48, +34 lines =@@ - !!! 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. - ~ -@@= skipped -81, +79 lines =@@ - ~~~ - !!! 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 -@@= skipped -31, +13 lines =@@ +@@= skipped -75, +75 lines =@@ + // 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. +@@= skipped -85, +61 lines =@@ !!! error TS1506: Numbers out of order in quantifier. ~~~~~~~~~ !!! error TS1507: There is nothing available for repetition. @@ -165,120 +171,113 @@ // 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 TS1516: A character class range must not be bounded by another character class. - ~~~~~ - !!! error TS1517: Range out of order in character class. -+ ~~ -+!!! error TS1516: A character class range must not be bounded by another character class. -+ ~~ -+!!! error TS1516: A character class range must not be bounded by another 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. -@@= skipped -39, +47 lines =@@ - !!! error TS1529: Unknown Unicode property name or value. +@@= skipped -40, +42 lines =@@ ~~~~~~~ !!! error TS1529: Unknown Unicode property name or value. -- ~ + ~ -!!! 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 'esnext' 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. -@@= skipped -75, +73 lines =@@ - !!! error TS1527: Expected a Unicode property name or value. +@@= skipped -75, +75 lines =@@ !!! error TS1527: Expected a Unicode property name or value. -- ~ + ~ -!!! 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 'esnext' 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. -@@= skipped -35, +33 lines =@@ - !!! error TS1518: Anything that would possibly match more than a single character is invalid inside a negated character class. +@@= skipped -35, +35 lines =@@ ~~~~~~~~~ !!! 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. ++!!! error TS1501: This regular expression flag is only available when targeting 'esnext' or later. // Character escapes /\c[\c0\ca\cQ\c\C]\c1\C/, /\c[\c0\ca\cQ\c\C]\c1\C/u, -@@= skipped -70, +68 lines =@@ - !!! error TS1508: Unexpected '{'. Did you mean to escape it with backslash? +@@= skipped -70, +70 lines =@@ !!! error TS1005: '}' expected. -- ~ + ~ -!!! 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 'esnext' or later. // Unicode sets notation /[a--b[--][\d++[]]&&[[&0-9--]&&[\p{L}]--\P{L}-_-]]&&&\q{foo}[0---9][&&q&&&\q{bar}&&]/, ~~~ -@@= skipped -74, +72 lines =@@ - !!! error TS1508: Unexpected '&'. Did you mean to escape it with backslash? +@@= skipped -74, +74 lines =@@ !!! error TS1520: Expected a class set operand. -- ~ + ~ -!!! 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 'esnext' 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. ++!!! error TS1501: This regular expression flag is only available when targeting 'esnext' 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. ++!!! error TS1501: This regular expression flag is only available when targeting 'esnext' 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. ++!!! error TS1501: This regular expression flag is only available when targeting 'esnext' 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. -@@= skipped -26, +18 lines =@@ - !!! error TS1518: Anything that would possibly match more than a single character is invalid inside a negated character class. +@@= skipped -26, +26 lines =@@ ~~~~~~~~~~~~~~~~~~~~~~ !!! 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. ++!!! error TS1501: This regular expression flag is only available when targeting 'esnext' 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. ++!!! error TS1501: This regular expression flag is only available when targeting 'esnext' 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. ++!!! error TS1501: This regular expression flag is only available when targeting 'esnext' 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. -@@= skipped -19, +13 lines =@@ - !!! error TS1518: Anything that would possibly match more than a single character is invalid inside a negated character class. +@@= skipped -19, +19 lines =@@ ~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! 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. ++!!! error TS1501: This regular expression flag is only available when targeting 'esnext' 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. ++!!! error TS1501: This regular expression flag is only available when targeting 'esnext' 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. ++!!! error TS1501: This regular expression flag is only available when targeting 'esnext' 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 index 39f64480484..570c015fe55 100644 --- a/testdata/baselines/reference/submodule/compiler/regularExpressionScanning(target=esnext).errors.txt +++ b/testdata/baselines/reference/submodule/compiler/regularExpressionScanning(target=esnext).errors.txt @@ -14,19 +14,7 @@ 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'. @@ -46,10 +34,7 @@ regularExpressionScanning.ts(17,40): error TS1507: There is nothing available fo regularExpressionScanning.ts(17,61): error TS1505: Incomplete quantifier. Digit expected. 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,22): error TS1516: A character class range must not be bounded by another character class. regularExpressionScanning.ts(19,28): error TS1517: Range out of order in character class. -regularExpressionScanning.ts(19,33): error TS1516: A character class range must not be bounded by another character class. -regularExpressionScanning.ts(19,36): error TS1516: A character class range must not be bounded by another 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. @@ -197,7 +182,7 @@ regularExpressionScanning.ts(47,5): error TS1518: Anything that would possibly m regularExpressionScanning.ts(47,89): error TS1518: Anything that would possibly match more than a single character is invalid inside a negated character class. -==== regularExpressionScanning.ts (197 errors) ==== +==== regularExpressionScanning.ts (182 errors) ==== const regexes: RegExp[] = [ // Flags /foo/visualstudiocode, @@ -238,36 +223,12 @@ regularExpressionScanning.ts(47,89): error TS1518: Anything that would possibly // 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. @@ -313,14 +274,8 @@ regularExpressionScanning.ts(47,89): error TS1518: Anything that would possibly !!! error TS1517: Range out of order in character class. ~~~ !!! error TS1517: Range out of order in character class. - ~~ -!!! error TS1516: A character class range must not be bounded by another character class. ~~~~~ !!! error TS1517: Range out of order in character class. - ~~ -!!! error TS1516: A character class range must not be bounded by another character class. - ~~ -!!! error TS1516: A character class range must not be bounded by another 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. 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 index 9d73f20db1c..9ae7ded5e53 100644 --- a/testdata/baselines/reference/submodule/compiler/regularExpressionScanning(target=esnext).errors.txt.diff +++ b/testdata/baselines/reference/submodule/compiler/regularExpressionScanning(target=esnext).errors.txt.diff @@ -1,29 +1,80 @@ --- old.regularExpressionScanning(target=esnext).errors.txt +++ new.regularExpressionScanning(target=esnext).errors.txt -@@= skipped -42, +42 lines =@@ +@@= skipped -13, +13 lines =@@ + 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'. +@@= skipped -29, +17 lines =@@ 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(17,61): error TS1505: Incomplete quantifier. Digit expected. 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,22): error TS1516: A character class range must not be bounded by another character class. regularExpressionScanning.ts(19,28): error TS1517: Range out of order in character class. -+regularExpressionScanning.ts(19,33): error TS1516: A character class range must not be bounded by another character class. -+regularExpressionScanning.ts(19,36): error TS1516: A character class range must not be bounded by another 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. -@@= skipped -150, +154 lines =@@ +@@= skipped -150, +151 lines =@@ regularExpressionScanning.ts(47,89): error TS1518: Anything that would possibly match more than a single character is invalid inside a negated character class. -==== regularExpressionScanning.ts (193 errors) ==== -+==== regularExpressionScanning.ts (197 errors) ==== ++==== regularExpressionScanning.ts (182 errors) ==== const regexes: RegExp[] = [ // Flags /foo/visualstudiocode, -@@= skipped -108, +108 lines =@@ +@@= skipped -41, +41 lines =@@ + // 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. +@@= skipped -67, +43 lines =@@ !!! error TS1506: Numbers out of order in quantifier. ~~~~~~~~~ !!! error TS1507: There is nothing available for repetition. @@ -31,18 +82,4 @@ +!!! error TS1505: Incomplete quantifier. Digit expected. // 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 TS1516: A character class range must not be bounded by another character class. - ~~~~~ - !!! error TS1517: Range out of order in character class. -+ ~~ -+!!! error TS1516: A character class range must not be bounded by another character class. -+ ~~ -+!!! error TS1516: A character class range must not be bounded by another 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. \ No newline at end of file + ~~~ \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/regularExpressionUnicodePropertyValueExpressionSuggestions(target=es2015).errors.txt b/testdata/baselines/reference/submodule/compiler/regularExpressionUnicodePropertyValueExpressionSuggestions(target=es2015).errors.txt index 904863c7add..81ed855de4b 100644 --- a/testdata/baselines/reference/submodule/compiler/regularExpressionUnicodePropertyValueExpressionSuggestions(target=es2015).errors.txt +++ b/testdata/baselines/reference/submodule/compiler/regularExpressionUnicodePropertyValueExpressionSuggestions(target=es2015).errors.txt @@ -9,12 +9,17 @@ regularExpressionUnicodePropertyValueExpressionSuggestions.ts(1,93): error TS152 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 regularExpressionUnicodePropertyValueExpressionSuggestions.ts:1:19: Did you mean 'ASCII'? ~~ !!! error TS1524: Unknown Unicode property name. +!!! related TS1369 regularExpressionUnicodePropertyValueExpressionSuggestions.ts:1:28: Did you mean 'sc'? ~~~~~~~~ !!! error TS1526: Unknown Unicode property value. +!!! related TS1369 regularExpressionUnicodePropertyValueExpressionSuggestions.ts:1:45: Did you mean 'Unknown'? ~~~~~~~~~~~~~~~~~~ !!! error TS1524: Unknown Unicode property name. +!!! related TS1369 regularExpressionUnicodePropertyValueExpressionSuggestions.ts:1:57: Did you mean 'Script_Extensions'? ~~~~~~~ !!! error TS1526: Unknown Unicode property value. +!!! related TS1369 regularExpressionUnicodePropertyValueExpressionSuggestions.ts:1:93: Did you mean 'Inherited'? \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/regularExpressionUnicodePropertyValueExpressionSuggestions(target=es2015).errors.txt.diff b/testdata/baselines/reference/submodule/compiler/regularExpressionUnicodePropertyValueExpressionSuggestions(target=es2015).errors.txt.diff index 5c4651e5727..5f6753c5d5b 100644 --- a/testdata/baselines/reference/submodule/compiler/regularExpressionUnicodePropertyValueExpressionSuggestions(target=es2015).errors.txt.diff +++ b/testdata/baselines/reference/submodule/compiler/regularExpressionUnicodePropertyValueExpressionSuggestions(target=es2015).errors.txt.diff @@ -5,16 +5,21 @@ ~~~~~ !!! error TS1529: Unknown Unicode property name or value. -!!! related TS1369: Did you mean 'ASCII'? ++!!! related TS1369 regularExpressionUnicodePropertyValueExpressionSuggestions.ts:1:19: Did you mean 'ASCII'? ~~ !!! error TS1524: Unknown Unicode property name. -!!! related TS1369: Did you mean 'sc'? ++!!! related TS1369 regularExpressionUnicodePropertyValueExpressionSuggestions.ts:1:28: Did you mean 'sc'? ~~~~~~~~ !!! error TS1526: Unknown Unicode property value. -!!! related TS1369: Did you mean 'Unknown'? ++!!! related TS1369 regularExpressionUnicodePropertyValueExpressionSuggestions.ts:1:45: Did you mean 'Unknown'? ~~~~~~~~~~~~~~~~~~ !!! error TS1524: Unknown Unicode property name. -!!! related TS1369: Did you mean 'Script_Extensions'? ++!!! related TS1369 regularExpressionUnicodePropertyValueExpressionSuggestions.ts:1:57: Did you mean 'Script_Extensions'? ~~~~~~~ !!! error TS1526: Unknown Unicode property value. -!!! related TS1369: Did you mean 'Inherited'? ++!!! related TS1369 regularExpressionUnicodePropertyValueExpressionSuggestions.ts:1:93: Did you mean 'Inherited'? \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/shebangError.errors.txt b/testdata/baselines/reference/submodule/compiler/shebangError.errors.txt index 1667c8d9ed8..63d8730735c 100644 --- a/testdata/baselines/reference/submodule/compiler/shebangError.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/shebangError.errors.txt @@ -1,14 +1,12 @@ shebangError.ts(2,1): error TS18026: '#!' can only be used at the start of a file. shebangError.ts(2,2): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type. shebangError.ts(2,3): error TS2872: This kind of expression is always truthy. -shebangError.ts(2,8): error TS1499: Unknown regular expression flag. -shebangError.ts(2,10): error TS1499: Unknown regular expression flag. shebangError.ts(2,12): error TS2304: Cannot find name 'env'. shebangError.ts(2,16): error TS1005: ';' expected. shebangError.ts(2,16): error TS2304: Cannot find name 'node'. -==== shebangError.ts (8 errors) ==== +==== shebangError.ts (6 errors) ==== var foo = 'Shebang is only allowed on the first line'; #!/usr/bin/env node ~~ @@ -17,10 +15,6 @@ shebangError.ts(2,16): error TS2304: Cannot find name 'node'. !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type. ~~~~~~~~ !!! error TS2872: This kind of expression is always truthy. - ~ -!!! error TS1499: Unknown regular expression flag. - ~ -!!! error TS1499: Unknown regular expression flag. ~~~ !!! error TS2304: Cannot find name 'env'. ~~~~ diff --git a/testdata/baselines/reference/submodule/compiler/shebangError.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/shebangError.errors.txt.diff deleted file mode 100644 index ce8fb26689a..00000000000 --- a/testdata/baselines/reference/submodule/compiler/shebangError.errors.txt.diff +++ /dev/null @@ -1,29 +0,0 @@ ---- old.shebangError.errors.txt -+++ new.shebangError.errors.txt -@@= skipped -0, +0 lines =@@ - shebangError.ts(2,1): error TS18026: '#!' can only be used at the start of a file. - shebangError.ts(2,2): error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type. - shebangError.ts(2,3): error TS2872: This kind of expression is always truthy. -+shebangError.ts(2,8): error TS1499: Unknown regular expression flag. -+shebangError.ts(2,10): error TS1499: Unknown regular expression flag. - shebangError.ts(2,12): error TS2304: Cannot find name 'env'. - shebangError.ts(2,16): error TS1005: ';' expected. - shebangError.ts(2,16): error TS2304: Cannot find name 'node'. - - --==== shebangError.ts (6 errors) ==== -+==== shebangError.ts (8 errors) ==== - var foo = 'Shebang is only allowed on the first line'; - #!/usr/bin/env node - ~~ -@@= skipped -14, +16 lines =@@ - !!! error TS2362: The left-hand side of an arithmetic operation must be of type 'any', 'number', 'bigint' or an enum type. - ~~~~~~~~ - !!! error TS2872: This kind of expression is always truthy. -+ ~ -+!!! error TS1499: Unknown regular expression flag. -+ ~ -+!!! error TS1499: Unknown regular expression flag. - ~~~ - !!! error TS2304: Cannot find name 'env'. - ~~~~ \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/parserRegularExpression1.errors.txt b/testdata/baselines/reference/submodule/conformance/parserRegularExpression1.errors.txt deleted file mode 100644 index baa62032beb..00000000000 --- a/testdata/baselines/reference/submodule/conformance/parserRegularExpression1.errors.txt +++ /dev/null @@ -1,7 +0,0 @@ -parserRegularExpression1.ts(1,27): error TS1516: A character class range must not be bounded by another character class. - - -==== parserRegularExpression1.ts (1 errors) ==== - /(#?-?\d*\.\d\w*%?)|(@?#?[\w-?]+%?)/g; - ~~ -!!! error TS1516: A character class range must not be bounded by another character class. \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/conformance/parserRegularExpression1.errors.txt.diff b/testdata/baselines/reference/submodule/conformance/parserRegularExpression1.errors.txt.diff deleted file mode 100644 index b415611df90..00000000000 --- a/testdata/baselines/reference/submodule/conformance/parserRegularExpression1.errors.txt.diff +++ /dev/null @@ -1,11 +0,0 @@ ---- old.parserRegularExpression1.errors.txt -+++ new.parserRegularExpression1.errors.txt -@@= skipped -0, +0 lines =@@ -- -+parserRegularExpression1.ts(1,27): error TS1516: A character class range must not be bounded by another character class. -+ -+ -+==== parserRegularExpression1.ts (1 errors) ==== -+ /(#?-?\d*\.\d\w*%?)|(@?#?[\w-?]+%?)/g; -+ ~~ -+!!! error TS1516: A character class range must not be bounded by another character class. \ No newline at end of file From c091575311148ca61b43c056f60e6fccf1a596fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Burzy=C5=84ski?= Date: Mon, 23 Feb 2026 11:12:10 +0100 Subject: [PATCH 05/43] Port "Correct Regular Expressions Behavior Related to Annex B" Co-authored-by: graphemecluster --- internal/scanner/regexp.go | 63 ++++++----- internal/scanner/scanner.go | 34 +++--- .../regularExpressionAnnexB.errors.txt | 71 +----------- .../regularExpressionAnnexB.errors.txt.diff | 101 ------------------ ...pressionScanning(target=es2015).errors.txt | 41 ++++++- ...ionScanning(target=es2015).errors.txt.diff | 89 ++------------- ...pressionScanning(target=esnext).errors.txt | 41 ++++++- ...ionScanning(target=esnext).errors.txt.diff | 85 --------------- 8 files changed, 141 insertions(+), 384 deletions(-) delete mode 100644 testdata/baselines/reference/submodule/compiler/regularExpressionAnnexB.errors.txt.diff delete mode 100644 testdata/baselines/reference/submodule/compiler/regularExpressionScanning(target=esnext).errors.txt.diff diff --git a/internal/scanner/regexp.go b/internal/scanner/regexp.go index 9797cea97fe..f933f909594 100644 --- a/internal/scanner/regexp.go +++ b/internal/scanner/regexp.go @@ -84,6 +84,9 @@ type regExpParser struct { unicodeSetsMode bool annexB bool + anyUnicodeModeOrNonAnnexB bool + namedCaptureGroups bool + mayContainStrings bool numberOfCapturingGroups int groupSpecifiers map[string]bool @@ -197,7 +200,7 @@ func (p *regExpParser) scanAlternative(isInGroup bool) { case '=', '!': p.incPos(1) // In Annex B, `(?=Disjunction)` and `(?!Disjunction)` are quantifiable - isPreviousTermQuantifiable = p.annexB + isPreviousTermQuantifiable = !p.anyUnicodeModeOrNonAnnexB case '<': groupNameStart := p.pos() p.incPos(1) @@ -238,6 +241,10 @@ func (p *regExpParser) scanAlternative(isInGroup bool) { digitsStart := p.pos() p.scanDigits() min := p.scanner.tokenValue + if !p.anyUnicodeModeOrNonAnnexB && min == "" { + isPreviousTermQuantifiable = true + continue + } if p.charAt(p.pos()) == ',' { p.incPos(1) p.scanDigits() @@ -246,29 +253,33 @@ func (p *regExpParser) scanAlternative(isInGroup bool) { if max != "" || p.charAt(p.pos()) == '}' { p.error(diagnostics.Incomplete_quantifier_Digit_expected, digitsStart, 0) } else { - if p.anyUnicodeMode { - p.error(diagnostics.Unexpected_0_Did_you_mean_to_escape_it_with_backslash, start, 1, string(ch)) - } + p.error(diagnostics.Unexpected_0_Did_you_mean_to_escape_it_with_backslash, start, 1, string(ch)) isPreviousTermQuantifiable = true continue } - } - if max != "" { + } else if max != "" { minVal, _ := strconv.Atoi(min) maxVal, _ := strconv.Atoi(max) - if minVal > maxVal { + if minVal > maxVal && (p.anyUnicodeModeOrNonAnnexB || p.charAt(p.pos()) == '}') { p.error(diagnostics.Numbers_out_of_order_in_quantifier, digitsStart, p.pos()-digitsStart) } } } else if min == "" { - if p.anyUnicodeMode { + if p.anyUnicodeModeOrNonAnnexB { p.error(diagnostics.Unexpected_0_Did_you_mean_to_escape_it_with_backslash, start, 1, string(ch)) } isPreviousTermQuantifiable = true continue } - p.scanExpectedChar('}') - p.incPos(-1) + if p.charAt(p.pos()) != '}' { + if p.anyUnicodeModeOrNonAnnexB { + p.error(diagnostics.X_0_expected, p.pos(), 0, "}") + p.incPos(-1) + } else { + isPreviousTermQuantifiable = true + continue + } + } // falls through to quantifier handling fallthrough case '*', '+', '?': @@ -298,7 +309,7 @@ func (p *regExpParser) scanAlternative(isInGroup bool) { } fallthrough case ']', '}': - if p.anyUnicodeMode || ch == ')' { + if p.anyUnicodeModeOrNonAnnexB || ch == ')' { p.error(diagnostics.Unexpected_0_Did_you_mean_to_escape_it_with_backslash, p.pos(), 1, string(ch)) } p.incPos(1) @@ -348,7 +359,7 @@ func (p *regExpParser) scanAtomEscape() { p.incPos(1) p.scanGroupName(true /*isReference*/) p.scanExpectedChar('>') - } else if p.anyUnicodeMode { + } else if p.anyUnicodeModeOrNonAnnexB || p.namedCaptureGroups { p.error(diagnostics.X_k_must_be_followed_by_a_capturing_group_name_enclosed_in_angle_brackets, p.pos()-2, 2) } case 'q': @@ -401,9 +412,9 @@ func (p *regExpParser) scanCharacterEscape(atomEscape bool) string { p.incPos(1) return string(rune(ch & 0x1f)) } - if p.anyUnicodeMode { + if p.anyUnicodeModeOrNonAnnexB { p.error(diagnostics.X_c_must_be_followed_by_an_ASCII_letter, p.pos()-2, 2) - } else if atomEscape && p.annexB { + } else if atomEscape { p.incPos(-1) return "\\" } @@ -418,7 +429,7 @@ func (p *regExpParser) scanCharacterEscape(atomEscape bool) string { flags |= EscapeSequenceScanningFlagsAnnexB } if p.anyUnicodeMode { - flags |= EscapeSequenceScanningFlagsReportErrors | EscapeSequenceScanningFlagsAnyUnicodeMode + flags |= EscapeSequenceScanningFlagsAnyUnicodeMode } if atomEscape { flags |= EscapeSequenceScanningFlagsAtomEscape @@ -475,12 +486,12 @@ func (p *regExpParser) scanClassRanges() { if p.isClassContentExit(ch) { return } - if minCharacter == "" && !p.annexB { + if minCharacter == "" && p.anyUnicodeModeOrNonAnnexB { p.error(diagnostics.A_character_class_range_must_not_be_bounded_by_another_character_class, minStart, p.pos()-1-minStart) } maxStart := p.pos() maxCharacter := p.scanClassAtom() - if maxCharacter == "" && !p.annexB { + if maxCharacter == "" && p.anyUnicodeModeOrNonAnnexB { p.error(diagnostics.A_character_class_range_must_not_be_bounded_by_another_character_class, maxStart, p.pos()-maxStart) continue } @@ -879,8 +890,11 @@ func (p *regExpParser) scanCharacterClassEscape() bool { if !p.anyUnicodeMode { p.error(diagnostics.Unicode_property_value_expressions_are_only_available_when_the_Unicode_u_flag_or_the_Unicode_Sets_v_flag_is_set, start, p.pos()-start) } - } else if p.anyUnicodeMode { + } else if p.anyUnicodeModeOrNonAnnexB { p.error(diagnostics.X_0_must_be_followed_by_a_Unicode_property_value_expression_enclosed_in_braces, p.pos()-2, 2, string(ch)) + } else { + p.incPos(-1) + return false } return true } @@ -967,9 +981,9 @@ func (p *regExpParser) scanDigits() { } func (p *regExpParser) run() { - if p.anyUnicodeMode { - p.annexB = false - } + // Regular expressions are checked more strictly when either in 'u' or 'v' mode, or + // when not using the looser interpretation of the syntax from ECMA-262 Annex B. + p.anyUnicodeModeOrNonAnnexB = p.anyUnicodeMode || !p.annexB p.scanDisjunction(false /*isInGroup*/) @@ -989,9 +1003,10 @@ func (p *regExpParser) run() { } } for _, escape := range p.decimalEscapes { - // in AnnexB, if a DecimalEscape is greater than the number of capturing groups then it is treated as - // either a LegacyOctalEscapeSequence or IdentityEscape - if !p.annexB && escape.value > p.numberOfCapturingGroups { + // Although a DecimalEscape with a value greater than the number of capturing groups + // is treated as either a LegacyOctalEscapeSequence or an IdentityEscape in Annex B, + // an error is nevertheless reported since it's most likely a mistake. + if escape.value > p.numberOfCapturingGroups { if p.numberOfCapturingGroups > 0 { p.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, p.numberOfCapturingGroups) } else { diff --git a/internal/scanner/scanner.go b/internal/scanner/scanner.go index 2aee905df09..80cadb08f25 100644 --- a/internal/scanner/scanner.go +++ b/internal/scanner/scanner.go @@ -1053,8 +1053,12 @@ func (s *Scanner) ReScanSlashToken(reportErrors ...bool) ast.Kind { startOfRegExpBody := s.tokenStart + 1 p := startOfRegExpBody inEscape := false + namedCaptureGroups := false // Although nested character classes are allowed in Unicode Sets mode, // an unescaped slash is nevertheless invalid even in a character class in any Unicode mode. + // This is indicated by Section 12.9.5 Regular Expression Literals of the specification, + // where nested character classes are not considered at all. (A `[` RegularExpressionClassChar + // does nothing in a RegularExpressionClass, and a `]` always closes the class.) // Additionally, parsing nested character classes will misinterpret regexes like `/[[]/` // as unterminated, consuming characters beyond the slash. (This even applies to `/[[]/v`, // which should be parsed as a well-terminated regex with an incomplete character class.) @@ -1081,6 +1085,11 @@ func (s *Scanner) ReScanSlashToken(reportErrors ...bool) ast.Kind { inEscape = true } else if ch == ']' { inCharacterClass = false + } else if !inCharacterClass && ch == '(' && + p+1 < len(s.text) && s.text[p+1] == '?' && + p+2 < len(s.text) && s.text[p+2] == '<' && + (p+3 >= len(s.text) || (s.text[p+3] != '=' && s.text[p+3] != '!')) { + namedCaptureGroups = true } p++ } @@ -1160,13 +1169,14 @@ func (s *Scanner) ReScanSlashToken(reportErrors ...bool) ast.Kind { saveTokenPos := s.tokenStart saveTokenFlags := s.tokenFlags parser := ®ExpParser{ - scanner: s, - end: endOfRegExpBody, - regExpFlags: regExpFlags, - anyUnicodeMode: regExpFlags&RegularExpressionFlagsAnyUnicodeMode != 0, - unicodeSetsMode: regExpFlags&RegularExpressionFlagsUnicodeSets != 0, - annexB: true, - groupSpecifiers: make(map[string]bool), + scanner: s, + end: endOfRegExpBody, + regExpFlags: regExpFlags, + anyUnicodeMode: regExpFlags&RegularExpressionFlagsAnyUnicodeMode != 0, + unicodeSetsMode: regExpFlags&RegularExpressionFlagsUnicodeSets != 0, + annexB: true, + namedCaptureGroups: namedCaptureGroups, + groupSpecifiers: make(map[string]bool), } parser.run() s.pos = p @@ -1681,12 +1691,10 @@ func (s *Scanner) scanEscapeSequence(flags EscapeSequenceScanningFlags) string { s.tokenFlags |= ast.TokenFlagsContainsInvalidEscape if flags&EscapeSequenceScanningFlagsReportInvalidEscapeErrors != 0 { code, _ := strconv.ParseInt(s.text[start+1:s.pos], 8, 32) - if flags&EscapeSequenceScanningFlagsAnnexB == 0 { - if flags&EscapeSequenceScanningFlagsRegularExpression != 0 && flags&EscapeSequenceScanningFlagsAtomEscape == 0 && ch != '0' { - s.errorAt(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, s.pos-start, "\\x"+fmt.Sprintf("%02x", code)) - } else { - s.errorAt(diagnostics.Octal_escape_sequences_are_not_allowed_Use_the_syntax_0, start, s.pos-start, "\\x"+fmt.Sprintf("%02x", code)) - } + if flags&EscapeSequenceScanningFlagsRegularExpression != 0 && flags&EscapeSequenceScanningFlagsAtomEscape == 0 && ch != '0' { + s.errorAt(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, s.pos-start, "\\x"+fmt.Sprintf("%02x", code)) + } else { + s.errorAt(diagnostics.Octal_escape_sequences_are_not_allowed_Use_the_syntax_0, start, s.pos-start, "\\x"+fmt.Sprintf("%02x", code)) } return string(rune(code)) } diff --git a/testdata/baselines/reference/submodule/compiler/regularExpressionAnnexB.errors.txt b/testdata/baselines/reference/submodule/compiler/regularExpressionAnnexB.errors.txt index d8d00e737f9..f08ceaf8959 100644 --- a/testdata/baselines/reference/submodule/compiler/regularExpressionAnnexB.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/regularExpressionAnnexB.errors.txt @@ -27,29 +27,6 @@ regularExpressionAnnexB.ts(8,31): error TS1531: '\p' must be followed by a Unico 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(15,4): error TS1507: There is nothing available for repetition. -regularExpressionAnnexB.ts(15,5): error TS1505: Incomplete quantifier. Digit expected. -regularExpressionAnnexB.ts(15,7): error TS1005: '}' expected. -regularExpressionAnnexB.ts(15,8): error TS1507: There is nothing available for repetition. -regularExpressionAnnexB.ts(16,4): error TS1507: There is nothing available for repetition. -regularExpressionAnnexB.ts(16,6): error TS1005: '}' expected. -regularExpressionAnnexB.ts(16,7): error TS1507: There is nothing available for repetition. -regularExpressionAnnexB.ts(17,4): error TS1507: There is nothing available for repetition. -regularExpressionAnnexB.ts(17,7): error TS1005: '}' expected. -regularExpressionAnnexB.ts(17,8): error TS1507: There is nothing available for repetition. -regularExpressionAnnexB.ts(18,4): error TS1507: There is nothing available for repetition. -regularExpressionAnnexB.ts(18,8): error TS1005: '}' expected. -regularExpressionAnnexB.ts(18,9): error TS1507: There is nothing available for repetition. -regularExpressionAnnexB.ts(19,4): error TS1507: There is nothing available for repetition. -regularExpressionAnnexB.ts(19,5): error TS1506: Numbers out of order in quantifier. -regularExpressionAnnexB.ts(19,8): error TS1005: '}' expected. -regularExpressionAnnexB.ts(19,9): error TS1507: There is nothing available for repetition. -regularExpressionAnnexB.ts(21,4): error TS1507: There is nothing available for repetition. -regularExpressionAnnexB.ts(21,5): error TS1505: Incomplete quantifier. Digit expected. -regularExpressionAnnexB.ts(21,8): error TS1507: There is nothing available for repetition. -regularExpressionAnnexB.ts(22,4): error TS1507: There is nothing available for repetition. -regularExpressionAnnexB.ts(22,5): error TS1505: Incomplete quantifier. Digit expected. -regularExpressionAnnexB.ts(22,9): error TS1507: There is nothing available for repetition. 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. @@ -97,7 +74,7 @@ regularExpressionAnnexB.ts(42,5): error TS1506: Numbers out of order in quantifi regularExpressionAnnexB.ts(42,10): error TS1507: There is nothing available for repetition. -==== regularExpressionAnnexB.ts (97 errors) ==== +==== regularExpressionAnnexB.ts (74 errors) ==== const regexes: RegExp[] = [ /\q\u\i\c\k\_\f\o\x\-\j\u\m\p\s/, @@ -171,59 +148,13 @@ regularExpressionAnnexB.ts(42,10): error TS1507: There is nothing available for /{??/, /{,??/, /{,1??/, - ~~~~ -!!! 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??/, - ~~~ -!!! error TS1507: There is nothing available for repetition. - -!!! error TS1005: '}' expected. - ~ -!!! error TS1507: There is nothing available for repetition. /{1,??/, - ~~~~ -!!! error TS1507: There is nothing available for repetition. - -!!! error TS1005: '}' expected. - ~ -!!! error TS1507: There is nothing available for repetition. /{1,2??/, - ~~~~~ -!!! error TS1507: There is nothing available for repetition. - -!!! error TS1005: '}' expected. - ~ -!!! 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 TS1005: '}' expected. - ~ -!!! error TS1507: There is nothing available for repetition. /{}??/, /{,}??/, - ~~~~ -!!! error TS1507: There is nothing available for repetition. - -!!! error TS1505: Incomplete quantifier. Digit expected. - ~ -!!! error TS1507: There is nothing available for repetition. /{,1}??/, - ~~~~~ -!!! error TS1507: There is nothing available for repetition. - -!!! error TS1505: Incomplete quantifier. Digit expected. - ~ -!!! error TS1507: There is nothing available for repetition. /{1}??/, ~~~~ !!! error TS1507: There is nothing available for repetition. 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 10916305475..00000000000 --- a/testdata/baselines/reference/submodule/compiler/regularExpressionAnnexB.errors.txt.diff +++ /dev/null @@ -1,101 +0,0 @@ ---- old.regularExpressionAnnexB.errors.txt -+++ new.regularExpressionAnnexB.errors.txt -@@= skipped -26, +26 lines =@@ - 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(15,4): error TS1507: There is nothing available for repetition. -+regularExpressionAnnexB.ts(15,5): error TS1505: Incomplete quantifier. Digit expected. -+regularExpressionAnnexB.ts(15,7): error TS1005: '}' expected. -+regularExpressionAnnexB.ts(15,8): error TS1507: There is nothing available for repetition. -+regularExpressionAnnexB.ts(16,4): error TS1507: There is nothing available for repetition. -+regularExpressionAnnexB.ts(16,6): error TS1005: '}' expected. -+regularExpressionAnnexB.ts(16,7): error TS1507: There is nothing available for repetition. -+regularExpressionAnnexB.ts(17,4): error TS1507: There is nothing available for repetition. -+regularExpressionAnnexB.ts(17,7): error TS1005: '}' expected. -+regularExpressionAnnexB.ts(17,8): error TS1507: There is nothing available for repetition. -+regularExpressionAnnexB.ts(18,4): error TS1507: There is nothing available for repetition. -+regularExpressionAnnexB.ts(18,8): error TS1005: '}' expected. -+regularExpressionAnnexB.ts(18,9): error TS1507: There is nothing available for repetition. -+regularExpressionAnnexB.ts(19,4): error TS1507: There is nothing available for repetition. -+regularExpressionAnnexB.ts(19,5): error TS1506: Numbers out of order in quantifier. -+regularExpressionAnnexB.ts(19,8): error TS1005: '}' expected. -+regularExpressionAnnexB.ts(19,9): error TS1507: There is nothing available for repetition. -+regularExpressionAnnexB.ts(21,4): error TS1507: There is nothing available for repetition. -+regularExpressionAnnexB.ts(21,5): error TS1505: Incomplete quantifier. Digit expected. -+regularExpressionAnnexB.ts(21,8): error TS1507: There is nothing available for repetition. -+regularExpressionAnnexB.ts(22,4): error TS1507: There is nothing available for repetition. -+regularExpressionAnnexB.ts(22,5): error TS1505: Incomplete quantifier. Digit expected. -+regularExpressionAnnexB.ts(22,9): error TS1507: There is nothing available for repetition. - 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. -@@= skipped -47, +70 lines =@@ - regularExpressionAnnexB.ts(42,10): error TS1507: There is nothing available for repetition. - - --==== regularExpressionAnnexB.ts (74 errors) ==== -+==== regularExpressionAnnexB.ts (97 errors) ==== - const regexes: RegExp[] = [ - /\q\u\i\c\k\_\f\o\x\-\j\u\m\p\s/, - -@@= skipped -74, +74 lines =@@ - /{??/, - /{,??/, - /{,1??/, -+ ~~~~ -+!!! 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??/, -+ ~~~ -+!!! error TS1507: There is nothing available for repetition. -+ -+!!! error TS1005: '}' expected. -+ ~ -+!!! error TS1507: There is nothing available for repetition. - /{1,??/, -+ ~~~~ -+!!! error TS1507: There is nothing available for repetition. -+ -+!!! error TS1005: '}' expected. -+ ~ -+!!! error TS1507: There is nothing available for repetition. - /{1,2??/, -+ ~~~~~ -+!!! error TS1507: There is nothing available for repetition. -+ -+!!! error TS1005: '}' expected. -+ ~ -+!!! 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 TS1005: '}' expected. -+ ~ -+!!! error TS1507: There is nothing available for repetition. - /{}??/, - /{,}??/, -+ ~~~~ -+!!! error TS1507: There is nothing available for repetition. -+ -+!!! error TS1505: Incomplete quantifier. Digit expected. -+ ~ -+!!! error TS1507: There is nothing available for repetition. - /{,1}??/, -+ ~~~~~ -+!!! error TS1507: There is nothing available for repetition. -+ -+!!! error TS1505: Incomplete quantifier. Digit expected. -+ ~ -+!!! error TS1507: There is nothing available for repetition. - /{1}??/, - ~~~~ - !!! error TS1507: There is nothing available for repetition. \ 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 index 23a680bac96..e5afde3d2f4 100644 --- a/testdata/baselines/reference/submodule/compiler/regularExpressionScanning(target=es2015).errors.txt +++ b/testdata/baselines/reference/submodule/compiler/regularExpressionScanning(target=es2015).errors.txt @@ -17,7 +17,19 @@ 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'. @@ -43,7 +55,6 @@ regularExpressionScanning.ts(15,59): error TS1515: Named capturing groups with t 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(17,61): error TS1505: Incomplete quantifier. Digit expected. 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. @@ -208,7 +219,7 @@ regularExpressionScanning.ts(47,89): error TS1518: Anything that would possibly regularExpressionScanning.ts(47,101): error TS1501: This regular expression flag is only available when targeting 'esnext' or later. -==== regularExpressionScanning.ts (208 errors) ==== +==== regularExpressionScanning.ts (219 errors) ==== const regexes: RegExp[] = [ // Flags /foo/visualstudiocode, @@ -255,12 +266,36 @@ regularExpressionScanning.ts(47,101): error TS1501: This 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. @@ -316,8 +351,6 @@ regularExpressionScanning.ts(47,101): error TS1501: This regular expression flag !!! error TS1506: Numbers out of order in quantifier. ~~~~~~~~~ !!! error TS1507: There is nothing available for repetition. - -!!! error TS1505: Incomplete quantifier. Digit expected. // Character classes /[-A-Za-z-z-aZ-A\d_-\d-.-.\r-\n\w-\W]/, ~~~ 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 index fd28b32cd20..b3231ede6ab 100644 --- a/testdata/baselines/reference/submodule/compiler/regularExpressionScanning(target=es2015).errors.txt.diff +++ b/testdata/baselines/reference/submodule/compiler/regularExpressionScanning(target=es2015).errors.txt.diff @@ -6,35 +6,7 @@ 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. -@@= skipped -16, +16 lines =@@ - 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'. -@@= skipped -38, +26 lines =@@ - 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(17,61): error TS1505: Incomplete quantifier. Digit expected. - 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. -@@= skipped -17, +18 lines =@@ +@@= skipped -71, +71 lines =@@ 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. @@ -109,14 +81,11 @@ 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) ==== +regularExpressionScanning.ts(47,101): error TS1501: This regular expression flag is only available when targeting 'esnext' or later. -+ -+ -+==== regularExpressionScanning.ts (208 errors) ==== - const regexes: RegExp[] = [ + + + ==== regularExpressionScanning.ts (219 errors) ==== +@@= skipped -33, +33 lines =@@ // Flags /foo/visualstudiocode, ~ @@ -125,53 +94,7 @@ ~ !!! error TS1501: This regular expression flag is only available when targeting 'es2018' or later. ~ -@@= skipped -75, +75 lines =@@ - // 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. -@@= skipped -85, +61 lines =@@ - !!! error TS1506: Numbers out of order in quantifier. - ~~~~~~~~~ - !!! error TS1507: There is nothing available for repetition. -+ -+!!! error TS1505: Incomplete quantifier. Digit expected. - // Character classes - /[-A-Za-z-z-aZ-A\d_-\d-.-.\r-\n\w-\W]/, - ~~~ -@@= skipped -40, +42 lines =@@ +@@= skipped -167, +167 lines =@@ ~~~~~~~ !!! error TS1529: Unknown Unicode property name or value. ~ diff --git a/testdata/baselines/reference/submodule/compiler/regularExpressionScanning(target=esnext).errors.txt b/testdata/baselines/reference/submodule/compiler/regularExpressionScanning(target=esnext).errors.txt index 570c015fe55..c2d144d42c5 100644 --- a/testdata/baselines/reference/submodule/compiler/regularExpressionScanning(target=esnext).errors.txt +++ b/testdata/baselines/reference/submodule/compiler/regularExpressionScanning(target=esnext).errors.txt @@ -14,7 +14,19 @@ 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'. @@ -31,7 +43,6 @@ regularExpressionScanning.ts(15,59): error TS1515: Named capturing groups with t 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(17,61): error TS1505: Incomplete quantifier. Digit expected. 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. @@ -182,7 +193,7 @@ regularExpressionScanning.ts(47,5): error TS1518: Anything that would possibly m regularExpressionScanning.ts(47,89): error TS1518: Anything that would possibly match more than a single character is invalid inside a negated character class. -==== regularExpressionScanning.ts (182 errors) ==== +==== regularExpressionScanning.ts (193 errors) ==== const regexes: RegExp[] = [ // Flags /foo/visualstudiocode, @@ -223,12 +234,36 @@ regularExpressionScanning.ts(47,89): error TS1518: Anything that would possibly // 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. @@ -266,8 +301,6 @@ regularExpressionScanning.ts(47,89): error TS1518: Anything that would possibly !!! error TS1506: Numbers out of order in quantifier. ~~~~~~~~~ !!! error TS1507: There is nothing available for repetition. - -!!! error TS1505: Incomplete quantifier. Digit expected. // Character classes /[-A-Za-z-z-aZ-A\d_-\d-.-.\r-\n\w-\W]/, ~~~ 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 9ae7ded5e53..00000000000 --- a/testdata/baselines/reference/submodule/compiler/regularExpressionScanning(target=esnext).errors.txt.diff +++ /dev/null @@ -1,85 +0,0 @@ ---- old.regularExpressionScanning(target=esnext).errors.txt -+++ new.regularExpressionScanning(target=esnext).errors.txt -@@= skipped -13, +13 lines =@@ - 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'. -@@= skipped -29, +17 lines =@@ - 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(17,61): error TS1505: Incomplete quantifier. Digit expected. - 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. -@@= skipped -150, +151 lines =@@ - regularExpressionScanning.ts(47,89): error TS1518: Anything that would possibly match more than a single character is invalid inside a negated character class. - - --==== regularExpressionScanning.ts (193 errors) ==== -+==== regularExpressionScanning.ts (182 errors) ==== - const regexes: RegExp[] = [ - // Flags - /foo/visualstudiocode, -@@= skipped -41, +41 lines =@@ - // 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. -@@= skipped -67, +43 lines =@@ - !!! error TS1506: Numbers out of order in quantifier. - ~~~~~~~~~ - !!! error TS1507: There is nothing available for repetition. -+ -+!!! error TS1505: Incomplete quantifier. Digit expected. - // Character classes - /[-A-Za-z-z-aZ-A\d_-\d-.-.\r-\n\w-\W]/, - ~~~ \ No newline at end of file From f548c2b6482ee07a8ca21e06fa979b8ea3c240b1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Burzy=C5=84ski?= Date: Mon, 23 Feb 2026 11:44:31 +0100 Subject: [PATCH 06/43] Port "Provide Spelling Suggestions for Named Capture Group References in Regular Expressions" Co-authored-by: graphemecluster --- internal/checker/grammarchecks.go | 2 +- ...rExpressionGroupNameSuggestions.errors.txt | 2 +- ...essionGroupNameSuggestions.errors.txt.diff | 9 ------- ...ssionSuggestions(target=es2015).errors.txt | 10 ++++---- ...Suggestions(target=es2015).errors.txt.diff | 25 ------------------- 5 files changed, 7 insertions(+), 41 deletions(-) delete mode 100644 testdata/baselines/reference/submodule/compiler/regularExpressionGroupNameSuggestions.errors.txt.diff delete mode 100644 testdata/baselines/reference/submodule/compiler/regularExpressionUnicodePropertyValueExpressionSuggestions(target=es2015).errors.txt.diff diff --git a/internal/checker/grammarchecks.go b/internal/checker/grammarchecks.go index 4a2450184a9..a5e749612df 100644 --- a/internal/checker/grammarchecks.go +++ b/internal/checker/grammarchecks.go @@ -65,7 +65,7 @@ func (c *Checker) checkGrammarRegularExpressionLiteral(node *ast.RegularExpressi c.regExpScanner.SetLanguageVariant(sourceFile.LanguageVariant) c.regExpScanner.SetOnError(func(message *diagnostics.Message, start int, length int, args ...any) { if message.Category() == diagnostics.CategoryMessage && lastError != nil && start == lastError.Pos() && length == lastError.Len() { - err := ast.NewDiagnostic(sourceFile, core.NewTextRange(start, start+length), message, args...) + err := ast.NewDiagnostic(nil, 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...) diff --git a/testdata/baselines/reference/submodule/compiler/regularExpressionGroupNameSuggestions.errors.txt b/testdata/baselines/reference/submodule/compiler/regularExpressionGroupNameSuggestions.errors.txt index dd244b2851d..b900c35fe69 100644 --- a/testdata/baselines/reference/submodule/compiler/regularExpressionGroupNameSuggestions.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/regularExpressionGroupNameSuggestions.errors.txt @@ -8,5 +8,5 @@ regularExpressionGroupNameSuggestions.ts(1,27): error TS1532: There is no captur !!! 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 regularExpressionGroupNameSuggestions.ts:1:27: Did you mean 'foo'? +!!! 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 fe8737b4d30..00000000000 --- a/testdata/baselines/reference/submodule/compiler/regularExpressionGroupNameSuggestions.errors.txt.diff +++ /dev/null @@ -1,9 +0,0 @@ ---- old.regularExpressionGroupNameSuggestions.errors.txt -+++ new.regularExpressionGroupNameSuggestions.errors.txt -@@= skipped -7, +7 lines =@@ - !!! 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'? -+!!! related TS1369 regularExpressionGroupNameSuggestions.ts:1:27: Did you mean 'foo'? - \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/regularExpressionUnicodePropertyValueExpressionSuggestions(target=es2015).errors.txt b/testdata/baselines/reference/submodule/compiler/regularExpressionUnicodePropertyValueExpressionSuggestions(target=es2015).errors.txt index 81ed855de4b..cf811c2d94e 100644 --- a/testdata/baselines/reference/submodule/compiler/regularExpressionUnicodePropertyValueExpressionSuggestions(target=es2015).errors.txt +++ b/testdata/baselines/reference/submodule/compiler/regularExpressionUnicodePropertyValueExpressionSuggestions(target=es2015).errors.txt @@ -9,17 +9,17 @@ regularExpressionUnicodePropertyValueExpressionSuggestions.ts(1,93): error TS152 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 regularExpressionUnicodePropertyValueExpressionSuggestions.ts:1:19: Did you mean 'ASCII'? +!!! related TS1369: Did you mean 'ASCII'? ~~ !!! error TS1524: Unknown Unicode property name. -!!! related TS1369 regularExpressionUnicodePropertyValueExpressionSuggestions.ts:1:28: Did you mean 'sc'? +!!! related TS1369: Did you mean 'sc'? ~~~~~~~~ !!! error TS1526: Unknown Unicode property value. -!!! related TS1369 regularExpressionUnicodePropertyValueExpressionSuggestions.ts:1:45: Did you mean 'Unknown'? +!!! related TS1369: Did you mean 'Unknown'? ~~~~~~~~~~~~~~~~~~ !!! error TS1524: Unknown Unicode property name. -!!! related TS1369 regularExpressionUnicodePropertyValueExpressionSuggestions.ts:1:57: Did you mean 'Script_Extensions'? +!!! related TS1369: Did you mean 'Script_Extensions'? ~~~~~~~ !!! error TS1526: Unknown Unicode property value. -!!! related TS1369 regularExpressionUnicodePropertyValueExpressionSuggestions.ts:1:93: Did you mean 'Inherited'? +!!! related TS1369: Did you mean 'Inherited'? \ No newline at end of file diff --git a/testdata/baselines/reference/submodule/compiler/regularExpressionUnicodePropertyValueExpressionSuggestions(target=es2015).errors.txt.diff b/testdata/baselines/reference/submodule/compiler/regularExpressionUnicodePropertyValueExpressionSuggestions(target=es2015).errors.txt.diff deleted file mode 100644 index 5f6753c5d5b..00000000000 --- a/testdata/baselines/reference/submodule/compiler/regularExpressionUnicodePropertyValueExpressionSuggestions(target=es2015).errors.txt.diff +++ /dev/null @@ -1,25 +0,0 @@ ---- old.regularExpressionUnicodePropertyValueExpressionSuggestions(target=es2015).errors.txt -+++ new.regularExpressionUnicodePropertyValueExpressionSuggestions(target=es2015).errors.txt -@@= skipped -8, +8 lines =@@ - 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'? -+!!! related TS1369 regularExpressionUnicodePropertyValueExpressionSuggestions.ts:1:19: Did you mean 'ASCII'? - ~~ - !!! error TS1524: Unknown Unicode property name. --!!! related TS1369: Did you mean 'sc'? -+!!! related TS1369 regularExpressionUnicodePropertyValueExpressionSuggestions.ts:1:28: Did you mean 'sc'? - ~~~~~~~~ - !!! error TS1526: Unknown Unicode property value. --!!! related TS1369: Did you mean 'Unknown'? -+!!! related TS1369 regularExpressionUnicodePropertyValueExpressionSuggestions.ts:1:45: Did you mean 'Unknown'? - ~~~~~~~~~~~~~~~~~~ - !!! error TS1524: Unknown Unicode property name. --!!! related TS1369: Did you mean 'Script_Extensions'? -+!!! related TS1369 regularExpressionUnicodePropertyValueExpressionSuggestions.ts:1:57: Did you mean 'Script_Extensions'? - ~~~~~~~ - !!! error TS1526: Unknown Unicode property value. --!!! related TS1369: Did you mean 'Inherited'? -+!!! related TS1369 regularExpressionUnicodePropertyValueExpressionSuggestions.ts:1:93: Did you mean 'Inherited'? - \ No newline at end of file From f1b8944d1fcc542c392be4f3082a39af0a0e08f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Burzy=C5=84ski?= Date: Mon, 23 Feb 2026 12:24:33 +0100 Subject: [PATCH 07/43] Port "Correct regular expression flags scanning for non-BMP characters" Co-authored-by: graphemecluster --- internal/scanner/regexp.go | 26 +++++++++---------- internal/scanner/scanner.go | 6 ++--- ...egularExpressionWithNonBMPFlags.errors.txt | 11 +++++--- ...rExpressionWithNonBMPFlags.errors.txt.diff | 23 +++++++--------- 4 files changed, 33 insertions(+), 33 deletions(-) diff --git a/internal/scanner/regexp.go b/internal/scanner/regexp.go index f933f909594..6be976f9e9d 100644 --- a/internal/scanner/regexp.go +++ b/internal/scanner/regexp.go @@ -25,7 +25,7 @@ const ( RegularExpressionFlagsModifiers RegularExpressionFlags = RegularExpressionFlagsIgnoreCase | RegularExpressionFlagsMultiline | RegularExpressionFlagsDotAll ) -var charToRegExpFlag = map[rune]RegularExpressionFlags{ +var charCodeToRegExpFlag = map[rune]RegularExpressionFlags{ 'd': RegularExpressionFlagsHasIndices, 'g': RegularExpressionFlagsGlobal, 'i': RegularExpressionFlagsIgnoreCase, @@ -44,14 +44,14 @@ var regExpFlagToFirstAvailableLanguageVersion = map[RegularExpressionFlags]core. RegularExpressionFlagsSticky: core.ScriptTargetES2015, } -func CharacterToRegularExpressionFlag(ch rune) (RegularExpressionFlags, bool) { - flag, ok := charToRegExpFlag[ch] +func CharacterCodeToRegularExpressionFlag(ch rune) (RegularExpressionFlags, bool) { + flag, ok := charCodeToRegExpFlag[ch] return flag, ok } -func (s *Scanner) checkRegularExpressionFlagAvailable(flag RegularExpressionFlags, pos int) { +func (s *Scanner) checkRegularExpressionFlagAvailability(flag RegularExpressionFlags, pos int, size int) { if availableFrom, ok := regExpFlagToFirstAvailableLanguageVersion[flag]; ok && s.languageVersion() < availableFrom { - s.errorAt(diagnostics.This_regular_expression_flag_is_only_available_when_targeting_0_or_later, pos, 1, GetNameOfScriptTarget(availableFrom)) + s.errorAt(diagnostics.This_regular_expression_flag_is_only_available_when_targeting_0_or_later, pos, size, GetNameOfScriptTarget(availableFrom)) } } @@ -325,22 +325,22 @@ func (p *regExpParser) scanAlternative(isInGroup bool) { func (p *regExpParser) scanPatternModifiers(currFlags RegularExpressionFlags) RegularExpressionFlags { for p.pos() < p.end { - ch := p.charAt(p.pos()) - if !IsIdentifierPart(ch) { + ch, size := utf8.DecodeRuneInString(p.text()[p.pos():]) + if ch == utf8.RuneError || !IsIdentifierPart(ch) { break } - flag, ok := CharacterToRegularExpressionFlag(ch) + flag, ok := CharacterCodeToRegularExpressionFlag(ch) if !ok { - p.error(diagnostics.Unknown_regular_expression_flag, p.pos(), 1) + p.error(diagnostics.Unknown_regular_expression_flag, p.pos(), size) } else if currFlags&flag != 0 { - p.error(diagnostics.Duplicate_regular_expression_flag, p.pos(), 1) + p.error(diagnostics.Duplicate_regular_expression_flag, p.pos(), size) } else if flag&RegularExpressionFlagsModifiers == 0 { - p.error(diagnostics.This_regular_expression_flag_cannot_be_toggled_within_a_subpattern, p.pos(), 1) + p.error(diagnostics.This_regular_expression_flag_cannot_be_toggled_within_a_subpattern, p.pos(), size) } else { currFlags |= flag - p.scanner.checkRegularExpressionFlagAvailable(flag, p.pos()) + p.scanner.checkRegularExpressionFlagAvailability(flag, p.pos(), size) } - p.incPos(1) + p.incPos(size) } return currFlags } diff --git a/internal/scanner/scanner.go b/internal/scanner/scanner.go index 80cadb08f25..a02271f9b3d 100644 --- a/internal/scanner/scanner.go +++ b/internal/scanner/scanner.go @@ -1146,11 +1146,11 @@ func (s *Scanner) ReScanSlashToken(reportErrors ...bool) ast.Kind { var regExpFlags RegularExpressionFlags for p < len(s.text) { ch, size := utf8.DecodeRuneInString(s.text[p:]) - if !IsIdentifierPart(ch) { + if ch == utf8.RuneError || !IsIdentifierPart(ch) { break } if shouldReportErrors { - flag, ok := CharacterToRegularExpressionFlag(ch) + flag, ok := CharacterCodeToRegularExpressionFlag(ch) if !ok { s.errorAt(diagnostics.Unknown_regular_expression_flag, p, size) } else if regExpFlags&flag != 0 { @@ -1159,7 +1159,7 @@ func (s *Scanner) ReScanSlashToken(reportErrors ...bool) ast.Kind { s.errorAt(diagnostics.The_Unicode_u_flag_and_the_Unicode_Sets_v_flag_cannot_be_set_simultaneously, p, size) } else { regExpFlags |= flag - s.checkRegularExpressionFlagAvailable(flag, p) + s.checkRegularExpressionFlagAvailability(flag, p, size) } } p += size diff --git a/testdata/baselines/reference/submodule/compiler/regularExpressionWithNonBMPFlags.errors.txt b/testdata/baselines/reference/submodule/compiler/regularExpressionWithNonBMPFlags.errors.txt index aa6f71cec40..8bcee094ebd 100644 --- a/testdata/baselines/reference/submodule/compiler/regularExpressionWithNonBMPFlags.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/regularExpressionWithNonBMPFlags.errors.txt @@ -1,11 +1,12 @@ regularExpressionWithNonBMPFlags.ts(7,18): error TS1499: Unknown regular expression flag. -regularExpressionWithNonBMPFlags.ts(7,19): error TS1005: ':' expected. +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 (5 errors) ==== +==== 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) @@ -15,8 +16,10 @@ regularExpressionWithNonBMPFlags.ts(7,32): error TS1499: Unknown regular express const 𝘳𝘦𝘨𝘦𝘹 = /(?𝘴𝘪-𝘮:^𝘧𝘰𝘰.)/𝘨𝘮𝘶; ~ !!! error TS1499: Unknown regular expression flag. - -!!! error TS1005: ':' expected. + ~ +!!! error TS1499: Unknown regular expression flag. + ~ +!!! error TS1499: Unknown regular expression flag. ~ !!! error TS1499: Unknown regular expression flag. ~ diff --git a/testdata/baselines/reference/submodule/compiler/regularExpressionWithNonBMPFlags.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/regularExpressionWithNonBMPFlags.errors.txt.diff index 48dabf10b7f..ffedaf83dbe 100644 --- a/testdata/baselines/reference/submodule/compiler/regularExpressionWithNonBMPFlags.errors.txt.diff +++ b/testdata/baselines/reference/submodule/compiler/regularExpressionWithNonBMPFlags.errors.txt.diff @@ -7,21 +7,16 @@ -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) ==== +regularExpressionWithNonBMPFlags.ts(7,18): error TS1499: Unknown regular expression flag. -+regularExpressionWithNonBMPFlags.ts(7,19): error TS1005: ':' expected. ++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 (5 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) -@@= skipped -13, +12 lines =@@ + + + ==== regularExpressionWithNonBMPFlags.ts (6 errors) ==== +@@= skipped -13, +13 lines =@@ // // See https://en.wikipedia.org/wiki/Mathematical_Alphanumeric_Symbols const 𝘳𝘦𝘨𝘦𝘹 = /(?𝘴𝘪-𝘮:^𝘧𝘰𝘰.)/𝘨𝘮𝘶; @@ -38,8 +33,10 @@ - ~~ + ~ +!!! error TS1499: Unknown regular expression flag. -+ -+!!! error TS1005: ':' expected. ++ ~ ++!!! error TS1499: Unknown regular expression flag. ++ ~ ++!!! error TS1499: Unknown regular expression flag. + ~ +!!! error TS1499: Unknown regular expression flag. + ~ From af449ae4d1725b8ecdf4f132bb86c97e1d57babc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Burzy=C5=84ski?= Date: Mon, 23 Feb 2026 14:03:42 +0100 Subject: [PATCH 08/43] fix stuff --- internal/scanner/scanner.go | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/internal/scanner/scanner.go b/internal/scanner/scanner.go index a02271f9b3d..d53f7323eaf 100644 --- a/internal/scanner/scanner.go +++ b/internal/scanner/scanner.go @@ -1728,9 +1728,22 @@ func (s *Scanner) scanEscapeSequence(flags EscapeSequenceScanningFlags) string { case '"': return "\"" case 'u': - // '\uDDDD' and '\U{DDDDDD}' + // '\uDDDD' and '\u{DDDDDD}' + extended := s.char() == '{' s.pos -= 2 codePoint := s.scanUnicodeEscape(flags&EscapeSequenceScanningFlagsReportInvalidEscapeErrors != 0) + if extended { + if flags&EscapeSequenceScanningFlagsAllowExtendedUnicodeEscape == 0 { + s.tokenFlags |= ast.TokenFlagsContainsInvalidEscape + if flags&EscapeSequenceScanningFlagsReportInvalidEscapeErrors != 0 { + s.errorAt(diagnostics.Unicode_escape_sequences_are_only_available_when_the_Unicode_u_flag_or_the_Unicode_Sets_v_flag_is_set, start, s.pos-start) + } + } + if codePoint < 0 { + return s.text[start:s.pos] + } + return string(codePoint) + } if codePoint < 0 { return s.text[start:s.pos] } else if codePointIsHighSurrogate(codePoint) && s.char() == '\\' && s.charAt(1) == 'u' { @@ -1739,7 +1752,7 @@ func (s *Scanner) scanEscapeSequence(flags EscapeSequenceScanningFlags) string { if codePointIsLowSurrogate(nextCodePoint) { return string(surrogatePairToCodepoint(codePoint, nextCodePoint)) } - s.pos = savedPos // restore position because we do not consume nextCodePoint + s.pos = savedPos } return string(codePoint) case 'x': From df6003ab73ebfa972ed827c97103bbc8f0897cb2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Burzy=C5=84ski?= Date: Mon, 23 Feb 2026 14:14:05 +0100 Subject: [PATCH 09/43] fix stuff --- internal/scanner/scanner.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/scanner/scanner.go b/internal/scanner/scanner.go index d53f7323eaf..dc4e7c91a71 100644 --- a/internal/scanner/scanner.go +++ b/internal/scanner/scanner.go @@ -1746,7 +1746,7 @@ func (s *Scanner) scanEscapeSequence(flags EscapeSequenceScanningFlags) string { } if codePoint < 0 { return s.text[start:s.pos] - } else if codePointIsHighSurrogate(codePoint) && s.char() == '\\' && s.charAt(1) == 'u' { + } else if flags&EscapeSequenceScanningFlagsAnyUnicodeMode != 0 && codePointIsHighSurrogate(codePoint) && s.char() == '\\' && s.charAt(1) == 'u' && s.charAt(2) != '{' { savedPos := s.pos nextCodePoint := s.scanUnicodeEscape(flags&EscapeSequenceScanningFlagsReportInvalidEscapeErrors != 0) if codePointIsLowSurrogate(nextCodePoint) { From 1f36b00c79a73c05ce8c66ed8f013912750e931a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Burzy=C5=84ski?= Date: Mon, 23 Feb 2026 14:53:13 +0100 Subject: [PATCH 10/43] fix a thing --- internal/scanner/scanner.go | 45 ++++++++++++++++++++----------------- 1 file changed, 25 insertions(+), 20 deletions(-) diff --git a/internal/scanner/scanner.go b/internal/scanner/scanner.go index dc4e7c91a71..471c8ad1762 100644 --- a/internal/scanner/scanner.go +++ b/internal/scanner/scanner.go @@ -211,6 +211,7 @@ type ScannerState struct { type Scanner struct { text string + end int languageVariant core.LanguageVariant scriptTarget core.ScriptTarget onError ErrorCallback @@ -404,6 +405,7 @@ func hasJSDocTag(text string, tags ...string) bool { func (s *Scanner) SetText(text string) { s.text = text + s.end = len(text) s.ScannerState = ScannerState{} } @@ -444,7 +446,7 @@ func (s *Scanner) errorAt(diagnostic *diagnostics.Message, pos int, length int, // It must be checked against utf8.RuneSelf to verify that a call to charAndSize // is not needed. func (s *Scanner) char() rune { - if s.pos < len(s.text) { + if s.pos < s.end { return rune(s.text[s.pos]) } return -1 @@ -452,7 +454,7 @@ func (s *Scanner) char() rune { // NOTE: this returns a rune, but only decodes the byte at the offset. func (s *Scanner) charAt(offset int) rune { - if s.pos+offset < len(s.text) { + if s.pos+offset < s.end { return rune(s.text[s.pos+offset]) } return -1 @@ -1164,24 +1166,27 @@ func (s *Scanner) ReScanSlashToken(reportErrors ...bool) ast.Kind { } p += size } - if shouldReportErrors { - s.pos = startOfRegExpBody - saveTokenPos := s.tokenStart - saveTokenFlags := s.tokenFlags - parser := ®ExpParser{ - scanner: s, - end: endOfRegExpBody, - regExpFlags: regExpFlags, - anyUnicodeMode: regExpFlags&RegularExpressionFlagsAnyUnicodeMode != 0, - unicodeSetsMode: regExpFlags&RegularExpressionFlagsUnicodeSets != 0, - annexB: true, - namedCaptureGroups: namedCaptureGroups, - groupSpecifiers: make(map[string]bool), - } - parser.run() - s.pos = p - s.tokenStart = saveTokenPos - s.tokenFlags = saveTokenFlags + if shouldReportErrors { + s.pos = startOfRegExpBody + saveEnd := s.end + saveTokenPos := s.tokenStart + saveTokenFlags := s.tokenFlags + s.end = endOfRegExpBody + parser := ®ExpParser{ + scanner: s, + end: endOfRegExpBody, + regExpFlags: regExpFlags, + anyUnicodeMode: regExpFlags&RegularExpressionFlagsAnyUnicodeMode != 0, + unicodeSetsMode: regExpFlags&RegularExpressionFlagsUnicodeSets != 0, + annexB: true, + namedCaptureGroups: namedCaptureGroups, + groupSpecifiers: make(map[string]bool), + } + parser.run() + s.end = saveEnd + s.pos = p + s.tokenStart = saveTokenPos + s.tokenFlags = saveTokenFlags } else { s.pos = p } From 25933235da7c5ff1309f126e4bd1acd4ed4ad9e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Burzy=C5=84ski?= Date: Mon, 23 Feb 2026 14:58:37 +0100 Subject: [PATCH 11/43] fix stuff --- internal/scanner/scanner.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/scanner/scanner.go b/internal/scanner/scanner.go index 471c8ad1762..85891895f1f 100644 --- a/internal/scanner/scanner.go +++ b/internal/scanner/scanner.go @@ -1801,7 +1801,6 @@ func (s *Scanner) scanUnicodeEscape(shouldEmitInvalidEscapeError bool) rune { var hexDigits string if extended { s.pos++ - s.tokenFlags |= ast.TokenFlagsExtendedUnicodeEscape hexDigits = s.scanHexDigits(1, true, false) } else { s.tokenFlags |= ast.TokenFlagsUnicodeEscape @@ -1836,6 +1835,7 @@ func (s *Scanner) scanUnicodeEscape(shouldEmitInvalidEscapeError bool) rune { if isInvalidExtendedEscape { return -1 } + s.tokenFlags |= ast.TokenFlagsExtendedUnicodeEscape } return rune(hexValue) } From 27c3597431f53b9334c7448a54077f4ce2d62b44 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Burzy=C5=84ski?= Date: Mon, 23 Feb 2026 15:08:04 +0100 Subject: [PATCH 12/43] fix stuff --- internal/scanner/regexp.go | 19 +++++++------------ 1 file changed, 7 insertions(+), 12 deletions(-) diff --git a/internal/scanner/regexp.go b/internal/scanner/regexp.go index 6be976f9e9d..8b96e67194a 100644 --- a/internal/scanner/regexp.go +++ b/internal/scanner/regexp.go @@ -948,20 +948,15 @@ func (p *regExpParser) scanWordCharacters() string { } func (p *regExpParser) scanSourceCharacter() string { - if p.anyUnicodeMode { - ch, size := utf8.DecodeRuneInString(p.text()[p.pos():]) - if size == 0 || ch == utf8.RuneError { - return "" - } - p.incPos(size) - return string(ch) + if p.pos() >= p.end { + return "" } - if p.pos() < p.end { - ch := p.text()[p.pos()] - p.incPos(1) - return string(ch) + ch, size := utf8.DecodeRuneInString(p.text()[p.pos():]) + if size == 0 || ch == utf8.RuneError { + return "" } - return "" + p.incPos(size) + return string(ch) } func (p *regExpParser) scanExpectedChar(ch rune) { From b9e8ad0a0f0e531547810ea3c596f732497012c2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Burzy=C5=84ski?= Date: Mon, 23 Feb 2026 15:23:59 +0100 Subject: [PATCH 13/43] fix stuff --- internal/scanner/scanner.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/internal/scanner/scanner.go b/internal/scanner/scanner.go index 85891895f1f..ab5f2dd1dab 100644 --- a/internal/scanner/scanner.go +++ b/internal/scanner/scanner.go @@ -1817,22 +1817,26 @@ func (s *Scanner) scanUnicodeEscape(shouldEmitInvalidEscapeError bool) rune { if extended { isInvalidExtendedEscape := false if hexValue > 0x10FFFF { - s.tokenFlags |= ast.TokenFlagsContainsInvalidEscape if shouldEmitInvalidEscapeError { s.errorAt(diagnostics.An_extended_Unicode_escape_value_must_be_between_0x0_and_0x10FFFF_inclusive, start+1, s.pos-start-1) } isInvalidExtendedEscape = true } - if s.char() == '}' { + if s.pos >= s.end { + if shouldEmitInvalidEscapeError { + s.error(diagnostics.Unexpected_end_of_text) + } + isInvalidExtendedEscape = true + } else if s.char() == '}' { s.pos++ } else { - s.tokenFlags |= ast.TokenFlagsContainsInvalidEscape if shouldEmitInvalidEscapeError { s.error(diagnostics.Unterminated_Unicode_escape_sequence) } isInvalidExtendedEscape = true } if isInvalidExtendedEscape { + s.tokenFlags |= ast.TokenFlagsContainsInvalidEscape return -1 } s.tokenFlags |= ast.TokenFlagsExtendedUnicodeEscape From 0dd18b221579f72541b1b9a294c0dabb31b4999c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Burzy=C5=84ski?= Date: Tue, 10 Mar 2026 11:41:56 +0100 Subject: [PATCH 14/43] fixup indent --- internal/scanner/scanner.go | 42 ++++++++++++++++++------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/internal/scanner/scanner.go b/internal/scanner/scanner.go index ab5f2dd1dab..4feb938c32f 100644 --- a/internal/scanner/scanner.go +++ b/internal/scanner/scanner.go @@ -1166,27 +1166,27 @@ func (s *Scanner) ReScanSlashToken(reportErrors ...bool) ast.Kind { } p += size } - if shouldReportErrors { - s.pos = startOfRegExpBody - saveEnd := s.end - saveTokenPos := s.tokenStart - saveTokenFlags := s.tokenFlags - s.end = endOfRegExpBody - parser := ®ExpParser{ - scanner: s, - end: endOfRegExpBody, - regExpFlags: regExpFlags, - anyUnicodeMode: regExpFlags&RegularExpressionFlagsAnyUnicodeMode != 0, - unicodeSetsMode: regExpFlags&RegularExpressionFlagsUnicodeSets != 0, - annexB: true, - namedCaptureGroups: namedCaptureGroups, - groupSpecifiers: make(map[string]bool), - } - parser.run() - s.end = saveEnd - s.pos = p - s.tokenStart = saveTokenPos - s.tokenFlags = saveTokenFlags + if shouldReportErrors { + s.pos = startOfRegExpBody + saveEnd := s.end + saveTokenPos := s.tokenStart + saveTokenFlags := s.tokenFlags + s.end = endOfRegExpBody + parser := ®ExpParser{ + scanner: s, + end: endOfRegExpBody, + regExpFlags: regExpFlags, + anyUnicodeMode: regExpFlags&RegularExpressionFlagsAnyUnicodeMode != 0, + unicodeSetsMode: regExpFlags&RegularExpressionFlagsUnicodeSets != 0, + annexB: true, + namedCaptureGroups: namedCaptureGroups, + groupSpecifiers: make(map[string]bool), + } + parser.run() + s.end = saveEnd + s.pos = p + s.tokenStart = saveTokenPos + s.tokenFlags = saveTokenFlags } else { s.pos = p } From 8de6161066786c5037691c136298fc959de0a135 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Burzy=C5=84ski?= Date: Tue, 10 Mar 2026 13:04:19 +0100 Subject: [PATCH 15/43] fix subrange scanning --- internal/scanner/scanner.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/internal/scanner/scanner.go b/internal/scanner/scanner.go index 4feb938c32f..43c3e54bd1a 100644 --- a/internal/scanner/scanner.go +++ b/internal/scanner/scanner.go @@ -1068,7 +1068,7 @@ func (s *Scanner) ReScanSlashToken(reportErrors ...bool) ast.Kind { inCharacterClass := false loop: for { - if p >= len(s.text) { + if p >= s.end { s.tokenFlags |= ast.TokenFlagsUnterminated break loop } @@ -1088,9 +1088,9 @@ func (s *Scanner) ReScanSlashToken(reportErrors ...bool) ast.Kind { } else if ch == ']' { inCharacterClass = false } else if !inCharacterClass && ch == '(' && - p+1 < len(s.text) && s.text[p+1] == '?' && - p+2 < len(s.text) && s.text[p+2] == '<' && - (p+3 >= len(s.text) || (s.text[p+3] != '=' && s.text[p+3] != '!')) { + p+1 < s.end && s.text[p+1] == '?' && + p+2 < s.end && s.text[p+2] == '<' && + (p+3 >= s.end || (s.text[p+3] != '=' && s.text[p+3] != '!')) { namedCaptureGroups = true } p++ @@ -1146,7 +1146,7 @@ func (s *Scanner) ReScanSlashToken(reportErrors ...bool) ast.Kind { // Consume the slash character p++ var regExpFlags RegularExpressionFlags - for p < len(s.text) { + for p < s.end { ch, size := utf8.DecodeRuneInString(s.text[p:]) if ch == utf8.RuneError || !IsIdentifierPart(ch) { break From a3f863a63f14845653b4217268f17b410392f18d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Burzy=C5=84ski?= Date: Tue, 10 Mar 2026 13:27:31 +0100 Subject: [PATCH 16/43] add missing case to `scanSourceCharacter` --- internal/scanner/regexp.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/internal/scanner/regexp.go b/internal/scanner/regexp.go index 8b96e67194a..7751cfa650c 100644 --- a/internal/scanner/regexp.go +++ b/internal/scanner/regexp.go @@ -951,6 +951,11 @@ func (p *regExpParser) scanSourceCharacter() string { if p.pos() >= p.end { return "" } + if !p.anyUnicodeMode { + ch := p.text()[p.pos()] + p.incPos(1) + return string(ch) + } ch, size := utf8.DecodeRuneInString(p.text()[p.pos():]) if size == 0 || ch == utf8.RuneError { return "" From b351d4a545d6eb44ee9956d32377265c539af556 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Burzy=C5=84ski?= Date: Tue, 10 Mar 2026 14:58:32 +0100 Subject: [PATCH 17/43] fix thing --- internal/scanner/scanner.go | 8 ++++- ...ressionCharacterClassRangeOrder.errors.txt | 18 ++++++++-- ...onCharacterClassRangeOrder.errors.txt.diff | 33 +++++-------------- ...xpressionExtendedUnicodeEscapes.errors.txt | 15 +++++++++ ...sionExtendedUnicodeEscapes.errors.txt.diff | 19 ----------- ...egularExpressionWithNonBMPFlags.errors.txt | 12 +++---- ...rExpressionWithNonBMPFlags.errors.txt.diff | 16 --------- 7 files changed, 51 insertions(+), 70 deletions(-) create mode 100644 testdata/baselines/reference/submodule/compiler/regularExpressionExtendedUnicodeEscapes.errors.txt delete mode 100644 testdata/baselines/reference/submodule/compiler/regularExpressionExtendedUnicodeEscapes.errors.txt.diff diff --git a/internal/scanner/scanner.go b/internal/scanner/scanner.go index 43c3e54bd1a..77373e33c1c 100644 --- a/internal/scanner/scanner.go +++ b/internal/scanner/scanner.go @@ -1751,7 +1751,12 @@ func (s *Scanner) scanEscapeSequence(flags EscapeSequenceScanningFlags) string { } if codePoint < 0 { return s.text[start:s.pos] - } else if flags&EscapeSequenceScanningFlagsAnyUnicodeMode != 0 && codePointIsHighSurrogate(codePoint) && s.char() == '\\' && s.charAt(1) == 'u' && s.charAt(2) != '{' { + } else if codePointIsHighSurrogate(codePoint) && s.char() == '\\' && s.charAt(1) == 'u' && s.charAt(2) != '{' { + // In TypeScript (UTF-16), \uHigh \uLow forms a valid surrogate pair string value. + // In Go (UTF-8), lone surrogates are invalid, so we always combine adjacent pairs + // regardless of unicode mode to preserve the intended code point. + // In regexp AnyUnicodeMode, this also aligns with the spec treatment of surrogate pairs + // as a single character for character class range ordering. savedPos := s.pos nextCodePoint := s.scanUnicodeEscape(flags&EscapeSequenceScanningFlagsReportInvalidEscapeErrors != 0) if codePointIsLowSurrogate(nextCodePoint) { @@ -2439,6 +2444,7 @@ func GetScannerForSourceFile(sourceFile *ast.SourceFile, pos int) *Scanner { s := NewScanner() s.text = sourceFile.Text() s.pos = pos + s.end = len(s.text) s.languageVariant = sourceFile.LanguageVariant s.Scan() return s diff --git a/testdata/baselines/reference/submodule/compiler/regularExpressionCharacterClassRangeOrder.errors.txt b/testdata/baselines/reference/submodule/compiler/regularExpressionCharacterClassRangeOrder.errors.txt index 4a0b74ec925..155c05d3679 100644 --- a/testdata/baselines/reference/submodule/compiler/regularExpressionCharacterClassRangeOrder.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/regularExpressionCharacterClassRangeOrder.errors.txt @@ -1,6 +1,10 @@ -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(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(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,31): error TS1517: Range out of order in character class. @@ -8,7 +12,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 (8 errors) ==== +==== regularExpressionCharacterClassRangeOrder.ts (12 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,8 +28,16 @@ regularExpressionCharacterClassRangeOrder.ts(17,31): error TS1517: Range out of !!! 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. diff --git a/testdata/baselines/reference/submodule/compiler/regularExpressionCharacterClassRangeOrder.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/regularExpressionCharacterClassRangeOrder.errors.txt.diff index fa863fcd662..3041752b9b1 100644 --- a/testdata/baselines/reference/submodule/compiler/regularExpressionCharacterClassRangeOrder.errors.txt.diff +++ b/testdata/baselines/reference/submodule/compiler/regularExpressionCharacterClassRangeOrder.errors.txt.diff @@ -3,15 +3,11 @@ @@= skipped -0, +0 lines =@@ -regularExpressionCharacterClassRangeOrder.ts(7,5): error TS1517: Range out of order in character class. -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(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,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(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. +@@= skipped -8, +6 lines =@@ + 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. @@ -22,11 +18,11 @@ -==== regularExpressionCharacterClassRangeOrder.ts (15 errors) ==== -+==== regularExpressionCharacterClassRangeOrder.ts (8 errors) ==== ++==== regularExpressionCharacterClassRangeOrder.ts (12 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, +15 lines =@@ +@@= skipped -14, +13 lines =@@ // See https://en.wikipedia.org/wiki/Mathematical_Alphanumeric_Symbols const regexes: RegExp[] = [ /[𝘈-𝘡][𝘡-𝘈]/, @@ -44,20 +40,7 @@ !!! 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. -@@= skipped -30, +18 lines =@@ +@@= skipped -30, +26 lines =@@ !!! error TS1517: Range out of order in character class. /[\uD835\uDE08-\uD835\uDE21][\uD835\uDE21-\uD835\uDE08]/, 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 00000000000..6414010e5cc --- /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 af46f29a92f..00000000000 --- 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/regularExpressionWithNonBMPFlags.errors.txt b/testdata/baselines/reference/submodule/compiler/regularExpressionWithNonBMPFlags.errors.txt index 8bcee094ebd..e17836b0ddc 100644 --- a/testdata/baselines/reference/submodule/compiler/regularExpressionWithNonBMPFlags.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/regularExpressionWithNonBMPFlags.errors.txt @@ -1,9 +1,9 @@ -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(7,23): error TS1499: Unknown regular expression flag. +regularExpressionWithNonBMPFlags.ts(7,25): error TS1499: Unknown regular expression flag. +regularExpressionWithNonBMPFlags.ts(7,28): error TS1499: Unknown regular expression flag. +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) ==== diff --git a/testdata/baselines/reference/submodule/compiler/regularExpressionWithNonBMPFlags.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/regularExpressionWithNonBMPFlags.errors.txt.diff index ffedaf83dbe..c80909e6d74 100644 --- a/testdata/baselines/reference/submodule/compiler/regularExpressionWithNonBMPFlags.errors.txt.diff +++ b/testdata/baselines/reference/submodule/compiler/regularExpressionWithNonBMPFlags.errors.txt.diff @@ -1,21 +1,5 @@ --- old.regularExpressionWithNonBMPFlags.errors.txt +++ new.regularExpressionWithNonBMPFlags.errors.txt -@@= skipped -0, +0 lines =@@ --regularExpressionWithNonBMPFlags.ts(7,23): error TS1499: Unknown regular expression flag. --regularExpressionWithNonBMPFlags.ts(7,25): error TS1499: Unknown regular expression flag. --regularExpressionWithNonBMPFlags.ts(7,28): error TS1499: Unknown regular expression flag. --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(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 From db421f454c348d4a684a8f159331d0e190ddf677 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Burzy=C5=84ski?= Date: Tue, 10 Mar 2026 18:42:05 +0100 Subject: [PATCH 18/43] remove GetNameOfScriptTarget --- internal/scanner/regexp.go | 34 ++-------------------------------- 1 file changed, 2 insertions(+), 32 deletions(-) diff --git a/internal/scanner/regexp.go b/internal/scanner/regexp.go index 7751cfa650c..a3005b6c036 100644 --- a/internal/scanner/regexp.go +++ b/internal/scanner/regexp.go @@ -2,6 +2,7 @@ package scanner import ( "strconv" + "strings" "unicode/utf8" "github.com/microsoft/typescript-go/internal/core" @@ -51,7 +52,7 @@ func CharacterCodeToRegularExpressionFlag(ch rune) (RegularExpressionFlags, bool func (s *Scanner) checkRegularExpressionFlagAvailability(flag RegularExpressionFlags, pos int, size int) { if availableFrom, ok := regExpFlagToFirstAvailableLanguageVersion[flag]; ok && s.languageVersion() < availableFrom { - s.errorAt(diagnostics.This_regular_expression_flag_is_only_available_when_targeting_0_or_later, pos, size, GetNameOfScriptTarget(availableFrom)) + s.errorAt(diagnostics.This_regular_expression_flag_is_only_available_when_targeting_0_or_later, pos, size, strings.ToLower(availableFrom.String())) } } @@ -1015,34 +1016,3 @@ func (p *regExpParser) run() { } } } - -func GetNameOfScriptTarget(target core.ScriptTarget) string { - switch target { - case core.ScriptTargetES5: - return "es5" - case core.ScriptTargetES2015: - return "es2015" - case core.ScriptTargetES2016: - return "es2016" - case core.ScriptTargetES2017: - return "es2017" - case core.ScriptTargetES2018: - return "es2018" - case core.ScriptTargetES2019: - return "es2019" - case core.ScriptTargetES2020: - return "es2020" - case core.ScriptTargetES2021: - return "es2021" - case core.ScriptTargetES2022: - return "es2022" - case core.ScriptTargetES2023: - return "es2023" - case core.ScriptTargetES2024: - return "es2024" - case core.ScriptTargetESNext: - return "esnext" - default: - return "" - } -} From f3d4cefebb707ad6be4974c4cf63b26ed597df16 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Burzy=C5=84ski?= Date: Tue, 10 Mar 2026 18:52:30 +0100 Subject: [PATCH 19/43] switch it back --- internal/scanner/scanner.go | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/internal/scanner/scanner.go b/internal/scanner/scanner.go index 77373e33c1c..4ebd6688b7c 100644 --- a/internal/scanner/scanner.go +++ b/internal/scanner/scanner.go @@ -1068,29 +1068,35 @@ func (s *Scanner) ReScanSlashToken(reportErrors ...bool) ast.Kind { inCharacterClass := false loop: for { + // If we reach the end of a file, or hit a newline, then this is an unterminated + // regex. Report error and return what we have so far. if p >= s.end { s.tokenFlags |= ast.TokenFlagsUnterminated break loop } ch := rune(s.text[p]) - if stringutil.IsLineBreak(ch) { + switch { + case stringutil.IsLineBreak(ch): s.tokenFlags |= ast.TokenFlagsUnterminated break loop - } - if inEscape { + case inEscape: + // Parsing an escape character; + // reset the flag and just advance to the next char. inEscape = false - } else if ch == '/' && !inCharacterClass { + case ch == '/' && !inCharacterClass: + // A slash within a character class is permissible, + // but in general it signals the end of the regexp literal. break loop - } else if ch == '[' { + case ch == '[': inCharacterClass = true - } else if ch == '\\' { + case ch == '\\': inEscape = true - } else if ch == ']' { + case ch == ']': inCharacterClass = false - } else if !inCharacterClass && ch == '(' && + case !inCharacterClass && ch == '(' && p+1 < s.end && s.text[p+1] == '?' && p+2 < s.end && s.text[p+2] == '<' && - (p+3 >= s.end || (s.text[p+3] != '=' && s.text[p+3] != '!')) { + (p+3 >= s.end || (s.text[p+3] != '=' && s.text[p+3] != '!')): namedCaptureGroups = true } p++ From dba4669d8f7fd802b6d79837aa1368e7ded76b60 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Burzy=C5=84ski?= Date: Tue, 10 Mar 2026 19:06:23 +0100 Subject: [PATCH 20/43] bring back comment --- internal/scanner/scanner.go | 1 + 1 file changed, 1 insertion(+) diff --git a/internal/scanner/scanner.go b/internal/scanner/scanner.go index 4ebd6688b7c..68824ce8907 100644 --- a/internal/scanner/scanner.go +++ b/internal/scanner/scanner.go @@ -1132,6 +1132,7 @@ func (s *Scanner) ReScanSlashToken(reportErrors ...bool) ast.Kind { } else if ch == ')' && groupDepth != 0 { groupDepth-- } else if ch == ')' || ch == ']' || ch == '}' { + // We encountered an unbalanced bracket outside a character class. Treat this position as the end of regex. break } } From 00ca1e6bd608ae4170d91945da399d57404f31f5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Burzy=C5=84ski?= Date: Tue, 10 Mar 2026 19:14:02 +0100 Subject: [PATCH 21/43] restore comment --- internal/scanner/scanner.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/scanner/scanner.go b/internal/scanner/scanner.go index 68824ce8907..59eef764465 100644 --- a/internal/scanner/scanner.go +++ b/internal/scanner/scanner.go @@ -1769,7 +1769,7 @@ func (s *Scanner) scanEscapeSequence(flags EscapeSequenceScanningFlags) string { if codePointIsLowSurrogate(nextCodePoint) { return string(surrogatePairToCodepoint(codePoint, nextCodePoint)) } - s.pos = savedPos + s.pos = savedPos // restore position because we do not consume nextCodePoint } return string(codePoint) case 'x': From 8dd5ac5b63d48b6ef9162445a1b5bd05c7ec832f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Burzy=C5=84ski?= Date: Tue, 10 Mar 2026 19:22:48 +0100 Subject: [PATCH 22/43] fix regExpFlagToFirstAvailableLanguageVersion --- internal/scanner/regexp.go | 2 +- ...acketInCharClass(target=es2015).errors.txt | 4 +- ...InCharClass(target=es2015).errors.txt.diff | 17 -- ...pressionScanning(target=es2015).errors.txt | 60 ++--- ...ionScanning(target=es2015).errors.txt.diff | 206 ------------------ 5 files changed, 33 insertions(+), 256 deletions(-) delete mode 100644 testdata/baselines/reference/submodule/compiler/regExpWithOpenBracketInCharClass(target=es2015).errors.txt.diff delete mode 100644 testdata/baselines/reference/submodule/compiler/regularExpressionScanning(target=es2015).errors.txt.diff diff --git a/internal/scanner/regexp.go b/internal/scanner/regexp.go index a3005b6c036..8676f5cdec6 100644 --- a/internal/scanner/regexp.go +++ b/internal/scanner/regexp.go @@ -41,7 +41,7 @@ var regExpFlagToFirstAvailableLanguageVersion = map[RegularExpressionFlags]core. RegularExpressionFlagsHasIndices: core.ScriptTargetES2022, RegularExpressionFlagsDotAll: core.ScriptTargetES2018, RegularExpressionFlagsUnicode: core.ScriptTargetES2015, - RegularExpressionFlagsUnicodeSets: core.ScriptTargetESNext, + RegularExpressionFlagsUnicodeSets: core.ScriptTargetES2024, RegularExpressionFlagsSticky: core.ScriptTargetES2015, } diff --git a/testdata/baselines/reference/submodule/compiler/regExpWithOpenBracketInCharClass(target=es2015).errors.txt b/testdata/baselines/reference/submodule/compiler/regExpWithOpenBracketInCharClass(target=es2015).errors.txt index eb71d3c8153..86e97bc3edc 100644 --- a/testdata/baselines/reference/submodule/compiler/regExpWithOpenBracketInCharClass(target=es2015).errors.txt +++ b/testdata/baselines/reference/submodule/compiler/regExpWithOpenBracketInCharClass(target=es2015).errors.txt @@ -1,5 +1,5 @@ regExpWithOpenBracketInCharClass.ts(4,7): error TS1005: ']' expected. -regExpWithOpenBracketInCharClass.ts(4,8): error TS1501: This regular expression flag is only available when targeting 'esnext' or later. +regExpWithOpenBracketInCharClass.ts(4,8): error TS1501: This regular expression flag is only available when targeting 'es2024' or later. ==== regExpWithOpenBracketInCharClass.ts (2 errors) ==== @@ -10,6 +10,6 @@ regExpWithOpenBracketInCharClass.ts(4,8): error TS1501: This regular expression !!! error TS1005: ']' expected. ~ -!!! error TS1501: This regular expression flag is only available when targeting 'esnext' or later. +!!! 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 db83779eeaa..00000000000 --- a/testdata/baselines/reference/submodule/compiler/regExpWithOpenBracketInCharClass(target=es2015).errors.txt.diff +++ /dev/null @@ -1,17 +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(4,8): error TS1501: This regular expression flag is only available when targeting 'esnext' or later. - - - ==== regExpWithOpenBracketInCharClass.ts (2 errors) ==== -@@= skipped -9, +9 lines =@@ - - !!! error TS1005: ']' expected. - ~ --!!! 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 'esnext' or later. - ]; - \ 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 index e5afde3d2f4..a32fb1567c5 100644 --- a/testdata/baselines/reference/submodule/compiler/regularExpressionScanning(target=es2015).errors.txt +++ b/testdata/baselines/reference/submodule/compiler/regularExpressionScanning(target=es2015).errors.txt @@ -1,4 +1,4 @@ -regularExpressionScanning.ts(3,7): error TS1501: This regular expression flag is only available when targeting 'esnext' or later. +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. @@ -72,7 +72,7 @@ regularExpressionScanning.ts(21,28): error TS1529: Unknown Unicode property name 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 'esnext' or later. +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. @@ -108,7 +108,7 @@ regularExpressionScanning.ts(25,53): error TS1531: '\p' must be followed by a Un 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 'esnext' or later. +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. @@ -124,7 +124,7 @@ regularExpressionScanning.ts(27,47): error TS1528: Any Unicode property that wou 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 'esnext' or later. +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. @@ -156,7 +156,7 @@ regularExpressionScanning.ts(34,42): error TS1508: Unexpected ']'. Did you mean 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 'esnext' or later. +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. @@ -191,32 +191,32 @@ 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 'esnext' or later. +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 'esnext' or later. -regularExpressionScanning.ts(40,83): error TS1501: This regular expression flag is only available when targeting 'esnext' or later. +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 'esnext' or later. +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 'esnext' or later. -regularExpressionScanning.ts(43,95): error TS1501: This regular expression flag is only available when targeting 'esnext' or later. +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 'esnext' or later. +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 'esnext' or later. +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 'esnext' or later. +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 'esnext' or later. +regularExpressionScanning.ts(47,101): error TS1501: This regular expression flag is only available when targeting 'es2024' or later. ==== regularExpressionScanning.ts (219 errors) ==== @@ -224,7 +224,7 @@ regularExpressionScanning.ts(47,101): error TS1501: This regular expression flag // Flags /foo/visualstudiocode, ~ -!!! error TS1501: This regular expression flag is only available when targeting 'esnext' or later. +!!! 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. ~ @@ -391,7 +391,7 @@ regularExpressionScanning.ts(47,101): error TS1501: This regular expression flag ~~~~~~~ !!! error TS1529: Unknown Unicode property name or value. ~ -!!! error TS1501: This regular expression flag is only available when targeting 'esnext' or later. +!!! 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. @@ -466,7 +466,7 @@ regularExpressionScanning.ts(47,101): error TS1501: This regular expression flag !!! error TS1527: Expected a Unicode property name or value. ~ -!!! error TS1501: This regular expression flag is only available when targeting 'esnext' or later. +!!! 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. @@ -501,7 +501,7 @@ regularExpressionScanning.ts(47,101): error TS1501: This regular expression flag ~~~~~~~~~ !!! 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 'esnext' or later. +!!! 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, @@ -571,7 +571,7 @@ regularExpressionScanning.ts(47,101): error TS1501: This regular expression flag !!! error TS1005: '}' expected. ~ -!!! error TS1501: This regular expression flag is only available when targeting 'esnext' or later. +!!! 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}&&]/, ~~~ @@ -645,24 +645,24 @@ regularExpressionScanning.ts(47,101): error TS1501: This regular expression flag !!! error TS1520: Expected a class set operand. ~ -!!! error TS1501: This regular expression flag is only available when targeting 'esnext' or later. +!!! 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 'esnext' or later. +!!! 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 'esnext' or later. +!!! 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 'esnext' or later. +!!! 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. @@ -671,17 +671,17 @@ regularExpressionScanning.ts(47,101): error TS1501: This regular expression flag ~~~~~~~~~~~~~~~~~~~~~~ !!! 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 'esnext' or later. +!!! 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 'esnext' or later. +!!! 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 'esnext' or later. +!!! 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. @@ -690,20 +690,20 @@ regularExpressionScanning.ts(47,101): error TS1501: This regular expression flag ~~~~~~~~~~~~~~~~~~~~~~~~~~ !!! 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 'esnext' or later. +!!! 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 'esnext' or later. +!!! 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 'esnext' or later. +!!! 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 b3231ede6ab..00000000000 --- a/testdata/baselines/reference/submodule/compiler/regularExpressionScanning(target=es2015).errors.txt.diff +++ /dev/null @@ -1,206 +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,7): error TS1501: This regular expression flag is only available when targeting 'esnext' 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. -@@= skipped -71, +71 lines =@@ - 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(22,72): error TS1501: This regular expression flag is only available when targeting 'esnext' 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. -@@= skipped -36, +36 lines =@@ - 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(25,67): error TS1501: This regular expression flag is only available when targeting 'esnext' 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. -@@= skipped -16, +16 lines =@@ - 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(28,59): error TS1501: This regular expression flag is only available when targeting 'esnext' 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. -@@= skipped -32, +32 lines =@@ - 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(34,47): error TS1501: This regular expression flag is only available when targeting 'esnext' 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. -@@= skipped -35, +35 lines =@@ - 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(38,87): error TS1501: This regular expression flag is only available when targeting 'esnext' 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(39,77): error TS1501: This regular expression flag is only available when targeting 'esnext' or later. -+regularExpressionScanning.ts(40,83): error TS1501: This regular expression flag is only available when targeting 'esnext' 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(41,83): error TS1501: This regular expression flag is only available when targeting 'esnext' 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(42,77): error TS1501: This regular expression flag is only available when targeting 'esnext' or later. -+regularExpressionScanning.ts(43,95): error TS1501: This regular expression flag is only available when targeting 'esnext' 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(44,95): error TS1501: This regular expression flag is only available when targeting 'esnext' 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(45,89): error TS1501: This regular expression flag is only available when targeting 'esnext' 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(46,91): error TS1501: This regular expression flag is only available when targeting 'esnext' 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(47,101): error TS1501: This regular expression flag is only available when targeting 'esnext' or later. - - - ==== regularExpressionScanning.ts (219 errors) ==== -@@= skipped -33, +33 lines =@@ - // 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 'esnext' or later. - ~ - !!! error TS1501: This regular expression flag is only available when targeting 'es2018' or later. - ~ -@@= skipped -167, +167 lines =@@ - ~~~~~~~ - !!! error TS1529: Unknown Unicode property name or value. - ~ --!!! 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 'esnext' 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. -@@= skipped -75, +75 lines =@@ - - !!! error TS1527: Expected a Unicode property name or value. - ~ --!!! 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 'esnext' 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. -@@= skipped -35, +35 lines =@@ - ~~~~~~~~~ - !!! 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. -+!!! error TS1501: This regular expression flag is only available when targeting 'esnext' or later. - // Character escapes - /\c[\c0\ca\cQ\c\C]\c1\C/, - /\c[\c0\ca\cQ\c\C]\c1\C/u, -@@= skipped -70, +70 lines =@@ - - !!! error TS1005: '}' expected. - ~ --!!! 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 'esnext' or later. - // Unicode sets notation - /[a--b[--][\d++[]]&&[[&0-9--]&&[\p{L}]--\P{L}-_-]]&&&\q{foo}[0---9][&&q&&&\q{bar}&&]/, - ~~~ -@@= skipped -74, +74 lines =@@ - - !!! error TS1520: Expected a class set operand. - ~ --!!! 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 'esnext' 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. -+!!! error TS1501: This regular expression flag is only available when targeting 'esnext' 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. -+!!! error TS1501: This regular expression flag is only available when targeting 'esnext' 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. -+!!! error TS1501: This regular expression flag is only available when targeting 'esnext' 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. -@@= skipped -26, +26 lines =@@ - ~~~~~~~~~~~~~~~~~~~~~~ - !!! 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. -+!!! error TS1501: This regular expression flag is only available when targeting 'esnext' 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. -+!!! error TS1501: This regular expression flag is only available when targeting 'esnext' 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. -+!!! error TS1501: This regular expression flag is only available when targeting 'esnext' 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. -@@= skipped -19, +19 lines =@@ - ~~~~~~~~~~~~~~~~~~~~~~~~~~ - !!! 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. -+!!! error TS1501: This regular expression flag is only available when targeting 'esnext' 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. -+!!! error TS1501: This regular expression flag is only available when targeting 'esnext' 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. -+!!! error TS1501: This regular expression flag is only available when targeting 'esnext' or later. - ]; - \ No newline at end of file From e2b725580290e8b483a272c968a92c693347e622 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Burzy=C5=84ski?= Date: Tue, 10 Mar 2026 21:24:20 +0100 Subject: [PATCH 23/43] update surrogate handling --- internal/scanner/regexp.go | 41 ++++++++++++++++--- internal/scanner/scanner.go | 21 ++++++---- internal/scanner/utilities.go | 22 ++++++++++ ...ressionCharacterClassRangeOrder.errors.txt | 15 +++++-- ...onCharacterClassRangeOrder.errors.txt.diff | 39 ++++-------------- 5 files changed, 91 insertions(+), 47 deletions(-) diff --git a/internal/scanner/regexp.go b/internal/scanner/regexp.go index 8676f5cdec6..a72b66c8c4f 100644 --- a/internal/scanner/regexp.go +++ b/internal/scanner/regexp.go @@ -94,6 +94,11 @@ type regExpParser struct { groupNameReferences []groupNameReference decimalEscapes []decimalEscapeValue namedCapturingGroups []map[string]bool + + // pendingLowSurrogate holds the low surrogate to emit on the next + // scanSourceCharacter call when a non-BMP character is split into two + // surrogate code units in non-unicode mode. + pendingLowSurrogate rune } func (p *regExpParser) pos() int { @@ -301,6 +306,7 @@ func (p *regExpParser) scanAlternative(isInGroup bool) { p.scanClassSetExpression() } else { p.scanClassRanges() + p.pendingLowSurrogate = 0 } p.scanExpectedChar(']') isPreviousTermQuantifiable = true @@ -471,6 +477,7 @@ func (p *regExpParser) isClassContentExit(ch rune) bool { // ClassRanges ::= '^'? (ClassAtom ('-' ClassAtom)?)* func (p *regExpParser) scanClassRanges() { + p.pendingLowSurrogate = 0 if p.charAt(p.pos()) == '^' { p.incPos(1) } @@ -499,8 +506,8 @@ func (p *regExpParser) scanClassRanges() { if minCharacter == "" { continue } - minCharacterValue, minSize := utf8.DecodeRuneInString(minCharacter) - maxCharacterValue, maxSize := utf8.DecodeRuneInString(maxCharacter) + minCharacterValue, minSize := decodeClassAtomRune(minCharacter) + maxCharacterValue, maxSize := decodeClassAtomRune(maxCharacter) if len(minCharacter) == minSize && len(maxCharacter) == maxSize && minCharacterValue > maxCharacterValue { p.error(diagnostics.Range_out_of_order_in_character_class, minStart, p.pos()-minStart) } @@ -595,8 +602,8 @@ func (p *regExpParser) scanClassSetExpression() { if secondOperand == "" { p.error(diagnostics.A_character_class_range_must_not_be_bounded_by_another_character_class, secondStart, p.pos()-secondStart) } else if operand != "" { - minCharacterValue, minSize := utf8.DecodeRuneInString(operand) - maxCharacterValue, maxSize := utf8.DecodeRuneInString(secondOperand) + minCharacterValue, minSize := decodeClassAtomRune(operand) + maxCharacterValue, maxSize := decodeClassAtomRune(secondOperand) if len(operand) == minSize && len(secondOperand) == maxSize && minCharacterValue > maxCharacterValue { p.error(diagnostics.Range_out_of_order_in_character_class, start, p.pos()-start) } @@ -953,8 +960,30 @@ func (p *regExpParser) scanSourceCharacter() string { return "" } if !p.anyUnicodeMode { - ch := p.text()[p.pos()] - p.incPos(1) + if p.pendingLowSurrogate != 0 { + // Second of two surrogate code units for the same non-BMP character. + // Now advance past the full UTF-8 sequence (the high surrogate call did not advance). + _, size := utf8.DecodeRuneInString(p.text()[p.pos():]) + p.incPos(size) + low := p.pendingLowSurrogate + p.pendingLowSurrogate = 0 + return encodeSurrogate(low) + } + ch, size := utf8.DecodeRuneInString(p.text()[p.pos():]) + if ch == utf8.RuneError || size == 0 { + // Not a valid rune; consume one raw byte. + p.incPos(1) + return string(p.text()[p.pos()-1]) + } + if ch >= surrSelf { + // Non-BMP character: emit the high surrogate first WITHOUT advancing. + // The low surrogate will be emitted on the next call, which also advances. + high := surr1 + (ch-surrSelf)>>10 + low := surr2 + (ch-surrSelf)&0x3FF + p.pendingLowSurrogate = low + return encodeSurrogate(high) + } + p.incPos(size) return string(ch) } ch, size := utf8.DecodeRuneInString(p.text()[p.pos():]) diff --git a/internal/scanner/scanner.go b/internal/scanner/scanner.go index 59eef764465..eb125118d0c 100644 --- a/internal/scanner/scanner.go +++ b/internal/scanner/scanner.go @@ -1758,18 +1758,25 @@ func (s *Scanner) scanEscapeSequence(flags EscapeSequenceScanningFlags) string { } if codePoint < 0 { return s.text[start:s.pos] - } else if codePointIsHighSurrogate(codePoint) && s.char() == '\\' && s.charAt(1) == 'u' && s.charAt(2) != '{' { - // In TypeScript (UTF-16), \uHigh \uLow forms a valid surrogate pair string value. - // In Go (UTF-8), lone surrogates are invalid, so we always combine adjacent pairs - // regardless of unicode mode to preserve the intended code point. - // In regexp AnyUnicodeMode, this also aligns with the spec treatment of surrogate pairs - // as a single character for character class range ordering. + } else if codePointIsHighSurrogate(codePoint) && + (flags&EscapeSequenceScanningFlagsRegularExpression == 0 || flags&EscapeSequenceScanningFlagsAnyUnicodeMode != 0) && + s.char() == '\\' && s.charAt(1) == 'u' && s.charAt(2) != '{' { + // Combine \uHigh\uLow into a single code point in string literals (always) and + // in regex AnyUnicodeMode. In non-unicode regex mode they are separate atoms. savedPos := s.pos nextCodePoint := s.scanUnicodeEscape(flags&EscapeSequenceScanningFlagsReportInvalidEscapeErrors != 0) if codePointIsLowSurrogate(nextCodePoint) { return string(surrogatePairToCodepoint(codePoint, nextCodePoint)) } - s.pos = savedPos // restore position because we do not consume nextCodePoint + s.pos = savedPos + if flags&EscapeSequenceScanningFlagsRegularExpression != 0 { + return encodeSurrogate(codePoint) + } + } else if (codePointIsHighSurrogate(codePoint) || codePointIsLowSurrogate(codePoint)) && + flags&EscapeSequenceScanningFlagsRegularExpression != 0 { + // Lone surrogate inside a non-unicode regex: encode as CESU-8 so scanClassRanges + // can compare surrogates numerically. Must NOT apply to string literals. + return encodeSurrogate(codePoint) } return string(codePoint) case 'x': diff --git a/internal/scanner/utilities.go b/internal/scanner/utilities.go index 06b29a1e2aa..a5bb3008e58 100644 --- a/internal/scanner/utilities.go +++ b/internal/scanner/utilities.go @@ -27,6 +27,28 @@ func surrogatePairToCodepoint(r1, r2 rune) rune { return (r1-surr1)<<10 | (r2 - surr2) + surrSelf } +// encodeSurrogate encodes a surrogate code unit (0xD800–0xDFFF) as a 3-byte +// CESU-8 sequence. Standard UTF-8 decoders reject this range, so it acts as a +// sentinel that decodeClassAtomRune can identify when comparing class ranges in +// non-unicode regex mode (where surrogates are valid individual characters). +func encodeSurrogate(r rune) string { + return string([]byte{ + 0xED, + byte(0x80 | ((r >> 6) & 0x3F)), + byte(0x80 | (r & 0x3F)), + }) +} + +// decodeClassAtomRune is like utf8.DecodeRuneInString but also handles +// surrogate code units encoded by encodeSurrogate. +func decodeClassAtomRune(s string) (rune, int) { + if len(s) >= 3 && s[0] == 0xED && s[1] >= 0xA0 && s[1] <= 0xBF && s[2] >= 0x80 && s[2] <= 0xBF { + r := rune(0xD000) | rune(s[1]&0x3F)<<6 | rune(s[2]&0x3F) + return r, 3 + } + return utf8.DecodeRuneInString(s) +} + func tokenIsIdentifierOrKeyword(token ast.Kind) bool { return token >= ast.KindIdentifier } diff --git a/testdata/baselines/reference/submodule/compiler/regularExpressionCharacterClassRangeOrder.errors.txt b/testdata/baselines/reference/submodule/compiler/regularExpressionCharacterClassRangeOrder.errors.txt index 155c05d3679..97eb5506e44 100644 --- a/testdata/baselines/reference/submodule/compiler/regularExpressionCharacterClassRangeOrder.errors.txt +++ b/testdata/baselines/reference/submodule/compiler/regularExpressionCharacterClassRangeOrder.errors.txt @@ -1,3 +1,5 @@ +regularExpressionCharacterClassRangeOrder.ts(7,4): error TS1517: Range out of order in character class. +regularExpressionCharacterClassRangeOrder.ts(7,11): 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. @@ -7,12 +9,13 @@ regularExpressionCharacterClassRangeOrder.ts(11,25): error TS1517: Range out of 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,31): 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 (12 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) @@ -20,6 +23,10 @@ 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, ~~~ !!! error TS1517: Range out of order in character class. @@ -46,7 +53,9 @@ regularExpressionCharacterClassRangeOrder.ts(17,31): error TS1517: Range out of !!! 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, ~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/testdata/baselines/reference/submodule/compiler/regularExpressionCharacterClassRangeOrder.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/regularExpressionCharacterClassRangeOrder.errors.txt.diff index 3041752b9b1..b12961b6457 100644 --- a/testdata/baselines/reference/submodule/compiler/regularExpressionCharacterClassRangeOrder.errors.txt.diff +++ b/testdata/baselines/reference/submodule/compiler/regularExpressionCharacterClassRangeOrder.errors.txt.diff @@ -3,33 +3,21 @@ @@= skipped -0, +0 lines =@@ -regularExpressionCharacterClassRangeOrder.ts(7,5): error TS1517: Range out of order in character class. -regularExpressionCharacterClassRangeOrder.ts(7,12): 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,11): 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. -@@= skipped -8, +6 lines =@@ - 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(15,31): 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 (15 errors) ==== -+==== regularExpressionCharacterClassRangeOrder.ts (12 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 -14, +13 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. - ~~~ --!!! error TS1517: Range out of order in character class. ++ ~~ + !!! error TS1517: Range out of order in character class. /[𝘈-𝘡][𝘡-𝘈]/u, - ~~~~~ + ~~~ @@ -39,15 +27,4 @@ + ~~~ !!! error TS1517: Range out of order in character class. - /[\u{1D608}-\u{1D621}][\u{1D621}-\u{1D608}]/, -@@= skipped -30, +26 lines =@@ - !!! 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, - ~~~~~~~~~~~~~~~~~~~~~~~~~ \ No newline at end of file + /[\u{1D608}-\u{1D621}][\u{1D621}-\u{1D608}]/, \ No newline at end of file From 6998167ca083e11208fa24c3786881a95afac927 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Burzy=C5=84ski?= Date: Wed, 11 Mar 2026 17:42:24 +0100 Subject: [PATCH 24/43] accept changes --- .../regularExpressionCharacterClassRangeOrder.errors.txt.diff | 0 .../compiler/regularExpressionWithNonBMPFlags.errors.txt.diff | 0 testdata/submoduleAccepted.txt | 3 +++ 3 files changed, 3 insertions(+) rename testdata/baselines/reference/{submodule => submoduleAccepted}/compiler/regularExpressionCharacterClassRangeOrder.errors.txt.diff (100%) rename testdata/baselines/reference/{submodule => submoduleAccepted}/compiler/regularExpressionWithNonBMPFlags.errors.txt.diff (100%) diff --git a/testdata/baselines/reference/submodule/compiler/regularExpressionCharacterClassRangeOrder.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/regularExpressionCharacterClassRangeOrder.errors.txt.diff similarity index 100% rename from testdata/baselines/reference/submodule/compiler/regularExpressionCharacterClassRangeOrder.errors.txt.diff rename to testdata/baselines/reference/submoduleAccepted/compiler/regularExpressionCharacterClassRangeOrder.errors.txt.diff diff --git a/testdata/baselines/reference/submodule/compiler/regularExpressionWithNonBMPFlags.errors.txt.diff b/testdata/baselines/reference/submoduleAccepted/compiler/regularExpressionWithNonBMPFlags.errors.txt.diff similarity index 100% rename from testdata/baselines/reference/submodule/compiler/regularExpressionWithNonBMPFlags.errors.txt.diff rename to testdata/baselines/reference/submoduleAccepted/compiler/regularExpressionWithNonBMPFlags.errors.txt.diff diff --git a/testdata/submoduleAccepted.txt b/testdata/submoduleAccepted.txt index c0d0157bdf7..ba9fbbeb06f 100644 --- a/testdata/submoduleAccepted.txt +++ b/testdata/submoduleAccepted.txt @@ -57,3 +57,6 @@ fourslash/inlayHints/inlayHintsInteractiveVariableTypes1.baseline.diff fourslash/inlayHints/inlayHintsInteractiveVariableTypes2.baseline.diff fourslash/inlayHints/inlayHintsVariableTypes3.baseline.diff fourslash/inlayHints/inlayHintsInteractiveFunctionParameterTypes1.baseline.diff + +## regex checking ## + From a2a0756b67a4cac6bbc50935b449fb80d6970252 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Burzy=C5=84ski?= Date: Wed, 11 Mar 2026 18:01:06 +0100 Subject: [PATCH 25/43] accept again ? --- .../regularExpressionCharacterClassRangeOrder.errors.txt.diff | 0 .../compiler/regularExpressionWithNonBMPFlags.errors.txt.diff | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename testdata/baselines/reference/{submoduleAccepted => submodule}/compiler/regularExpressionCharacterClassRangeOrder.errors.txt.diff (100%) rename testdata/baselines/reference/{submoduleAccepted => submodule}/compiler/regularExpressionWithNonBMPFlags.errors.txt.diff (100%) diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/regularExpressionCharacterClassRangeOrder.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/regularExpressionCharacterClassRangeOrder.errors.txt.diff similarity index 100% rename from testdata/baselines/reference/submoduleAccepted/compiler/regularExpressionCharacterClassRangeOrder.errors.txt.diff rename to testdata/baselines/reference/submodule/compiler/regularExpressionCharacterClassRangeOrder.errors.txt.diff diff --git a/testdata/baselines/reference/submoduleAccepted/compiler/regularExpressionWithNonBMPFlags.errors.txt.diff b/testdata/baselines/reference/submodule/compiler/regularExpressionWithNonBMPFlags.errors.txt.diff similarity index 100% rename from testdata/baselines/reference/submoduleAccepted/compiler/regularExpressionWithNonBMPFlags.errors.txt.diff rename to testdata/baselines/reference/submodule/compiler/regularExpressionWithNonBMPFlags.errors.txt.diff From a6e25addecf11cca52c1be181d4ea82a1246443b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Burzy=C5=84ski?= Date: Wed, 11 Mar 2026 18:18:49 +0100 Subject: [PATCH 26/43] fix lints --- internal/scanner/regexp.go | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/internal/scanner/regexp.go b/internal/scanner/regexp.go index a72b66c8c4f..acb83823d96 100644 --- a/internal/scanner/regexp.go +++ b/internal/scanner/regexp.go @@ -246,31 +246,31 @@ func (p *regExpParser) scanAlternative(isInGroup bool) { p.incPos(1) digitsStart := p.pos() p.scanDigits() - min := p.scanner.tokenValue - if !p.anyUnicodeModeOrNonAnnexB && min == "" { + minStr := p.scanner.tokenValue + if !p.anyUnicodeModeOrNonAnnexB && minStr == "" { isPreviousTermQuantifiable = true continue } if p.charAt(p.pos()) == ',' { p.incPos(1) p.scanDigits() - max := p.scanner.tokenValue - if min == "" { - if max != "" || p.charAt(p.pos()) == '}' { + maxStr := p.scanner.tokenValue + if minStr == "" { + if maxStr != "" || p.charAt(p.pos()) == '}' { p.error(diagnostics.Incomplete_quantifier_Digit_expected, digitsStart, 0) } else { p.error(diagnostics.Unexpected_0_Did_you_mean_to_escape_it_with_backslash, start, 1, string(ch)) isPreviousTermQuantifiable = true continue } - } else if max != "" { - minVal, _ := strconv.Atoi(min) - maxVal, _ := strconv.Atoi(max) + } else if maxStr != "" { + minVal, _ := strconv.Atoi(minStr) + maxVal, _ := strconv.Atoi(maxStr) if minVal > maxVal && (p.anyUnicodeModeOrNonAnnexB || p.charAt(p.pos()) == '}') { p.error(diagnostics.Numbers_out_of_order_in_quantifier, digitsStart, p.pos()-digitsStart) } } - } else if min == "" { + } else if minStr == "" { if p.anyUnicodeModeOrNonAnnexB { p.error(diagnostics.Unexpected_0_Did_you_mean_to_escape_it_with_backslash, start, 1, string(ch)) } @@ -417,7 +417,7 @@ func (p *regExpParser) scanCharacterEscape(atomEscape bool) string { ch = p.charAt(p.pos()) if stringutil.IsASCIILetter(ch) { p.incPos(1) - return string(rune(ch & 0x1f)) + return string(ch & 0x1f) } if p.anyUnicodeModeOrNonAnnexB { p.error(diagnostics.X_c_must_be_followed_by_an_ASCII_letter, p.pos()-2, 2) From 970eeb3e3b5c75a76ef1847691c12153aabd3f12 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Burzy=C5=84ski?= Date: Thu, 12 Mar 2026 08:43:13 +0100 Subject: [PATCH 27/43] drop the 2015 availability stuff --- internal/checker/types.go | 4 ---- internal/scanner/regexp.go | 2 -- 2 files changed, 6 deletions(-) diff --git a/internal/checker/types.go b/internal/checker/types.go index 1203055f4ce..fd4df41304a 100644 --- a/internal/checker/types.go +++ b/internal/checker/types.go @@ -1253,8 +1253,6 @@ const ( type TypeComparer func(s *Type, t *Type, reportErrors bool) Ternary type LanguageFeatureMinimumTargetMap struct { - RegularExpressionFlagsUnicode core.ScriptTarget - RegularExpressionFlagsSticky core.ScriptTarget Exponentiation core.ScriptTarget AsyncFunctions core.ScriptTarget ForAwaitOf core.ScriptTarget @@ -1278,8 +1276,6 @@ type LanguageFeatureMinimumTargetMap struct { } var LanguageFeatureMinimumTarget = LanguageFeatureMinimumTargetMap{ - RegularExpressionFlagsUnicode: core.ScriptTargetES2015, - RegularExpressionFlagsSticky: core.ScriptTargetES2015, Exponentiation: core.ScriptTargetES2016, AsyncFunctions: core.ScriptTargetES2017, ForAwaitOf: core.ScriptTargetES2018, diff --git a/internal/scanner/regexp.go b/internal/scanner/regexp.go index acb83823d96..04e41d5afe6 100644 --- a/internal/scanner/regexp.go +++ b/internal/scanner/regexp.go @@ -40,9 +40,7 @@ var charCodeToRegExpFlag = map[rune]RegularExpressionFlags{ var regExpFlagToFirstAvailableLanguageVersion = map[RegularExpressionFlags]core.ScriptTarget{ RegularExpressionFlagsHasIndices: core.ScriptTargetES2022, RegularExpressionFlagsDotAll: core.ScriptTargetES2018, - RegularExpressionFlagsUnicode: core.ScriptTargetES2015, RegularExpressionFlagsUnicodeSets: core.ScriptTargetES2024, - RegularExpressionFlagsSticky: core.ScriptTargetES2015, } func CharacterCodeToRegularExpressionFlag(ch rune) (RegularExpressionFlags, bool) { From ffff27d229a20416999baf7c7f27d5bb9c180550 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Burzy=C5=84ski?= Date: Thu, 12 Mar 2026 08:43:54 +0100 Subject: [PATCH 28/43] remove unused `lastDiagnostic` --- internal/parser/parser.go | 7 ------- 1 file changed, 7 deletions(-) diff --git a/internal/parser/parser.go b/internal/parser/parser.go index 45441a79d12..0650665d782 100644 --- a/internal/parser/parser.go +++ b/internal/parser/parser.go @@ -254,13 +254,6 @@ func (p *Parser) scanError(message *diagnostics.Message, pos int, length int, ar p.parseErrorAtRange(core.NewTextRange(pos, pos+length), message, args...) } -func (p *Parser) lastDiagnostic() *ast.Diagnostic { - if len(p.diagnostics) > 0 { - return p.diagnostics[len(p.diagnostics)-1] - } - return nil -} - func (p *Parser) parseErrorAt(pos int, end int, message *diagnostics.Message, args ...any) *ast.Diagnostic { return p.parseErrorAtRange(core.NewTextRange(pos, end), message, args...) } From b5b1755f90e69fc366f260734c33cf28384f0abb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Burzy=C5=84ski?= Date: Thu, 12 Mar 2026 08:56:01 +0100 Subject: [PATCH 29/43] privatize what needs to be privatized --- internal/scanner/regexp.go | 67 +++++++++++++++++-------------------- internal/scanner/scanner.go | 10 +++--- 2 files changed, 36 insertions(+), 41 deletions(-) diff --git a/internal/scanner/regexp.go b/internal/scanner/regexp.go index 04e41d5afe6..6f8101346e9 100644 --- a/internal/scanner/regexp.go +++ b/internal/scanner/regexp.go @@ -10,45 +10,40 @@ import ( "github.com/microsoft/typescript-go/internal/stringutil" ) -type RegularExpressionFlags int32 +type regularExpressionFlags int32 const ( - RegularExpressionFlagsNone RegularExpressionFlags = 0 - RegularExpressionFlagsHasIndices RegularExpressionFlags = 1 << 0 // d - RegularExpressionFlagsGlobal RegularExpressionFlags = 1 << 1 // g - RegularExpressionFlagsIgnoreCase RegularExpressionFlags = 1 << 2 // i - RegularExpressionFlagsMultiline RegularExpressionFlags = 1 << 3 // m - RegularExpressionFlagsDotAll RegularExpressionFlags = 1 << 4 // s - RegularExpressionFlagsUnicode RegularExpressionFlags = 1 << 5 // u - RegularExpressionFlagsUnicodeSets RegularExpressionFlags = 1 << 6 // v - RegularExpressionFlagsSticky RegularExpressionFlags = 1 << 7 // y - RegularExpressionFlagsAnyUnicodeMode RegularExpressionFlags = RegularExpressionFlagsUnicode | RegularExpressionFlagsUnicodeSets - RegularExpressionFlagsModifiers RegularExpressionFlags = RegularExpressionFlagsIgnoreCase | RegularExpressionFlagsMultiline | RegularExpressionFlagsDotAll + regularExpressionFlagsNone regularExpressionFlags = 0 + regularExpressionFlagsHasIndices regularExpressionFlags = 1 << 0 // d + regularExpressionFlagsGlobal regularExpressionFlags = 1 << 1 // g + regularExpressionFlagsIgnoreCase regularExpressionFlags = 1 << 2 // i + regularExpressionFlagsMultiline regularExpressionFlags = 1 << 3 // m + regularExpressionFlagsDotAll regularExpressionFlags = 1 << 4 // s + regularExpressionFlagsUnicode regularExpressionFlags = 1 << 5 // u + regularExpressionFlagsUnicodeSets regularExpressionFlags = 1 << 6 // v + regularExpressionFlagsSticky regularExpressionFlags = 1 << 7 // y + regularExpressionFlagsAnyUnicodeMode regularExpressionFlags = regularExpressionFlagsUnicode | regularExpressionFlagsUnicodeSets + regularExpressionFlagsModifiers regularExpressionFlags = regularExpressionFlagsIgnoreCase | regularExpressionFlagsMultiline | regularExpressionFlagsDotAll ) -var charCodeToRegExpFlag = map[rune]RegularExpressionFlags{ - 'd': RegularExpressionFlagsHasIndices, - 'g': RegularExpressionFlagsGlobal, - 'i': RegularExpressionFlagsIgnoreCase, - 'm': RegularExpressionFlagsMultiline, - 's': RegularExpressionFlagsDotAll, - 'u': RegularExpressionFlagsUnicode, - 'v': RegularExpressionFlagsUnicodeSets, - 'y': RegularExpressionFlagsSticky, +var charCodeToRegExpFlag = map[rune]regularExpressionFlags{ + 'd': regularExpressionFlagsHasIndices, + 'g': regularExpressionFlagsGlobal, + 'i': regularExpressionFlagsIgnoreCase, + 'm': regularExpressionFlagsMultiline, + 's': regularExpressionFlagsDotAll, + 'u': regularExpressionFlagsUnicode, + 'v': regularExpressionFlagsUnicodeSets, + 'y': regularExpressionFlagsSticky, } -var regExpFlagToFirstAvailableLanguageVersion = map[RegularExpressionFlags]core.ScriptTarget{ - RegularExpressionFlagsHasIndices: core.ScriptTargetES2022, - RegularExpressionFlagsDotAll: core.ScriptTargetES2018, - RegularExpressionFlagsUnicodeSets: core.ScriptTargetES2024, +var regExpFlagToFirstAvailableLanguageVersion = map[regularExpressionFlags]core.ScriptTarget{ + regularExpressionFlagsHasIndices: core.ScriptTargetES2022, + regularExpressionFlagsDotAll: core.ScriptTargetES2018, + regularExpressionFlagsUnicodeSets: core.ScriptTargetES2024, } -func CharacterCodeToRegularExpressionFlag(ch rune) (RegularExpressionFlags, bool) { - flag, ok := charCodeToRegExpFlag[ch] - return flag, ok -} - -func (s *Scanner) checkRegularExpressionFlagAvailability(flag RegularExpressionFlags, pos int, size int) { +func (s *Scanner) checkRegularExpressionFlagAvailability(flag regularExpressionFlags, pos int, size int) { if availableFrom, ok := regExpFlagToFirstAvailableLanguageVersion[flag]; ok && s.languageVersion() < availableFrom { s.errorAt(diagnostics.This_regular_expression_flag_is_only_available_when_targeting_0_or_later, pos, size, strings.ToLower(availableFrom.String())) } @@ -78,7 +73,7 @@ type decimalEscapeValue struct { type regExpParser struct { scanner *Scanner end int - regExpFlags RegularExpressionFlags + regExpFlags regularExpressionFlags anyUnicodeMode bool unicodeSetsMode bool annexB bool @@ -223,7 +218,7 @@ func (p *regExpParser) scanAlternative(isInGroup bool) { } default: flagsStart := p.pos() - setFlags := p.scanPatternModifiers(RegularExpressionFlagsNone) + setFlags := p.scanPatternModifiers(regularExpressionFlagsNone) if p.charAt(p.pos()) == '-' { p.incPos(1) p.scanPatternModifiers(setFlags) @@ -328,18 +323,18 @@ func (p *regExpParser) scanAlternative(isInGroup bool) { } } -func (p *regExpParser) scanPatternModifiers(currFlags RegularExpressionFlags) RegularExpressionFlags { +func (p *regExpParser) scanPatternModifiers(currFlags regularExpressionFlags) regularExpressionFlags { for p.pos() < p.end { ch, size := utf8.DecodeRuneInString(p.text()[p.pos():]) if ch == utf8.RuneError || !IsIdentifierPart(ch) { break } - flag, ok := CharacterCodeToRegularExpressionFlag(ch) + flag, ok := charCodeToRegExpFlag[ch] if !ok { p.error(diagnostics.Unknown_regular_expression_flag, p.pos(), size) } else if currFlags&flag != 0 { p.error(diagnostics.Duplicate_regular_expression_flag, p.pos(), size) - } else if flag&RegularExpressionFlagsModifiers == 0 { + } else if flag®ularExpressionFlagsModifiers == 0 { p.error(diagnostics.This_regular_expression_flag_cannot_be_toggled_within_a_subpattern, p.pos(), size) } else { currFlags |= flag diff --git a/internal/scanner/scanner.go b/internal/scanner/scanner.go index eb125118d0c..e93eb4ccd31 100644 --- a/internal/scanner/scanner.go +++ b/internal/scanner/scanner.go @@ -1152,19 +1152,19 @@ func (s *Scanner) ReScanSlashToken(reportErrors ...bool) ast.Kind { } else { // Consume the slash character p++ - var regExpFlags RegularExpressionFlags + var regExpFlags regularExpressionFlags for p < s.end { ch, size := utf8.DecodeRuneInString(s.text[p:]) if ch == utf8.RuneError || !IsIdentifierPart(ch) { break } if shouldReportErrors { - flag, ok := CharacterCodeToRegularExpressionFlag(ch) + flag, ok := charCodeToRegExpFlag[ch] if !ok { s.errorAt(diagnostics.Unknown_regular_expression_flag, p, size) } else if regExpFlags&flag != 0 { s.errorAt(diagnostics.Duplicate_regular_expression_flag, p, size) - } else if (regExpFlags|flag)&RegularExpressionFlagsAnyUnicodeMode == RegularExpressionFlagsAnyUnicodeMode { + } else if (regExpFlags|flag)®ularExpressionFlagsAnyUnicodeMode == regularExpressionFlagsAnyUnicodeMode { s.errorAt(diagnostics.The_Unicode_u_flag_and_the_Unicode_Sets_v_flag_cannot_be_set_simultaneously, p, size) } else { regExpFlags |= flag @@ -1183,8 +1183,8 @@ func (s *Scanner) ReScanSlashToken(reportErrors ...bool) ast.Kind { scanner: s, end: endOfRegExpBody, regExpFlags: regExpFlags, - anyUnicodeMode: regExpFlags&RegularExpressionFlagsAnyUnicodeMode != 0, - unicodeSetsMode: regExpFlags&RegularExpressionFlagsUnicodeSets != 0, + anyUnicodeMode: regExpFlags®ularExpressionFlagsAnyUnicodeMode != 0, + unicodeSetsMode: regExpFlags®ularExpressionFlagsUnicodeSets != 0, annexB: true, namedCaptureGroups: namedCaptureGroups, groupSpecifiers: make(map[string]bool), From 66afe1f0ec6e90dda246555e6b1405cbf5a54d96 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Burzy=C5=84ski?= Date: Thu, 12 Mar 2026 09:11:49 +0100 Subject: [PATCH 30/43] reuse `collections.NewSetFromItems` --- internal/scanner/regexp.go | 16 ++++++++-------- internal/scanner/unicodeproperties.go | 20 +++++++------------- 2 files changed, 15 insertions(+), 21 deletions(-) diff --git a/internal/scanner/regexp.go b/internal/scanner/regexp.go index 6f8101346e9..6d766c02854 100644 --- a/internal/scanner/regexp.go +++ b/internal/scanner/regexp.go @@ -860,7 +860,7 @@ func (p *regExpParser) scanCharacterClassEscape() bool { p.error(diagnostics.Expected_a_Unicode_property_value, p.pos(), 0) } else if propertyName != "" { values := valuesOfNonBinaryUnicodeProperties[propertyName] - if values != nil && !values[propertyValue] { + if values != nil && !values.Has(propertyValue) { p.error(diagnostics.Unknown_Unicode_property_value, propertyValueStart, p.pos()-propertyValueStart) suggestion := p.getSpellingSuggestionForUnicodePropertyValue(propertyName, propertyValue) if suggestion != "" { @@ -871,7 +871,7 @@ func (p *regExpParser) scanCharacterClassEscape() bool { } else { if p.pos() == propertyNameOrValueStart { p.error(diagnostics.Expected_a_Unicode_property_name_or_value, p.pos(), 0) - } else if binaryUnicodePropertiesOfStrings[propertyNameOrValue] { + } else if binaryUnicodePropertiesOfStrings.Has(propertyNameOrValue) { if !p.unicodeSetsMode { p.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, p.pos()-propertyNameOrValueStart) } else if isCharacterComplement { @@ -879,7 +879,7 @@ func (p *regExpParser) scanCharacterClassEscape() bool { } else { p.mayContainStrings = true } - } else if !valuesOfNonBinaryUnicodeProperties["General_Category"][propertyNameOrValue] && !binaryUnicodeProperties[propertyNameOrValue] { + } else if !valuesOfNonBinaryUnicodeProperties["General_Category"].Has(propertyNameOrValue) && !binaryUnicodeProperties.Has(propertyNameOrValue) { p.error(diagnostics.Unknown_Unicode_property_name_or_value, propertyNameOrValueStart, p.pos()-propertyNameOrValueStart) suggestion := p.getSpellingSuggestionForUnicodePropertyNameOrValue(propertyNameOrValue) if suggestion != "" { @@ -915,8 +915,8 @@ func (p *regExpParser) getSpellingSuggestionForUnicodePropertyValue(propertyName if values == nil { return "" } - candidates := make([]string, 0, len(values)) - for k := range values { + candidates := make([]string, 0, values.Len()) + for k := range values.Keys() { candidates = append(candidates, k) } return core.GetSpellingSuggestion(value, candidates, func(s string) string { return s }) @@ -924,13 +924,13 @@ func (p *regExpParser) getSpellingSuggestionForUnicodePropertyValue(propertyName func (p *regExpParser) getSpellingSuggestionForUnicodePropertyNameOrValue(name string) string { var candidates []string - for k := range valuesOfNonBinaryUnicodeProperties["General_Category"] { + for k := range valuesOfNonBinaryUnicodeProperties["General_Category"].Keys() { candidates = append(candidates, k) } - for k := range binaryUnicodeProperties { + for k := range binaryUnicodeProperties.Keys() { candidates = append(candidates, k) } - for k := range binaryUnicodePropertiesOfStrings { + for k := range binaryUnicodePropertiesOfStrings.Keys() { candidates = append(candidates, k) } return core.GetSpellingSuggestion(name, candidates, func(s string) string { return s }) diff --git a/internal/scanner/unicodeproperties.go b/internal/scanner/unicodeproperties.go index 9de4786e745..3c24e894569 100644 --- a/internal/scanner/unicodeproperties.go +++ b/internal/scanner/unicodeproperties.go @@ -1,5 +1,7 @@ package scanner +import "github.com/microsoft/typescript-go/internal/collections" + // Table 66: Non-binary Unicode property aliases and their canonical property names // https://tc39.es/ecma262/#table-nonbinary-unicode-properties var nonBinaryUnicodeProperties = map[string]string{ @@ -13,7 +15,7 @@ var nonBinaryUnicodeProperties = map[string]string{ // Table 67: Binary Unicode property aliases and their canonical property names // https://tc39.es/ecma262/#table-binary-unicode-properties -var binaryUnicodeProperties = newStringSet( +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", @@ -50,15 +52,15 @@ var binaryUnicodeProperties = newStringSet( // Table 68: Binary Unicode properties of strings // https://tc39.es/ecma262/#table-binary-unicode-properties-of-strings -var binaryUnicodePropertiesOfStrings = newStringSet( +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 -var valuesOfNonBinaryUnicodeProperties = map[string]map[string]bool{ - "General_Category": newStringSet( +var valuesOfNonBinaryUnicodeProperties = map[string]*collections.Set[string]{ + "General_Category": 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", @@ -74,7 +76,7 @@ var valuesOfNonBinaryUnicodeProperties = map[string]map[string]bool{ "Z", "Separator", "Zl", "Line_Separator", "Zp", "Paragraph_Separator", "Zs", "Space_Separator", ), - "Script": newStringSet( + "Script": 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", @@ -156,11 +158,3 @@ var valuesOfNonBinaryUnicodeProperties = map[string]map[string]bool{ func init() { valuesOfNonBinaryUnicodeProperties["Script_Extensions"] = valuesOfNonBinaryUnicodeProperties["Script"] } - -func newStringSet(values ...string) map[string]bool { - m := make(map[string]bool, len(values)) - for _, v := range values { - m[v] = true - } - return m -} From ba541a0ffeb9a98d31ad892504d795fe278134b2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Burzy=C5=84ski?= Date: Thu, 12 Mar 2026 18:43:12 +0100 Subject: [PATCH 31/43] Remove unicodeproperties init indirection --- internal/scanner/unicodeproperties.go | 160 +++++++++++++------------- 1 file changed, 79 insertions(+), 81 deletions(-) diff --git a/internal/scanner/unicodeproperties.go b/internal/scanner/unicodeproperties.go index 3c24e894569..e34fc0fd3f9 100644 --- a/internal/scanner/unicodeproperties.go +++ b/internal/scanner/unicodeproperties.go @@ -59,6 +59,83 @@ var binaryUnicodePropertiesOfStrings = collections.NewSetFromItems( ) // Unicode 15.1 +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", +) + var valuesOfNonBinaryUnicodeProperties = map[string]*collections.Set[string]{ "General_Category": collections.NewSetFromItems( "C", "Other", "Cc", "Control", "cntrl", "Cf", "Format", "Cn", "Unassigned", @@ -76,85 +153,6 @@ var valuesOfNonBinaryUnicodeProperties = map[string]*collections.Set[string]{ "Z", "Separator", "Zl", "Line_Separator", "Zp", "Paragraph_Separator", "Zs", "Space_Separator", ), - "Script": 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", - ), - "Script_Extensions": nil, // set to Script values in init() -} - -func init() { - valuesOfNonBinaryUnicodeProperties["Script_Extensions"] = valuesOfNonBinaryUnicodeProperties["Script"] + "Script": scriptValues, + "Script_Extensions": scriptValues, } From b4ab864739b2ad55f0afc28a2067a4d90affe2ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Burzy=C5=84ski?= Date: Fri, 13 Mar 2026 17:13:30 +0100 Subject: [PATCH 32/43] introduce char helper --- internal/scanner/regexp.go | 103 ++++++++++++++++++++----------------- 1 file changed, 55 insertions(+), 48 deletions(-) diff --git a/internal/scanner/regexp.go b/internal/scanner/regexp.go index 6d766c02854..329fbd899bf 100644 --- a/internal/scanner/regexp.go +++ b/internal/scanner/regexp.go @@ -106,6 +106,13 @@ func (p *regExpParser) incPos(n int) { p.scanner.pos += n } +func (p *regExpParser) char() rune { + if p.pos() < p.end { + return rune(p.scanner.text[p.pos()]) + } + return -1 +} + func (p *regExpParser) charAt(pos int) rune { if pos < p.end { return rune(p.scanner.text[pos]) @@ -127,7 +134,7 @@ func (p *regExpParser) scanDisjunction(isInGroup bool) { p.namedCapturingGroups = append(p.namedCapturingGroups, make(map[string]bool)) p.scanAlternative(isInGroup) p.namedCapturingGroups = p.namedCapturingGroups[:len(p.namedCapturingGroups)-1] - if p.charAt(p.pos()) != '|' { + if p.char() != '|' { return } p.incPos(1) @@ -176,14 +183,14 @@ func (p *regExpParser) scanAlternative(isInGroup bool) { isPreviousTermQuantifiable := false for p.pos() < p.end { start := p.pos() - ch := p.charAt(p.pos()) + ch := p.char() switch ch { case '^', '$': p.incPos(1) isPreviousTermQuantifiable = false case '\\': p.incPos(1) - switch p.charAt(p.pos()) { + switch p.char() { case 'b', 'B': p.incPos(1) isPreviousTermQuantifiable = false @@ -193,9 +200,9 @@ func (p *regExpParser) scanAlternative(isInGroup bool) { } case '(': p.incPos(1) - if p.charAt(p.pos()) == '?' { + if p.char() == '?' { p.incPos(1) - switch p.charAt(p.pos()) { + switch p.char() { case '=', '!': p.incPos(1) // In Annex B, `(?=Disjunction)` and `(?!Disjunction)` are quantifiable @@ -203,7 +210,7 @@ func (p *regExpParser) scanAlternative(isInGroup bool) { case '<': groupNameStart := p.pos() p.incPos(1) - switch p.charAt(p.pos()) { + switch p.char() { case '=', '!': p.incPos(1) isPreviousTermQuantifiable = false @@ -219,7 +226,7 @@ func (p *regExpParser) scanAlternative(isInGroup bool) { default: flagsStart := p.pos() setFlags := p.scanPatternModifiers(regularExpressionFlagsNone) - if p.charAt(p.pos()) == '-' { + if p.char() == '-' { p.incPos(1) p.scanPatternModifiers(setFlags) if p.pos() == flagsStart+1 { @@ -244,12 +251,12 @@ func (p *regExpParser) scanAlternative(isInGroup bool) { isPreviousTermQuantifiable = true continue } - if p.charAt(p.pos()) == ',' { + if p.char() == ',' { p.incPos(1) p.scanDigits() maxStr := p.scanner.tokenValue if minStr == "" { - if maxStr != "" || p.charAt(p.pos()) == '}' { + if maxStr != "" || p.char() == '}' { p.error(diagnostics.Incomplete_quantifier_Digit_expected, digitsStart, 0) } else { p.error(diagnostics.Unexpected_0_Did_you_mean_to_escape_it_with_backslash, start, 1, string(ch)) @@ -259,7 +266,7 @@ func (p *regExpParser) scanAlternative(isInGroup bool) { } else if maxStr != "" { minVal, _ := strconv.Atoi(minStr) maxVal, _ := strconv.Atoi(maxStr) - if minVal > maxVal && (p.anyUnicodeModeOrNonAnnexB || p.charAt(p.pos()) == '}') { + if minVal > maxVal && (p.anyUnicodeModeOrNonAnnexB || p.char() == '}') { p.error(diagnostics.Numbers_out_of_order_in_quantifier, digitsStart, p.pos()-digitsStart) } } @@ -270,7 +277,7 @@ func (p *regExpParser) scanAlternative(isInGroup bool) { isPreviousTermQuantifiable = true continue } - if p.charAt(p.pos()) != '}' { + if p.char() != '}' { if p.anyUnicodeModeOrNonAnnexB { p.error(diagnostics.X_0_expected, p.pos(), 0, "}") p.incPos(-1) @@ -283,7 +290,7 @@ func (p *regExpParser) scanAlternative(isInGroup bool) { fallthrough case '*', '+', '?': p.incPos(1) - if p.charAt(p.pos()) == '?' { + if p.char() == '?' { p.incPos(1) } if !isPreviousTermQuantifiable { @@ -352,10 +359,10 @@ func (p *regExpParser) scanPatternModifiers(currFlags regularExpressionFlags) re // | CharacterEscape // | 'k<' RegExpIdentifierName '>' func (p *regExpParser) scanAtomEscape() { - switch p.charAt(p.pos()) { + switch p.char() { case 'k': p.incPos(1) - if p.charAt(p.pos()) == '<' { + if p.char() == '<' { p.incPos(1) p.scanGroupName(true /*isReference*/) p.scanExpectedChar('>') @@ -378,7 +385,7 @@ func (p *regExpParser) scanAtomEscape() { // DecimalEscape ::= [1-9] [0-9]* func (p *regExpParser) scanDecimalEscape() bool { - ch := p.charAt(p.pos()) + ch := p.char() if ch >= '1' && ch <= '9' { start := p.pos() p.scanDigits() @@ -400,14 +407,14 @@ func (p *regExpParser) scanDecimalEscape() bool { // | '^' | '$' | '/' | '\' | '.' | '*' | '+' | '?' | '(' | ')' | '[' | ']' | '{' | '}' | '|' // | [~AnyUnicodeMode] (any other non-identifier characters) func (p *regExpParser) scanCharacterEscape(atomEscape bool) string { - ch := p.charAt(p.pos()) + ch := p.char() switch ch { case -1: p.error(diagnostics.Undetermined_character_escape, p.pos()-1, 1) return "\\" case 'c': p.incPos(1) - ch = p.charAt(p.pos()) + ch = p.char() if stringutil.IsASCIILetter(ch) { p.incPos(1) return string(ch & 0x1f) @@ -471,19 +478,19 @@ func (p *regExpParser) isClassContentExit(ch rune) bool { // ClassRanges ::= '^'? (ClassAtom ('-' ClassAtom)?)* func (p *regExpParser) scanClassRanges() { p.pendingLowSurrogate = 0 - if p.charAt(p.pos()) == '^' { + if p.char() == '^' { p.incPos(1) } for p.pos() < p.end { - ch := p.charAt(p.pos()) + ch := p.char() if p.isClassContentExit(ch) { return } minStart := p.pos() minCharacter := p.scanClassAtom() - if p.charAt(p.pos()) == '-' { + if p.char() == '-' { p.incPos(1) - ch = p.charAt(p.pos()) + ch = p.char() if p.isClassContentExit(ch) { return } @@ -515,12 +522,12 @@ func (p *regExpParser) scanClassRanges() { // ClassSetRange ::= ClassSetCharacter '-' ClassSetCharacter func (p *regExpParser) scanClassSetExpression() { isCharacterComplement := false - if p.charAt(p.pos()) == '^' { + if p.char() == '^' { p.incPos(1) isCharacterComplement = true } expressionMayContainStrings := false - ch := p.charAt(p.pos()) + ch := p.char() if p.isClassContentExit(ch) { return } @@ -537,7 +544,7 @@ func (p *regExpParser) scanClassSetExpression() { default: operand = p.scanClassSetOperand() } - switch p.charAt(p.pos()) { + switch p.char() { case '-': if p.pos()+1 < p.end && p.charAt(p.pos()+1) == '-' { if isCharacterComplement && p.mayContainStrings { @@ -567,11 +574,11 @@ func (p *regExpParser) scanClassSetExpression() { expressionMayContainStrings = p.mayContainStrings } for p.pos() < p.end { - ch = p.charAt(p.pos()) + ch = p.char() switch ch { case '-': p.incPos(1) - ch = p.charAt(p.pos()) + ch = p.char() if p.isClassContentExit(ch) { p.mayContainStrings = !isCharacterComplement && expressionMayContainStrings return @@ -605,10 +612,10 @@ func (p *regExpParser) scanClassSetExpression() { case '&': start = p.pos() p.incPos(1) - if p.charAt(p.pos()) == '&' { + if p.char() == '&' { p.incPos(1) p.error(diagnostics.Operators_must_not_be_mixed_within_a_character_class_Wrap_it_in_a_nested_class_instead, p.pos()-2, 2) - if p.charAt(p.pos()) == '&' { + if p.char() == '&' { p.error(diagnostics.Unexpected_0_Did_you_mean_to_escape_it_with_backslash, p.pos(), 1, string(ch)) p.incPos(1) } @@ -618,7 +625,7 @@ func (p *regExpParser) scanClassSetExpression() { operand = p.text()[start:p.pos()] continue } - if p.isClassContentExit(p.charAt(p.pos())) { + if p.isClassContentExit(p.char()) { break } start = p.pos() @@ -641,14 +648,14 @@ func (p *regExpParser) scanClassSetExpression() { func (p *regExpParser) scanClassSetSubExpression(expressionType classSetExpressionType) { expressionMayContainStrings := p.mayContainStrings for p.pos() < p.end { - ch := p.charAt(p.pos()) + ch := p.char() if p.isClassContentExit(ch) { break } switch ch { case '-': p.incPos(1) - if p.charAt(p.pos()) == '-' { + if p.char() == '-' { p.incPos(1) if expressionType != classSetExpressionTypeClassSubtraction { p.error(diagnostics.Operators_must_not_be_mixed_within_a_character_class_Wrap_it_in_a_nested_class_instead, p.pos()-2, 2) @@ -658,12 +665,12 @@ func (p *regExpParser) scanClassSetSubExpression(expressionType classSetExpressi } case '&': p.incPos(1) - if p.charAt(p.pos()) == '&' { + if p.char() == '&' { p.incPos(1) if expressionType != classSetExpressionTypeClassIntersection { p.error(diagnostics.Operators_must_not_be_mixed_within_a_character_class_Wrap_it_in_a_nested_class_instead, p.pos()-2, 2) } - if p.charAt(p.pos()) == '&' { + if p.char() == '&' { p.error(diagnostics.Unexpected_0_Did_you_mean_to_escape_it_with_backslash, p.pos(), 1, string(ch)) p.incPos(1) } @@ -678,7 +685,7 @@ func (p *regExpParser) scanClassSetSubExpression(expressionType classSetExpressi p.error(diagnostics.X_0_expected, p.pos(), 0, "&&") } } - ch = p.charAt(p.pos()) + ch = p.char() if p.isClassContentExit(ch) { p.error(diagnostics.Expected_a_class_set_operand, p.pos(), 0) break @@ -699,7 +706,7 @@ func (p *regExpParser) scanClassSetSubExpression(expressionType classSetExpressi // | ClassSetCharacter func (p *regExpParser) scanClassSetOperand() string { p.mayContainStrings = false - switch p.charAt(p.pos()) { + switch p.char() { case '[': p.incPos(1) p.scanClassSetExpression() @@ -709,9 +716,9 @@ func (p *regExpParser) scanClassSetOperand() string { p.incPos(1) if p.scanCharacterClassEscape() { return "" - } else if p.charAt(p.pos()) == 'q' { + } else if p.char() == 'q' { p.incPos(1) - if p.charAt(p.pos()) == '{' { + if p.char() == '{' { p.incPos(1) p.scanClassStringDisjunctionContents() p.scanExpectedChar('}') @@ -732,7 +739,7 @@ func (p *regExpParser) scanClassSetOperand() string { func (p *regExpParser) scanClassStringDisjunctionContents() { characterCount := 0 for p.pos() < p.end { - ch := p.charAt(p.pos()) + ch := p.char() switch ch { case '}': if characterCount != 1 { @@ -757,10 +764,10 @@ func (p *regExpParser) scanClassStringDisjunctionContents() { // | SourceCharacter -- ClassSetSyntaxCharacter -- ClassSetReservedDoublePunctuator // | '\' (CharacterEscape | ClassSetReservedPunctuator | 'b') func (p *regExpParser) scanClassSetCharacter() string { - ch := p.charAt(p.pos()) + ch := p.char() if ch == '\\' { p.incPos(1) - innerCh := p.charAt(p.pos()) + innerCh := p.char() switch innerCh { case 'b': p.incPos(1) @@ -800,9 +807,9 @@ func (p *regExpParser) scanClassSetCharacter() string { // | CharacterClassEscape // | CharacterEscape func (p *regExpParser) scanClassAtom() string { - if p.charAt(p.pos()) == '\\' { + if p.char() == '\\' { p.incPos(1) - ch := p.charAt(p.pos()) + ch := p.char() switch ch { case 'b': p.incPos(1) @@ -828,7 +835,7 @@ func (p *regExpParser) scanClassAtom() string { func (p *regExpParser) scanCharacterClassEscape() bool { isCharacterComplement := false start := p.pos() - 1 - ch := p.charAt(p.pos()) + ch := p.char() switch ch { case 'd', 'D', 's', 'S', 'w', 'W': p.incPos(1) @@ -838,11 +845,11 @@ func (p *regExpParser) scanCharacterClassEscape() bool { fallthrough case 'p': p.incPos(1) - if p.charAt(p.pos()) == '{' { + if p.char() == '{' { p.incPos(1) propertyNameOrValueStart := p.pos() propertyNameOrValue := p.scanWordCharacters() - if p.charAt(p.pos()) == '=' { + if p.char() == '=' { propertyName := nonBinaryUnicodeProperties[propertyNameOrValue] if p.pos() == propertyNameOrValueStart { p.error(diagnostics.Expected_a_Unicode_property_name, p.pos(), 0) @@ -939,7 +946,7 @@ func (p *regExpParser) getSpellingSuggestionForUnicodePropertyNameOrValue(name s func (p *regExpParser) scanWordCharacters() string { start := p.pos() for p.pos() < p.end { - ch := p.charAt(p.pos()) + ch := p.char() if !isWordCharacter(ch) { break } @@ -988,7 +995,7 @@ func (p *regExpParser) scanSourceCharacter() string { } func (p *regExpParser) scanExpectedChar(ch rune) { - if p.charAt(p.pos()) == ch { + if p.char() == ch { p.incPos(1) } else { p.error(diagnostics.X_0_expected, p.pos(), 0, string(ch)) @@ -997,7 +1004,7 @@ func (p *regExpParser) scanExpectedChar(ch rune) { func (p *regExpParser) scanDigits() { start := p.pos() - for p.pos() < p.end && stringutil.IsDigit(p.charAt(p.pos())) { + for p.pos() < p.end && stringutil.IsDigit(p.char()) { p.incPos(1) } p.scanner.tokenValue = p.text()[start:p.pos()] From 6847b559f771c76b03ac7b1b3982db6bb5e43cfa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Burzy=C5=84ski?= Date: Fri, 13 Mar 2026 17:23:57 +0100 Subject: [PATCH 33/43] passthrough those helpers --- internal/scanner/regexp.go | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/internal/scanner/regexp.go b/internal/scanner/regexp.go index 329fbd899bf..789ad5a8e57 100644 --- a/internal/scanner/regexp.go +++ b/internal/scanner/regexp.go @@ -107,17 +107,11 @@ func (p *regExpParser) incPos(n int) { } func (p *regExpParser) char() rune { - if p.pos() < p.end { - return rune(p.scanner.text[p.pos()]) - } - return -1 + return p.scanner.char() } func (p *regExpParser) charAt(pos int) rune { - if pos < p.end { - return rune(p.scanner.text[pos]) - } - return -1 + return p.scanner.charAt(pos - p.pos()) } func (p *regExpParser) error(msg *diagnostics.Message, pos int, length int, args ...any) { From 01b37de36b12cd1962051fb7b800571e6c2b2f93 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Burzy=C5=84ski?= Date: Sat, 14 Mar 2026 08:54:31 +0100 Subject: [PATCH 34/43] bounds improvement --- internal/scanner/regexp.go | 22 ++++++++++++--- ...ularExpressionQuantifierBounds1.errors.txt | 18 +++++++++++++ .../regularExpressionQuantifierBounds1.js | 23 ++++++++++++++++ ...regularExpressionQuantifierBounds1.symbols | 15 +++++++++++ .../regularExpressionQuantifierBounds1.types | 27 +++++++++++++++++++ .../regularExpressionQuantifierBounds1.ts | 11 ++++++++ 6 files changed, 113 insertions(+), 3 deletions(-) create mode 100644 testdata/baselines/reference/compiler/regularExpressionQuantifierBounds1.errors.txt create mode 100644 testdata/baselines/reference/compiler/regularExpressionQuantifierBounds1.js create mode 100644 testdata/baselines/reference/compiler/regularExpressionQuantifierBounds1.symbols create mode 100644 testdata/baselines/reference/compiler/regularExpressionQuantifierBounds1.types create mode 100644 testdata/tests/cases/compiler/regularExpressionQuantifierBounds1.ts diff --git a/internal/scanner/regexp.go b/internal/scanner/regexp.go index 789ad5a8e57..c979fec4c23 100644 --- a/internal/scanner/regexp.go +++ b/internal/scanner/regexp.go @@ -122,6 +122,24 @@ func (p *regExpParser) text() string { return p.scanner.text } +func compareDecimalStrings(a string, b string) int { + a = strings.TrimLeft(a, "0") + b = strings.TrimLeft(b, "0") + if a == "" { + a = "0" + } + if b == "" { + b = "0" + } + if len(a) != len(b) { + if len(a) < len(b) { + return -1 + } + return 1 + } + return strings.Compare(a, b) +} + // Disjunction ::= Alternative ('|' Alternative)* func (p *regExpParser) scanDisjunction(isInGroup bool) { for { @@ -258,9 +276,7 @@ func (p *regExpParser) scanAlternative(isInGroup bool) { continue } } else if maxStr != "" { - minVal, _ := strconv.Atoi(minStr) - maxVal, _ := strconv.Atoi(maxStr) - if minVal > maxVal && (p.anyUnicodeModeOrNonAnnexB || p.char() == '}') { + if compareDecimalStrings(minStr, maxStr) > 0 && (p.anyUnicodeModeOrNonAnnexB || p.char() == '}') { p.error(diagnostics.Numbers_out_of_order_in_quantifier, digitsStart, p.pos()-digitsStart) } } diff --git a/testdata/baselines/reference/compiler/regularExpressionQuantifierBounds1.errors.txt b/testdata/baselines/reference/compiler/regularExpressionQuantifierBounds1.errors.txt new file mode 100644 index 00000000000..223ac13c6d5 --- /dev/null +++ b/testdata/baselines/reference/compiler/regularExpressionQuantifierBounds1.errors.txt @@ -0,0 +1,18 @@ +regularExpressionQuantifierBounds1.ts(4,5): error TS1506: Numbers out of order in quantifier. +regularExpressionQuantifierBounds1.ts(5,5): error TS1506: Numbers out of order in quantifier. + + +==== regularExpressionQuantifierBounds1.ts (2 errors) ==== + const regexes: RegExp[] = [ + /a{7,8}/, + /a{9223372036854775807,9223372036854775808}/, + /a{8,7}/, + ~~~ +!!! error TS1506: Numbers out of order in quantifier. + /a{9223372036854775808,9223372036854775807}/, + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +!!! error TS1506: Numbers out of order in quantifier. + /a{8,8}/, + /a{9223372036854775808,9223372036854775808}/, + ]; + \ No newline at end of file diff --git a/testdata/baselines/reference/compiler/regularExpressionQuantifierBounds1.js b/testdata/baselines/reference/compiler/regularExpressionQuantifierBounds1.js new file mode 100644 index 00000000000..a569206a3d9 --- /dev/null +++ b/testdata/baselines/reference/compiler/regularExpressionQuantifierBounds1.js @@ -0,0 +1,23 @@ +//// [tests/cases/compiler/regularExpressionQuantifierBounds1.ts] //// + +//// [regularExpressionQuantifierBounds1.ts] +const regexes: RegExp[] = [ + /a{7,8}/, + /a{9223372036854775807,9223372036854775808}/, + /a{8,7}/, + /a{9223372036854775808,9223372036854775807}/, + /a{8,8}/, + /a{9223372036854775808,9223372036854775808}/, +]; + + +//// [regularExpressionQuantifierBounds1.js] +"use strict"; +const regexes = [ + /a{7,8}/, + /a{9223372036854775807,9223372036854775808}/, + /a{8,7}/, + /a{9223372036854775808,9223372036854775807}/, + /a{8,8}/, + /a{9223372036854775808,9223372036854775808}/, +]; diff --git a/testdata/baselines/reference/compiler/regularExpressionQuantifierBounds1.symbols b/testdata/baselines/reference/compiler/regularExpressionQuantifierBounds1.symbols new file mode 100644 index 00000000000..441ebd635f4 --- /dev/null +++ b/testdata/baselines/reference/compiler/regularExpressionQuantifierBounds1.symbols @@ -0,0 +1,15 @@ +//// [tests/cases/compiler/regularExpressionQuantifierBounds1.ts] //// + +=== regularExpressionQuantifierBounds1.ts === +const regexes: RegExp[] = [ +>regexes : Symbol(regexes, Decl(regularExpressionQuantifierBounds1.ts, 0, 5)) +>RegExp : Symbol(RegExp, Decl(lib.es5.d.ts, --, --), Decl(lib.es5.d.ts, --, --), Decl(lib.es2015.core.d.ts, --, --), Decl(lib.es2015.symbol.wellknown.d.ts, --, --), Decl(lib.es2018.regexp.d.ts, --, --) ... and 3 more) + + /a{7,8}/, + /a{9223372036854775807,9223372036854775808}/, + /a{8,7}/, + /a{9223372036854775808,9223372036854775807}/, + /a{8,8}/, + /a{9223372036854775808,9223372036854775808}/, +]; + diff --git a/testdata/baselines/reference/compiler/regularExpressionQuantifierBounds1.types b/testdata/baselines/reference/compiler/regularExpressionQuantifierBounds1.types new file mode 100644 index 00000000000..5c732f6653c --- /dev/null +++ b/testdata/baselines/reference/compiler/regularExpressionQuantifierBounds1.types @@ -0,0 +1,27 @@ +//// [tests/cases/compiler/regularExpressionQuantifierBounds1.ts] //// + +=== regularExpressionQuantifierBounds1.ts === +const regexes: RegExp[] = [ +>regexes : RegExp[] +>[ /a{7,8}/, /a{9223372036854775807,9223372036854775808}/, /a{8,7}/, /a{9223372036854775808,9223372036854775807}/, /a{8,8}/, /a{9223372036854775808,9223372036854775808}/,] : RegExp[] + + /a{7,8}/, +>/a{7,8}/ : RegExp + + /a{9223372036854775807,9223372036854775808}/, +>/a{9223372036854775807,9223372036854775808}/ : RegExp + + /a{8,7}/, +>/a{8,7}/ : RegExp + + /a{9223372036854775808,9223372036854775807}/, +>/a{9223372036854775808,9223372036854775807}/ : RegExp + + /a{8,8}/, +>/a{8,8}/ : RegExp + + /a{9223372036854775808,9223372036854775808}/, +>/a{9223372036854775808,9223372036854775808}/ : RegExp + +]; + diff --git a/testdata/tests/cases/compiler/regularExpressionQuantifierBounds1.ts b/testdata/tests/cases/compiler/regularExpressionQuantifierBounds1.ts new file mode 100644 index 00000000000..84792247ee9 --- /dev/null +++ b/testdata/tests/cases/compiler/regularExpressionQuantifierBounds1.ts @@ -0,0 +1,11 @@ +// @strict: true +// @target: esnext + +const regexes: RegExp[] = [ + /a{7,8}/, + /a{9223372036854775807,9223372036854775808}/, + /a{8,7}/, + /a{9223372036854775808,9223372036854775807}/, + /a{8,8}/, + /a{9223372036854775808,9223372036854775808}/, +]; From 702e8a2b7b74dee8004766f7d0204ab7fa2b8b7b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Burzy=C5=84ski?= Date: Mon, 16 Mar 2026 13:54:26 +0100 Subject: [PATCH 35/43] remove redundant comment --- internal/scanner/regexp.go | 1 - 1 file changed, 1 deletion(-) diff --git a/internal/scanner/regexp.go b/internal/scanner/regexp.go index c979fec4c23..8fb072b81a6 100644 --- a/internal/scanner/regexp.go +++ b/internal/scanner/regexp.go @@ -296,7 +296,6 @@ func (p *regExpParser) scanAlternative(isInGroup bool) { continue } } - // falls through to quantifier handling fallthrough case '*', '+', '?': p.incPos(1) From cfcdb99678172d714fdd3ad59a2cd520a309402c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Burzy=C5=84ski?= Date: Mon, 16 Mar 2026 13:55:35 +0100 Subject: [PATCH 36/43] bring back lost comment --- internal/scanner/regexp.go | 1 + 1 file changed, 1 insertion(+) diff --git a/internal/scanner/regexp.go b/internal/scanner/regexp.go index 8fb072b81a6..c5cfad9c280 100644 --- a/internal/scanner/regexp.go +++ b/internal/scanner/regexp.go @@ -300,6 +300,7 @@ func (p *regExpParser) scanAlternative(isInGroup bool) { case '*', '+', '?': p.incPos(1) if p.char() == '?' { + // Non-greedy p.incPos(1) } if !isPreviousTermQuantifiable { From 8fee12e55da6edd4c86d1646dd4fdcffea53548c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Burzy=C5=84ski?= Date: Mon, 16 Mar 2026 14:07:11 +0100 Subject: [PATCH 37/43] add missing asserts --- internal/scanner/regexp.go | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/internal/scanner/regexp.go b/internal/scanner/regexp.go index c5cfad9c280..32eede2dc94 100644 --- a/internal/scanner/regexp.go +++ b/internal/scanner/regexp.go @@ -6,6 +6,7 @@ import ( "unicode/utf8" "github.com/microsoft/typescript-go/internal/core" + "github.com/microsoft/typescript-go/internal/debug" "github.com/microsoft/typescript-go/internal/diagnostics" "github.com/microsoft/typescript-go/internal/stringutil" ) @@ -369,6 +370,7 @@ func (p *regExpParser) scanPatternModifiers(currFlags regularExpressionFlags) re // | CharacterEscape // | 'k<' RegExpIdentifierName '>' func (p *regExpParser) scanAtomEscape() { + debug.Assert(p.pos() > 0 && p.text()[p.pos()-1] == '\\') switch p.char() { case 'k': p.incPos(1) @@ -388,13 +390,15 @@ func (p *regExpParser) scanAtomEscape() { fallthrough default: if !p.scanCharacterClassEscape() && !p.scanDecimalEscape() { - p.scanCharacterEscape(true /*atomEscape*/) + // Regex literals cannot contain line breaks here, so a character escape must consume something. + debug.Assert(p.scanCharacterEscape(true /*atomEscape*/) != "") } } } // DecimalEscape ::= [1-9] [0-9]* func (p *regExpParser) scanDecimalEscape() bool { + debug.Assert(p.pos() > 0 && p.text()[p.pos()-1] == '\\') ch := p.char() if ch >= '1' && ch <= '9' { start := p.pos() @@ -417,6 +421,7 @@ func (p *regExpParser) scanDecimalEscape() bool { // | '^' | '$' | '/' | '\' | '.' | '*' | '+' | '?' | '(' | ')' | '[' | ']' | '{' | '}' | '|' // | [~AnyUnicodeMode] (any other non-identifier characters) func (p *regExpParser) scanCharacterEscape(atomEscape bool) string { + debug.Assert(p.pos() > 0 && p.text()[p.pos()-1] == '\\') ch := p.char() switch ch { case -1: @@ -456,6 +461,7 @@ func (p *regExpParser) scanCharacterEscape(atomEscape bool) string { } func (p *regExpParser) scanGroupName(isReference bool) { + debug.Assert(p.pos() > 0 && p.text()[p.pos()-1] == '<') p.scanner.tokenStart = p.pos() p.scanner.scanIdentifier(0) if p.pos() == p.scanner.tokenStart { @@ -487,6 +493,7 @@ func (p *regExpParser) isClassContentExit(ch rune) bool { // ClassRanges ::= '^'? (ClassAtom ('-' ClassAtom)?)* func (p *regExpParser) scanClassRanges() { + debug.Assert(p.pos() > 0 && p.text()[p.pos()-1] == '[') p.pendingLowSurrogate = 0 if p.char() == '^' { p.incPos(1) @@ -531,6 +538,7 @@ func (p *regExpParser) scanClassRanges() { // ClassSubtraction ::= ClassSetOperand ('--' ClassSetOperand)+ // ClassSetRange ::= ClassSetCharacter '-' ClassSetCharacter func (p *regExpParser) scanClassSetExpression() { + debug.Assert(p.pos() > 0 && p.text()[p.pos()-1] == '[') isCharacterComplement := false if p.char() == '^' { p.incPos(1) @@ -747,6 +755,7 @@ func (p *regExpParser) scanClassSetOperand() string { // ClassStringDisjunctionContents ::= ClassSetCharacter* ('|' ClassSetCharacter*)* func (p *regExpParser) scanClassStringDisjunctionContents() { + debug.Assert(p.pos() > 0 && p.text()[p.pos()-1] == '{') characterCount := 0 for p.pos() < p.end { ch := p.char() @@ -843,6 +852,7 @@ func (p *regExpParser) scanClassAtom() string { // | 'd' | 'D' | 's' | 'S' | 'w' | 'W' // | [+AnyUnicodeMode] ('P' | 'p') '{' UnicodePropertyValueExpression '}' func (p *regExpParser) scanCharacterClassEscape() bool { + debug.Assert(p.pos() > 0 && p.text()[p.pos()-1] == '\\') isCharacterComplement := false start := p.pos() - 1 ch := p.char() From b2e2b0788f3456e744c3537df3c36fb0f25fe7f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Burzy=C5=84ski?= Date: Mon, 16 Mar 2026 14:21:44 +0100 Subject: [PATCH 38/43] handle atoi error --- internal/scanner/regexp.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/internal/scanner/regexp.go b/internal/scanner/regexp.go index 32eede2dc94..96cd88e98c9 100644 --- a/internal/scanner/regexp.go +++ b/internal/scanner/regexp.go @@ -1,6 +1,7 @@ package scanner import ( + "math" "strconv" "strings" "unicode/utf8" @@ -403,7 +404,10 @@ func (p *regExpParser) scanDecimalEscape() bool { if ch >= '1' && ch <= '9' { start := p.pos() p.scanDigits() - val, _ := strconv.Atoi(p.scanner.tokenValue) + val, err := strconv.Atoi(p.scanner.tokenValue) + if err != nil { + val = math.MaxInt + } p.decimalEscapes = append(p.decimalEscapes, decimalEscapeValue{pos: start, end: p.pos(), value: val}) return true } From c65c53de13f7793966af3d22d27de7e056db29c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Burzy=C5=84ski?= Date: Mon, 16 Mar 2026 14:36:41 +0100 Subject: [PATCH 39/43] improve comment --- internal/scanner/regexp.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/internal/scanner/regexp.go b/internal/scanner/regexp.go index 96cd88e98c9..6f914bbb771 100644 --- a/internal/scanner/regexp.go +++ b/internal/scanner/regexp.go @@ -91,8 +91,9 @@ type regExpParser struct { namedCapturingGroups []map[string]bool // pendingLowSurrogate holds the low surrogate to emit on the next - // scanSourceCharacter call when a non-BMP character is split into two - // surrogate code units in non-unicode mode. + // scanSourceCharacter call when Corsa has to split a non-BMP rune into + // UTF-16 surrogate code units in non-unicode mode. Strada did not need + // this bookkeeping because its source text was already indexed as UTF-16. pendingLowSurrogate rune } From b4ff2e2a5598879d75241437ec1c0420147f028f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Burzy=C5=84ski?= Date: Mon, 16 Mar 2026 14:42:06 +0100 Subject: [PATCH 40/43] use charAt properly --- internal/scanner/regexp.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/scanner/regexp.go b/internal/scanner/regexp.go index 6f914bbb771..b5098253eb7 100644 --- a/internal/scanner/regexp.go +++ b/internal/scanner/regexp.go @@ -802,7 +802,7 @@ func (p *regExpParser) scanClassSetCharacter() string { default: return p.scanCharacterEscape(false /*atomEscape*/) } - } else if p.pos()+1 < p.end && ch == rune(p.scanner.text[p.pos()+1]) { + } else if p.pos()+1 < p.end && ch == p.charAt(p.pos()+1) { switch ch { case '&', '!', '#', '%', '*', '+', ',', '.', ':', ';', '<', '=', '>', '?', '@', '`', '~': p.error(diagnostics.A_character_class_must_not_contain_a_reserved_double_punctuator_Did_you_mean_to_escape_it_with_backslash, p.pos(), 2) From 6208841c845ce7727fc1765a4bd81ea49f1e656d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Burzy=C5=84ski?= Date: Mon, 16 Mar 2026 14:51:29 +0100 Subject: [PATCH 41/43] readd some comments --- internal/checker/grammarchecks.go | 1 + internal/scanner/regexp.go | 26 +++++++++++++++++++++----- internal/scanner/unicodeproperties.go | 6 +++++- 3 files changed, 27 insertions(+), 6 deletions(-) diff --git a/internal/checker/grammarchecks.go b/internal/checker/grammarchecks.go index a5e749612df..12a5f8b7fec 100644 --- a/internal/checker/grammarchecks.go +++ b/internal/checker/grammarchecks.go @@ -65,6 +65,7 @@ func (c *Checker) checkGrammarRegularExpressionLiteral(node *ast.RegularExpressi c.regExpScanner.SetLanguageVariant(sourceFile.LanguageVariant) c.regExpScanner.SetOnError(func(message *diagnostics.Message, start int, length int, args ...any) { if message.Category() == diagnostics.CategoryMessage && lastError != nil && start == lastError.Pos() && length == lastError.Len() { + // For providing spelling suggestions. err := ast.NewDiagnostic(nil, core.NewTextRange(start, start+length), message, args...) lastError.AddRelatedInfo(err) } else if lastError == nil || start != lastError.Pos() { diff --git a/internal/scanner/regexp.go b/internal/scanner/regexp.go index b5098253eb7..5f42804a09f 100644 --- a/internal/scanner/regexp.go +++ b/internal/scanner/regexp.go @@ -83,12 +83,18 @@ type regExpParser struct { anyUnicodeModeOrNonAnnexB bool namedCaptureGroups bool - mayContainStrings bool + // See scanClassSetExpression. + mayContainStrings bool + // The number of all (named and unnamed) capturing groups defined in the regex. numberOfCapturingGroups int - groupSpecifiers map[string]bool - groupNameReferences []groupNameReference - decimalEscapes []decimalEscapeValue - namedCapturingGroups []map[string]bool + // All named capturing groups defined in the regex. + groupSpecifiers map[string]bool + // All references to named capturing groups in the regex. + groupNameReferences []groupNameReference + // All numeric backreferences within the regex. + decimalEscapes []decimalEscapeValue + // A stack of scopes for named capturing groups. See scanGroupName. + namedCapturingGroups []map[string]bool // pendingLowSurrogate holds the low surrogate to emit on the next // scanSourceCharacter call when Corsa has to split a non-BMP rune into @@ -537,6 +543,16 @@ func (p *regExpParser) scanClassRanges() { } } +// Static Semantics: MayContainStrings +// ClassUnion: ClassSetOperands.some(ClassSetOperand => ClassSetOperand.MayContainStrings) +// ClassIntersection: ClassSetOperands.every(ClassSetOperand => ClassSetOperand.MayContainStrings) +// ClassSubtraction: ClassSetOperands[0].MayContainStrings +// ClassSetOperand: +// || ClassStringDisjunctionContents.MayContainStrings +// || CharacterClassEscape.UnicodePropertyValueExpression.LoneUnicodePropertyNameOrValue.MayContainStrings +// ClassStringDisjunctionContents: ClassStrings.some(ClassString => ClassString.ClassSetCharacters.length !== 1) +// LoneUnicodePropertyNameOrValue: isBinaryUnicodePropertyOfStrings(LoneUnicodePropertyNameOrValue) + // ClassSetExpression ::= '^'? (ClassUnion | ClassIntersection | ClassSubtraction) // ClassUnion ::= (ClassSetRange | ClassSetOperand)* // ClassIntersection ::= ClassSetOperand ('&&' ClassSetOperand)+ diff --git a/internal/scanner/unicodeproperties.go b/internal/scanner/unicodeproperties.go index e34fc0fd3f9..83d1e0e847c 100644 --- a/internal/scanner/unicodeproperties.go +++ b/internal/scanner/unicodeproperties.go @@ -153,6 +153,10 @@ var valuesOfNonBinaryUnicodeProperties = map[string]*collections.Set[string]{ "Z", "Separator", "Zl", "Line_Separator", "Zp", "Paragraph_Separator", "Zs", "Space_Separator", ), - "Script": scriptValues, + "Script": scriptValues, + // The Script_Extensions property of a character contains one or more Script values. + // See https://www.unicode.org/reports/tr24/#Script_Extensions + // Here, since each Unicode property value expression only allows a single value, + // its values can be considered the same as those of the Script property. "Script_Extensions": scriptValues, } From 97e002b909a6f5a7abd77b3cb6ad1bb09a5512a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Burzy=C5=84ski?= Date: Mon, 16 Mar 2026 18:48:47 +0100 Subject: [PATCH 42/43] tweak --- internal/scanner/scanner.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/scanner/scanner.go b/internal/scanner/scanner.go index e93eb4ccd31..f732dc382e7 100644 --- a/internal/scanner/scanner.go +++ b/internal/scanner/scanner.go @@ -1704,7 +1704,7 @@ func (s *Scanner) scanEscapeSequence(flags EscapeSequenceScanningFlags) string { if flags&EscapeSequenceScanningFlagsReportInvalidEscapeErrors != 0 { code, _ := strconv.ParseInt(s.text[start+1:s.pos], 8, 32) if flags&EscapeSequenceScanningFlagsRegularExpression != 0 && flags&EscapeSequenceScanningFlagsAtomEscape == 0 && ch != '0' { - s.errorAt(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, s.pos-start, "\\x"+fmt.Sprintf("%02x", code)) + s.errorAt(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, s.pos-start, fmt.Sprintf("\\x%02x", code)) } else { s.errorAt(diagnostics.Octal_escape_sequences_are_not_allowed_Use_the_syntax_0, start, s.pos-start, "\\x"+fmt.Sprintf("%02x", code)) } From 96e9c9cc7e9d27f2d74d0a7d5ca3ea487dc8ee5c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Burzy=C5=84ski?= Date: Mon, 16 Mar 2026 19:00:06 +0100 Subject: [PATCH 43/43] tweak --- internal/scanner/scanner.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/internal/scanner/scanner.go b/internal/scanner/scanner.go index f732dc382e7..3c27fcd5571 100644 --- a/internal/scanner/scanner.go +++ b/internal/scanner/scanner.go @@ -1706,7 +1706,7 @@ func (s *Scanner) scanEscapeSequence(flags EscapeSequenceScanningFlags) string { if flags&EscapeSequenceScanningFlagsRegularExpression != 0 && flags&EscapeSequenceScanningFlagsAtomEscape == 0 && ch != '0' { s.errorAt(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, s.pos-start, fmt.Sprintf("\\x%02x", code)) } else { - s.errorAt(diagnostics.Octal_escape_sequences_are_not_allowed_Use_the_syntax_0, start, s.pos-start, "\\x"+fmt.Sprintf("%02x", code)) + s.errorAt(diagnostics.Octal_escape_sequences_are_not_allowed_Use_the_syntax_0, start, s.pos-start, fmt.Sprintf("\\x%02x", code)) } return string(rune(code)) }