Skip to content

Commit 6dc2109

Browse files
committed
Merge remote-tracking branch 'origin/main' into port/48172
2 parents e2cd9c6 + ed2d8c9 commit 6dc2109

File tree

85 files changed

+1024
-1835
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

85 files changed

+1024
-1835
lines changed

.custom-gcl.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# yaml-language-server: $schema=https://golangci-lint.run/jsonschema/custom-gcl.jsonschema.json
22

3-
version: v2.4.0
3+
version: v2.5.0
44

55
destination: ./_tools
66

NOTICE.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
221221

222222
---------------------------------------------------------
223223

224-
github.com/go-json-experiment/json v0.0.0-20250813233538-9b1f9ea2e11b - BSD-3-Clause
224+
github.com/go-json-experiment/json v0.0.0-20250910080747-cc2cfa0554c3 - BSD-3-Clause
225225

226226

227227
Copyright 2010 The Go Authors

_extension/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@
106106
},
107107
"devDependencies": {
108108
"@types/vscode": "^1.100.0",
109-
"@vscode/vsce": "^3.6.0",
110-
"esbuild": "^0.25.8"
109+
"@vscode/vsce": "^3.6.2",
110+
"esbuild": "^0.25.10"
111111
}
112112
}

_tools/go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,11 @@ go 1.25
55
require (
66
github.com/golangci/plugin-module-register v0.1.2
77
golang.org/x/mod v0.28.0
8-
golang.org/x/tools v0.36.0
8+
golang.org/x/tools v0.37.0
99
gotest.tools/v3 v3.5.2
1010
)
1111

1212
require (
1313
github.com/google/go-cmp v0.6.0 // indirect
14-
golang.org/x/sync v0.16.0 // indirect
14+
golang.org/x/sync v0.17.0 // indirect
1515
)

_tools/go.sum

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,9 @@ github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
44
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
55
golang.org/x/mod v0.28.0 h1:gQBtGhjxykdjY9YhZpSlZIsbnaE2+PgjfLWUQTnoZ1U=
66
golang.org/x/mod v0.28.0/go.mod h1:yfB/L0NOf/kmEbXjzCPOx1iK1fRutOydrCMsqRhEBxI=
7-
golang.org/x/sync v0.16.0 h1:ycBJEhp9p4vXvUZNszeOq0kGTPghopOL8q0fq3vstxw=
8-
golang.org/x/sync v0.16.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA=
9-
golang.org/x/tools v0.36.0 h1:kWS0uv/zsvHEle1LbV5LE8QujrxB3wfQyxHfhOk0Qkg=
10-
golang.org/x/tools v0.36.0/go.mod h1:WBDiHKJK8YgLHlcQPYQzNCkUxUypCaa5ZegCVutKm+s=
7+
golang.org/x/sync v0.17.0 h1:l60nONMj9l5drqw6jlhIELNv9I0A4OFgRsG9k2oT9Ug=
8+
golang.org/x/sync v0.17.0/go.mod h1:9KTHXmSnoGruLpwFjVSX0lNNA75CykiMECbovNTZqGI=
9+
golang.org/x/tools v0.37.0 h1:DVSRzp7FwePZW356yEAChSdNcQo6Nsp+fex1SUW09lE=
10+
golang.org/x/tools v0.37.0/go.mod h1:MBN5QPQtLMHVdvsbtarmTNukZDdgwdwlO5qGacAzF0w=
1111
gotest.tools/v3 v3.5.2 h1:7koQfIKdy+I8UTetycgUqXWSDwpgv193Ka+qRsmBY8Q=
1212
gotest.tools/v3 v3.5.2/go.mod h1:LtdLGcnqToBH83WByAAi/wiwSFCArdFIUV/xxN4pcjA=

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ go 1.25
44

55
require (
66
github.com/dlclark/regexp2 v1.11.5
7-
github.com/go-json-experiment/json v0.0.0-20250813233538-9b1f9ea2e11b
7+
github.com/go-json-experiment/json v0.0.0-20250910080747-cc2cfa0554c3
88
github.com/google/go-cmp v0.7.0
99
github.com/peter-evans/patience v0.3.0
1010
github.com/zeebo/xxh3 v1.0.2

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
github.com/dlclark/regexp2 v1.11.5 h1:Q/sSnsKerHeCkc/jSTNq1oCm7KiVgUMZRDUoRu0JQZQ=
22
github.com/dlclark/regexp2 v1.11.5/go.mod h1:DHkYz0B9wPfa6wondMfaivmHpzrQ3v9q8cnmRbL6yW8=
3-
github.com/go-json-experiment/json v0.0.0-20250813233538-9b1f9ea2e11b h1:6Q4zRHXS/YLOl9Ng1b1OOOBWMidAQZR3Gel0UKPC/KU=
4-
github.com/go-json-experiment/json v0.0.0-20250813233538-9b1f9ea2e11b/go.mod h1:TiCD2a1pcmjd7YnhGH0f/zKNcCD06B029pHhzV23c2M=
3+
github.com/go-json-experiment/json v0.0.0-20250910080747-cc2cfa0554c3 h1:02WINGfSX5w0Mn+F28UyRoSt9uvMhKguwWMlOAh6U/0=
4+
github.com/go-json-experiment/json v0.0.0-20250910080747-cc2cfa0554c3/go.mod h1:uNVvRXArCGbZ508SxYYTC5v1JWoz2voff5pm25jU1Ok=
55
github.com/go-quicktest/qt v1.101.0 h1:O1K29Txy5P2OK0dGo59b7b0LR6wKfIhttaAhHUyn7eI=
66
github.com/go-quicktest/qt v1.101.0/go.mod h1:14Bz/f7NwaXPtdYEgzsx46kqSxVwTbzVZsDC26tQJow=
77
github.com/google/go-cmp v0.7.0 h1:wk8382ETsv4JYUZwIsn6YpYiWiBsYLSJiTsyBybVuN8=

internal/checker/checker.go

Lines changed: 43 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -12405,17 +12405,32 @@ func (c *Checker) checkNullishCoalesceOperands(left *ast.Node, right *ast.Node)
1240512405
if ast.IsBinaryExpression(right) && ast.IsLogicalBinaryOperator(right.AsBinaryExpression().OperatorToken.Kind) {
1240612406
c.grammarErrorOnNode(right, diagnostics.X_0_and_1_operations_cannot_be_mixed_without_parentheses, scanner.TokenToString(right.AsBinaryExpression().OperatorToken.Kind), scanner.TokenToString(ast.KindQuestionQuestionToken))
1240712407
}
12408+
c.checkNullishCoalesceOperandLeft(left)
12409+
c.checkNullishCoalesceOperandRight(right)
12410+
}
12411+
12412+
func (c *Checker) checkNullishCoalesceOperandLeft(left *ast.Node) {
1240812413
leftTarget := ast.SkipOuterExpressions(left, ast.OEKAll)
1240912414
nullishSemantics := c.getSyntacticNullishnessSemantics(leftTarget)
1241012415
if nullishSemantics != PredicateSemanticsSometimes {
12411-
if left.Parent.Parent.Kind == ast.KindBinaryExpression {
12412-
c.error(leftTarget, diagnostics.This_binary_expression_is_never_nullish_Are_you_missing_parentheses)
12416+
if nullishSemantics == PredicateSemanticsAlways {
12417+
c.error(leftTarget, diagnostics.This_expression_is_always_nullish)
1241312418
} else {
12414-
if nullishSemantics == PredicateSemanticsAlways {
12415-
c.error(leftTarget, diagnostics.This_expression_is_always_nullish)
12416-
} else {
12417-
c.error(leftTarget, diagnostics.Right_operand_of_is_unreachable_because_the_left_operand_is_never_nullish)
12418-
}
12419+
c.error(leftTarget, diagnostics.Right_operand_of_is_unreachable_because_the_left_operand_is_never_nullish)
12420+
}
12421+
}
12422+
}
12423+
12424+
func (c *Checker) checkNullishCoalesceOperandRight(right *ast.Node) {
12425+
binaryExpression := right.Parent
12426+
if binaryExpression.Parent != nil && ast.IsBinaryExpression(binaryExpression.Parent) && binaryExpression.Parent.AsBinaryExpression().OperatorToken.Kind == ast.KindQuestionQuestionToken {
12427+
rightTarget := ast.SkipOuterExpressions(right, ast.OEKAll)
12428+
nullishSemantics := c.getSyntacticNullishnessSemantics(rightTarget)
12429+
switch nullishSemantics {
12430+
case PredicateSemanticsAlways:
12431+
c.error(rightTarget, diagnostics.This_expression_is_always_nullish)
12432+
case PredicateSemanticsNever:
12433+
c.error(rightTarget, diagnostics.This_expression_is_never_nullish)
1241912434
}
1242012435
}
1242112436
}
@@ -15393,9 +15408,7 @@ func (c *Checker) addDeclarationToLateBoundSymbol(symbol *ast.Symbol, member *as
1539315408
symbol.Declarations = append(symbol.Declarations, member)
1539415409
}
1539515410
if symbolFlags&ast.SymbolFlagsValue != 0 {
15396-
if symbol.ValueDeclaration == nil || symbol.ValueDeclaration.Kind != member.Kind {
15397-
symbol.ValueDeclaration = member
15398-
}
15411+
binder.SetValueDeclaration(symbol, member)
1539915412
}
1540015413
}
1540115414

@@ -15700,14 +15713,14 @@ func (c *Checker) getWriteTypeOfSymbolWithDeferredType(symbol *ast.Symbol) *Type
1570015713
// properties deriving from set accessors will either pre-compute or defer the union or
1570115714
// intersection of the writeTypes of their constituents.
1570215715
func (c *Checker) getWriteTypeOfSymbol(symbol *ast.Symbol) *Type {
15703-
if symbol.Flags&ast.SymbolFlagsProperty != 0 {
15704-
if symbol.CheckFlags&ast.CheckFlagsSyntheticProperty != 0 {
15705-
if symbol.CheckFlags&ast.CheckFlagsDeferredType != 0 {
15706-
return c.getWriteTypeOfSymbolWithDeferredType(symbol)
15707-
}
15708-
links := c.valueSymbolLinks.Get(symbol)
15709-
return core.OrElse(links.writeType, links.resolvedType)
15716+
if symbol.CheckFlags&ast.CheckFlagsSyntheticProperty != 0 {
15717+
if symbol.CheckFlags&ast.CheckFlagsDeferredType != 0 {
15718+
return c.getWriteTypeOfSymbolWithDeferredType(symbol)
1571015719
}
15720+
links := c.valueSymbolLinks.Get(symbol)
15721+
return core.OrElse(links.writeType, links.resolvedType)
15722+
}
15723+
if symbol.Flags&ast.SymbolFlagsProperty != 0 {
1571115724
return c.removeMissingType(c.getTypeOfSymbol(symbol), symbol.Flags&ast.SymbolFlagsOptional != 0)
1571215725
}
1571315726
if symbol.Flags&ast.SymbolFlagsAccessor != 0 {
@@ -20598,6 +20611,7 @@ func (c *Checker) getUnionOrIntersectionProperty(t *Type, name string, skipObjec
2059820611
}
2059920612

2060020613
func (c *Checker) createUnionOrIntersectionProperty(containingType *Type, name string, skipObjectFunctionPropertyAugment bool) *ast.Symbol {
20614+
propFlags := ast.SymbolFlagsNone
2060120615
var singleProp *ast.Symbol
2060220616
var propSet collections.OrderedSet[*ast.Symbol]
2060320617
var indexTypes []*Type
@@ -20627,6 +20641,7 @@ func (c *Checker) createUnionOrIntersectionProperty(containingType *Type, name s
2062720641
}
2062820642
if singleProp == nil {
2062920643
singleProp = prop
20644+
propFlags = core.OrElse(prop.Flags&ast.SymbolFlagsAccessor, ast.SymbolFlagsProperty)
2063020645
} else if prop != singleProp {
2063120646
isInstantiation := c.getTargetSymbol(prop) == c.getTargetSymbol(singleProp)
2063220647
// If the symbols are instances of one another with identical types - consider the symbols
@@ -20643,6 +20658,13 @@ func (c *Checker) createUnionOrIntersectionProperty(containingType *Type, name s
2064320658
}
2064420659
propSet.Add(prop)
2064520660
}
20661+
// classes created by mixins are represented as intersections
20662+
// and overriding a property in a derived class redefines it completely at runtime
20663+
// so a get accessor can't be merged with a set accessor in a base class,
20664+
// for that reason the accessor flags are only used when they are the same in all constituents
20665+
if propFlags&ast.SymbolFlagsAccessor != 0 && (prop.Flags&ast.SymbolFlagsAccessor != (propFlags & ast.SymbolFlagsAccessor)) {
20666+
propFlags = (propFlags &^ ast.SymbolFlagsAccessor) | ast.SymbolFlagsProperty
20667+
}
2064620668
}
2064720669
if isUnion && c.isReadonlySymbol(prop) {
2064820670
checkFlags |= ast.CheckFlagsReadonly
@@ -20670,6 +20692,7 @@ func (c *Checker) createUnionOrIntersectionProperty(containingType *Type, name s
2067020692
indexInfo = c.getApplicableIndexInfoForName(t, name)
2067120693
}
2067220694
if indexInfo != nil {
20695+
propFlags = propFlags&^ast.SymbolFlagsAccessor | ast.SymbolFlagsProperty
2067320696
checkFlags |= ast.CheckFlagsWritePartial | (core.IfElse(indexInfo.isReadonly, ast.CheckFlagsReadonly, 0))
2067420697
if isTupleType(t) {
2067520698
indexType := c.getRestTypeOfTupleType(t)
@@ -20762,7 +20785,7 @@ func (c *Checker) createUnionOrIntersectionProperty(containingType *Type, name s
2076220785
propTypes = append(propTypes, t)
2076320786
}
2076420787
propTypes = append(propTypes, indexTypes...)
20765-
result := c.newSymbolEx(ast.SymbolFlagsProperty|optionalFlag, name, checkFlags|syntheticFlag)
20788+
result := c.newSymbolEx(propFlags|optionalFlag, name, checkFlags|syntheticFlag)
2076620789
result.Declarations = declarations
2076720790
if !hasNonUniformValueDeclaration && firstValueDeclaration != nil {
2076820791
result.ValueDeclaration = firstValueDeclaration
@@ -23059,6 +23082,8 @@ func (c *Checker) computeEnumMemberValues(node *ast.Node) {
2305923082
func (c *Checker) computeEnumMemberValue(member *ast.Node, autoValue jsnum.Number, previous *ast.Node) evaluator.Result {
2306023083
if ast.IsComputedNonLiteralName(member.Name()) {
2306123084
c.error(member.Name(), diagnostics.Computed_property_names_are_not_allowed_in_enums)
23085+
} else if ast.IsBigIntLiteral(member.Name()) {
23086+
c.error(member.Name(), diagnostics.An_enum_member_cannot_have_a_numeric_name)
2306223087
} else {
2306323088
text := ast.GetTextOfPropertyName(member.Name())
2306423089
if isNumericLiteralName(text) && !isInfinityOrNaNString(text) {

internal/checker/emitresolver.go

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -409,7 +409,14 @@ func (r *emitResolver) hasVisibleDeclarations(symbol *ast.Symbol, shouldComputeA
409409
continue
410410
}
411411
if symbol.Flags&ast.SymbolFlagsBlockScopedVariable != 0 {
412-
variableStatement := ast.FindAncestor(declaration, ast.IsVariableStatement)
412+
rootDeclaration := ast.WalkUpBindingElementsAndPatterns(declaration)
413+
if ast.IsParameter(rootDeclaration) {
414+
return nil
415+
}
416+
variableStatement := rootDeclaration.Parent.Parent
417+
if !ast.IsVariableStatement(variableStatement) {
418+
return nil
419+
}
413420
if ast.HasSyntacticModifier(variableStatement, ast.ModifierFlagsExport) {
414421
continue // no alias to add, already exported
415422
}

internal/checker/grammarchecks.go

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ func (c *Checker) grammarErrorAtPos(nodeForSourceFile *ast.Node, start int, leng
3737
func (c *Checker) grammarErrorOnNode(node *ast.Node, message *diagnostics.Message, args ...any) bool {
3838
sourceFile := ast.GetSourceFileOfNode(node)
3939
if !c.hasParseDiagnostics(sourceFile) {
40-
c.diagnostics.Add(NewDiagnosticForNode(node, message, args...))
40+
c.error(node, message, args...)
4141
return true
4242
}
4343
return false
@@ -1700,8 +1700,13 @@ func (c *Checker) checkGrammarVariableDeclarationList(declarationList *ast.Varia
17001700
}
17011701

17021702
blockScopeFlags := declarationList.Flags & ast.NodeFlagsBlockScoped
1703-
if (blockScopeFlags == ast.NodeFlagsUsing || blockScopeFlags == ast.NodeFlagsAwaitUsing) && ast.IsForInStatement(declarationList.Parent) {
1704-
return c.grammarErrorOnNode(declarationList.AsNode(), core.IfElse(blockScopeFlags == ast.NodeFlagsUsing, diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_using_declaration, diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_an_await_using_declaration))
1703+
if blockScopeFlags == ast.NodeFlagsUsing || blockScopeFlags == ast.NodeFlagsAwaitUsing {
1704+
if ast.IsForInStatement(declarationList.Parent) {
1705+
return c.grammarErrorOnNode(declarationList.AsNode(), core.IfElse(blockScopeFlags == ast.NodeFlagsUsing, diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_a_using_declaration, diagnostics.The_left_hand_side_of_a_for_in_statement_cannot_be_an_await_using_declaration))
1706+
}
1707+
if declarationList.Flags&ast.NodeFlagsAmbient != 0 {
1708+
return c.grammarErrorOnNode(declarationList.AsNode(), core.IfElse(blockScopeFlags == ast.NodeFlagsUsing, diagnostics.X_using_declarations_are_not_allowed_in_ambient_contexts, diagnostics.X_await_using_declarations_are_not_allowed_in_ambient_contexts))
1709+
}
17051710
}
17061711

17071712
if blockScopeFlags == ast.NodeFlagsAwaitUsing {
@@ -1841,7 +1846,7 @@ func (c *Checker) checkGrammarForDisallowedBlockScopedVariableStatement(node *as
18411846
default:
18421847
panic("Unknown BlockScope flag")
18431848
}
1844-
return c.grammarErrorOnNode(node.AsNode(), diagnostics.X_0_declarations_can_only_be_declared_inside_a_block, keyword)
1849+
c.error(node.AsNode(), diagnostics.X_0_declarations_can_only_be_declared_inside_a_block, keyword)
18451850
}
18461851
}
18471852

@@ -2140,7 +2145,8 @@ func (c *Checker) checkGrammarNumericLiteral(node *ast.NumericLiteral) {
21402145
func (c *Checker) checkGrammarBigIntLiteral(node *ast.BigIntLiteral) bool {
21412146
literalType := ast.IsLiteralTypeNode(node.Parent) || ast.IsPrefixUnaryExpression(node.Parent) && ast.IsLiteralTypeNode(node.Parent.Parent)
21422147
if !literalType {
2143-
if c.languageVersion < core.ScriptTargetES2020 {
2148+
// Don't error on BigInt literals in ambient contexts
2149+
if node.Flags&ast.NodeFlagsAmbient == 0 && c.languageVersion < core.ScriptTargetES2020 {
21442150
if c.grammarErrorOnNode(node.AsNode(), diagnostics.BigInt_literals_are_not_available_when_targeting_lower_than_ES2020) {
21452151
return true
21462152
}

0 commit comments

Comments
 (0)