Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
6f4fc7a
Port "Provide Syntax Checking for Regular Expressions"
Andarist Feb 21, 2026
a37d964
Port "Improve Recovery of Unterminated Regular Expressions"
Andarist Feb 22, 2026
fa64311
Port "Move RegExp flag version mapping to LanguageFeatureMinimumTarget"
Andarist Feb 22, 2026
0499a15
Port "Report RegExp errors in grammar check, use Annex B grammar"
Andarist Feb 23, 2026
c091575
Port "Correct Regular Expressions Behavior Related to Annex B"
Andarist Feb 23, 2026
f548c2b
Port "Provide Spelling Suggestions for Named Capture Group References…
Andarist Feb 23, 2026
f1b8944
Port "Correct regular expression flags scanning for non-BMP characters"
Andarist Feb 23, 2026
af449ae
fix stuff
Andarist Feb 23, 2026
df6003a
fix stuff
Andarist Feb 23, 2026
1f36b00
fix a thing
Andarist Feb 23, 2026
2593323
fix stuff
Andarist Feb 23, 2026
27c3597
fix stuff
Andarist Feb 23, 2026
b9e8ad0
fix stuff
Andarist Feb 23, 2026
0dd18b2
fixup indent
Andarist Mar 10, 2026
8de6161
fix subrange scanning
Andarist Mar 10, 2026
a3f863a
add missing case to `scanSourceCharacter`
Andarist Mar 10, 2026
b351d4a
fix thing
Andarist Mar 10, 2026
db421f4
remove GetNameOfScriptTarget
Andarist Mar 10, 2026
f3d4cef
switch it back
Andarist Mar 10, 2026
dba4669
bring back comment
Andarist Mar 10, 2026
00ca1e6
restore comment
Andarist Mar 10, 2026
8dd5ac5
fix regExpFlagToFirstAvailableLanguageVersion
Andarist Mar 10, 2026
e2b7255
update surrogate handling
Andarist Mar 10, 2026
6998167
accept changes
Andarist Mar 11, 2026
a2a0756
accept again ?
Andarist Mar 11, 2026
a6e25ad
fix lints
Andarist Mar 11, 2026
9c5ab8d
Merge remote-tracking branch 'origin/main' into port/55600
Andarist Mar 12, 2026
970eeb3
drop the 2015 availability stuff
Andarist Mar 12, 2026
ffff27d
remove unused `lastDiagnostic`
Andarist Mar 12, 2026
b5b1755
privatize what needs to be privatized
Andarist Mar 12, 2026
66afe1f
reuse `collections.NewSetFromItems`
Andarist Mar 12, 2026
ba541a0
Remove unicodeproperties init indirection
Andarist Mar 12, 2026
b4ab864
introduce char helper
Andarist Mar 13, 2026
6847b55
passthrough those helpers
Andarist Mar 13, 2026
01b37de
bounds improvement
Andarist Mar 14, 2026
702e8a2
remove redundant comment
Andarist Mar 16, 2026
cfcdb99
bring back lost comment
Andarist Mar 16, 2026
8fee12e
add missing asserts
Andarist Mar 16, 2026
b2e2b07
handle atoi error
Andarist Mar 16, 2026
c65c53d
improve comment
Andarist Mar 16, 2026
b4ff2e2
use charAt properly
Andarist Mar 16, 2026
6208841
readd some comments
Andarist Mar 16, 2026
97e002b
tweak
Andarist Mar 16, 2026
96e9c9c
tweak
Andarist Mar 16, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions internal/checker/checker.go
Original file line number Diff line number Diff line change
Expand Up @@ -679,6 +679,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
Expand Down
64 changes: 28 additions & 36 deletions internal/checker/grammarchecks.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,43 +54,35 @@ 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() {
// 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() {
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 {
Expand Down
Loading
Loading