Skip to content

Merge main into release/6.2 #3057

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
30 commits
Select commit Hold shift + click to select a range
848e5fe
Fix build warning
ahoppen Mar 28, 2025
c8f189e
[bazel] Add new C files
keith Apr 1, 2025
52c4bc2
Include try and await expressions which are parents of a freestanding…
stmontgomery Jul 10, 2024
2b9a763
Handle `try` and `await` in unfolded sequences
hamishknight Apr 1, 2025
2c16aeb
Add `unsafe` as a lexical context too
hamishknight Apr 3, 2025
09ea403
Merge pull request #3037 from hamishknight/in-sequence
hamishknight Apr 4, 2025
660b9a1
[Windows] Remove extra newlines from diagnostic output.
al45tair Apr 3, 2025
820501e
Add dependencies to SwiftSyntax60[12] (#3034)
mbrandonw Apr 4, 2025
6c53107
Merge pull request #3039 from al45tair/eng/PR-148520063
al45tair Apr 6, 2025
f650d77
Merge pull request #3031 from ahoppen/fix-build-warning
ahoppen Apr 7, 2025
f1261c0
Merge pull request #3035 from keith/ks/bazel-add-new-c-files
ahoppen Apr 7, 2025
2fcf9c4
Don’t exclude 5.8 in PR testing
ahoppen Apr 7, 2025
491c5c9
Add concurrency control to cancel in-progress PR workflows (#3042)
TTOzzi Apr 7, 2025
1637566
Removes duplicate trivia from UnsafeExprSyntax
TTOzzi Apr 5, 2025
35a9cde
[SwiftParser] Allow nonisolated to accept `nonsending` modifier
xedin Apr 4, 2025
a7f65cd
[SwiftParser] Allow `nonisolated` modifier to have a single `nonsendi…
xedin Apr 7, 2025
3977abe
[SwiftParser] Make `nonisolated(nonsending)` parsing check before con…
xedin Apr 7, 2025
9ffe4b8
[SwiftParser] Lookahead: Teach `skipTypeAttributeList` about modifier…
xedin Apr 8, 2025
2b13304
[SwiftParser] Account for a newline between `nonisolated` and `(`
xedin Apr 9, 2025
367883a
Merge pull request #3043 from TTOzzi/unsafe-leading-trivia
ahoppen Apr 9, 2025
ea77686
Change default release version to 603.0.0
ahoppen Apr 9, 2025
a292dd3
Merge pull request #3045 from ahoppen/remove-58-pr-testing
ahoppen Apr 9, 2025
0ef1dc3
Add SwiftSyntax603 version marker module
ahoppen Apr 9, 2025
7ba88aa
Merge pull request #3050 from ahoppen/default-release-version
ahoppen Apr 10, 2025
d0c3e61
Add GitHub action that automatically creates a PR to merge main into …
ahoppen Apr 10, 2025
cf4e08b
Merge pull request #3053 from ahoppen/auto-merge
ahoppen Apr 11, 2025
b9f80c7
[SwiftParser] Avoid consuming invalid `dependsOn` and `nonisolated` m…
xedin Apr 11, 2025
2ae464e
[SwiftParser] Parse `nonisolated` as modifier only if it has `nonsend…
xedin Apr 11, 2025
fb65fcb
Merge pull request #3047 from xedin/nonisolated-nonsending-attr
xedin Apr 12, 2025
caa2d3b
Revert "Change default release version to 603.0.0"
ahoppen Apr 16, 2025
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
14 changes: 14 additions & 0 deletions .github/workflows/automerge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: Create PR to merge main into release branch
# In the first period after branching the release branch, we typically want to include many changes from `main` in the release branch. This workflow automatically creates a PR every Monday to merge main into the release branch.
# Later in the release cycle we should stop this practice to avoid landing risky changes by disabling this workflow. To do so, disable the workflow as described in https://docs.github.com/en/actions/managing-workflow-runs-and-deployments/managing-workflow-runs/disabling-and-enabling-a-workflow
on:
schedule:
- cron: '0 9 * * MON'
workflow_dispatch:
jobs:
create_merge_pr:
name: Create PR to merge main into release branch
uses: swiftlang/github-workflows/.github/workflows/create_automerge_pr.yml@main
with:
base_branch: release/6.2
if: (github.event_name == 'schedule' && github.repository == 'swiftlang/swift-syntax') || (github.event_name != 'schedule') # Ensure that we don't run this on a schedule in a fork
6 changes: 4 additions & 2 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@ on:
pull_request:
types: [opened, reopened, synchronize]

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
tests:
name: Test
uses: swiftlang/github-workflows/.github/workflows/swift_package_test.yml@main
with:
linux_exclude_swift_versions: "[{\"swift_version\": \"5.8\"}]"
soundness:
name: Soundness
uses: swiftlang/github-workflows/.github/workflows/soundness.yml@main
Expand Down
18 changes: 18 additions & 0 deletions BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,9 @@ swift_syntax_library(
":SwiftSyntax509",
":SwiftSyntax510",
":SwiftSyntax600",
":SwiftSyntax601",
":SwiftSyntax602",
":SwiftSyntax603",
":_SwiftSyntaxCShims",
],
)
Expand Down Expand Up @@ -251,6 +254,20 @@ swift_syntax_library(
],
)

swift_syntax_library(
name = "SwiftSyntax602",
srcs = glob(["Sources/VersionMarkerModules/SwiftSyntax602/**/*.swift"]),
deps = [
],
)

swift_syntax_library(
name = "SwiftSyntax603",
srcs = glob(["Sources/VersionMarkerModules/SwiftSyntax603/**/*.swift"]),
deps = [
],
)

swift_syntax_library(
name = "SwiftSyntaxBuilder",
deps = [
Expand Down Expand Up @@ -376,6 +393,7 @@ cc_library(

cc_library(
name = "_SwiftSyntaxCShims",
srcs = glob(["Sources/_SwiftSyntaxCShims/*.c"]),
hdrs = glob(["Sources/_SwiftSyntaxCShims/include/*.h"]),
includes = ["Sources/_SwiftSyntaxCShims/include"],
tags = ["swift_module=_SwiftSyntaxCShims"],
Expand Down
3 changes: 3 additions & 0 deletions CodeGeneration/Sources/SyntaxSupport/KeywordSpec.swift
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ public enum Keyword: CaseIterable {
case none
case nonisolated
case nonmutating
case nonsending
case objc
case obsoleted
case of
Expand Down Expand Up @@ -551,6 +552,8 @@ public enum Keyword: CaseIterable {
return KeywordSpec("nonisolated")
case .nonmutating:
return KeywordSpec("nonmutating")
case .nonsending:
return KeywordSpec("nonsending")
case .objc:
return KeywordSpec("objc")
case .obsoleted:
Expand Down
3 changes: 3 additions & 0 deletions CodeGeneration/Sources/SyntaxSupport/SyntaxNodeKind.swift
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,9 @@ public enum SyntaxNodeKind: String, CaseIterable, IdentifierConvertible, TypeCon
case multipleTrailingClosureElementList
case namedOpaqueReturnType
case nilLiteralExpr
case nonisolatedSpecifierArgument
case nonisolatedSpecifierArgumentList
case nonisolatedTypeSpecifier
case objCSelectorPiece
case objCSelectorPieceList
case operatorDecl
Expand Down
49 changes: 47 additions & 2 deletions CodeGeneration/Sources/SyntaxSupport/TypeNodes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -676,6 +676,52 @@ public let TYPE_NODES: [Node] = [
]
),

Node(
kind: .nonisolatedSpecifierArgument,
base: .syntax,
nameForDiagnostics: nil,
documentation: """
A single argument that can be added to a nonisolated specifier: 'nonsending'.

### Example
`data` in `func foo(data: nonisolated(nonsending) () async -> Void) -> X`
""",
traits: [
"Parenthesized"
],
children: [
Child(
name: "leftParen",
kind: .token(choices: [.token(.leftParen)])
),
Child(
name: "nonsendingKeyword",
kind: .token(choices: [.keyword(.nonsending)])
),
Child(
name: "rightParen",
kind: .token(choices: [.token(.rightParen)])
),
]
),

Node(
kind: .nonisolatedTypeSpecifier,
base: .syntax,
nameForDiagnostics: "'nonisolated' specifier",
children: [
Child(
name: "nonisolatedKeyword",
kind: .token(choices: [.keyword(.nonisolated)])
),
Child(
name: "argument",
kind: .node(kind: .nonisolatedSpecifierArgument),
isOptional: true
),
]
),

Node(
kind: .simpleTypeSpecifier,
base: .syntax,
Expand All @@ -689,7 +735,6 @@ public let TYPE_NODES: [Node] = [
.keyword(.__shared),
.keyword(.__owned),
.keyword(.isolated),
.keyword(.nonisolated),
.keyword(._const),
.keyword(.borrowing),
.keyword(.consuming),
Expand All @@ -704,6 +749,6 @@ public let TYPE_NODES: [Node] = [
kind: .typeSpecifierList,
base: .syntaxCollection,
nameForDiagnostics: nil,
elementChoices: [.simpleTypeSpecifier, .lifetimeTypeSpecifier]
elementChoices: [.simpleTypeSpecifier, .lifetimeTypeSpecifier, .nonisolatedTypeSpecifier]
),
]
10 changes: 9 additions & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,10 @@ let package = Package(

.target(
name: "SwiftSyntax",
dependencies: ["_SwiftSyntaxCShims", "SwiftSyntax509", "SwiftSyntax510", "SwiftSyntax600"],
dependencies: [
"_SwiftSyntaxCShims", "SwiftSyntax509", "SwiftSyntax510", "SwiftSyntax600", "SwiftSyntax601", "SwiftSyntax602",
"SwiftSyntax603",
],
exclude: ["CMakeLists.txt"],
swiftSettings: swiftSyntaxSwiftSettings
),
Expand Down Expand Up @@ -248,6 +251,11 @@ let package = Package(
path: "Sources/VersionMarkerModules/SwiftSyntax602"
),

.target(
name: "SwiftSyntax603",
path: "Sources/VersionMarkerModules/SwiftSyntax603"
),

// MARK: SwiftSyntaxBuilder

.target(
Expand Down
18 changes: 13 additions & 5 deletions Sources/SwiftDiagnostics/DiagnosticsFormatter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -293,10 +293,13 @@ public struct DiagnosticsFormatter {
)
)

// If the line did not end with \n (e.g. the last line), append it manually
if annotatedSource.last != "\n" {
annotatedSource.append("\n")
// Remove any trailing newline and replace it; this may seem
// counterintuitive, but if we're running within CMake and we let a
// '\r\n' through, CMake will turn that into *two* newlines.
if let last = annotatedSource.last, last.isNewline {
annotatedSource.removeLast()
}
annotatedSource.append("\n")

let columnsWithDiagnostics = Set(
annotatedLine.diagnostics.map {
Expand Down Expand Up @@ -331,8 +334,13 @@ public struct DiagnosticsFormatter {
}

// Add suffix text.
annotatedSource.append(annotatedLine.suffixText)
if annotatedSource.last != "\n" {
if !annotatedLine.suffixText.isEmpty {
annotatedSource.append(annotatedLine.suffixText)

// See above for an explanation of why we do this
if let last = annotatedSource.last, last.isNewline {
annotatedSource.removeLast()
}
annotatedSource.append("\n")
}
}
Expand Down
2 changes: 1 addition & 1 deletion Sources/SwiftIfConfig/BuildConfiguration.swift
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ enum BuildConfigurationError: Error, CustomStringConvertible {
var description: String {
switch self {
case .experimentalFeature(let name):
return "'name' is an experimental feature"
return "'\(name)' is an experimental feature"
}
}
}
Expand Down
6 changes: 3 additions & 3 deletions Sources/SwiftOperators/OperatorTable+Folding.swift
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,6 @@ extension OperatorTable {
if let unsafeExpr = lhs.as(UnsafeExprSyntax.self) {
return ExprSyntax(
UnsafeExprSyntax(
leadingTrivia: unsafeExpr.leadingTrivia,
unsafeExpr.unexpectedBeforeUnsafeKeyword,
unsafeKeyword: unsafeExpr.unsafeKeyword,
unsafeExpr.unexpectedBetweenUnsafeKeywordAndExpression,
Expand All @@ -150,11 +149,12 @@ extension OperatorTable {
op: op,
rhs: rhs
),
unsafeExpr.unexpectedAfterExpression,
trailingTrivia: unsafeExpr.trailingTrivia
unsafeExpr.unexpectedAfterExpression
)
)
}
// NOTE: If you add a new try/await/unsafe-like hoisting case here, make
// sure to also update `allMacroLexicalContexts` to handle it.

// The form of the binary operation depends on the operator itself,
// which will be one of the unresolved infix operators.
Expand Down
6 changes: 3 additions & 3 deletions Sources/SwiftParser/Attributes.swift
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ extension Parser {
shouldParseArgument = true
case .customAttribute:
shouldParseArgument =
self.withLookahead { $0.atCustomAttributeArgument() }
self.withLookahead { $0.atAttributeOrSpecifierArgument() }
&& self.at(TokenSpec(.leftParen, allowAtStartOfLine: false))
case .optional:
shouldParseArgument = self.at(.leftParen)
Expand Down Expand Up @@ -1002,7 +1002,7 @@ extension Parser {
// MARK: Lookahead

extension Parser.Lookahead {
mutating func atCustomAttributeArgument() -> Bool {
mutating func atAttributeOrSpecifierArgument() -> Bool {
var lookahead = self.lookahead()
lookahead.skipSingle()

Expand Down Expand Up @@ -1036,7 +1036,7 @@ extension Parser.Lookahead {
}

if self.at(TokenSpec(.leftParen, allowAtStartOfLine: false))
&& self.withLookahead({ $0.atCustomAttributeArgument() })
&& self.withLookahead({ $0.atAttributeOrSpecifierArgument() })
{
self.skipSingle()
}
Expand Down
30 changes: 28 additions & 2 deletions Sources/SwiftParser/Expressions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -381,13 +381,39 @@ extension Parser {
}
}

/// Make sure that we only accept `nonisolated(nonsending)` as a valid type specifier
/// in expression context to minimize source compatibility impact.
func canParseNonisolatedAsSpecifierInExpressionContext() -> Bool {
return withLookahead {
guard $0.consume(if: .keyword(.nonisolated)) != nil else {
return false
}

if $0.currentToken.isAtStartOfLine {
return false
}

guard $0.consume(if: .leftParen) != nil else {
return false
}

guard $0.consume(if: TokenSpec(.nonsending, allowAtStartOfLine: false)) != nil else {
return false
}

return $0.at(TokenSpec(.rightParen, allowAtStartOfLine: false))
}
}

/// Parse an expression sequence element.
mutating func parseSequenceExpressionElement(
flavor: ExprFlavor,
pattern: PatternContext = .none
) -> RawExprSyntax {
// Try to parse '@' sign or 'inout' as an attributed typerepr.
if self.at(.atSign, .keyword(.inout)) {
// Try to parse '@' sign, 'inout', or 'nonisolated' as an attributed typerepr.
if self.at(.atSign, .keyword(.inout))
|| self.canParseNonisolatedAsSpecifierInExpressionContext()
{
var lookahead = self.lookahead()
if lookahead.canParseType() {
let type = self.parseType()
Expand Down
6 changes: 5 additions & 1 deletion Sources/SwiftParser/Modifiers.swift
Original file line number Diff line number Diff line change
Expand Up @@ -236,7 +236,11 @@ extension Parser {
let detail: RawDeclModifierDetailSyntax?
if self.at(.leftParen) {
let (unexpectedBeforeLeftParen, leftParen) = self.expect(.leftParen)
let (unexpectedBeforeDetailToken, detailToken) = self.expect(TokenSpec(.unsafe, remapping: .identifier))
let (unexpectedBeforeDetailToken, detailToken) = self.expect(
TokenSpec(.unsafe, remapping: .identifier),
TokenSpec(.nonsending, remapping: .identifier),
default: TokenSpec(.identifier)
)
let (unexpectedBeforeRightParen, rightParen) = self.expect(.rightParen)
detail = RawDeclModifierDetailSyntax(
unexpectedBeforeLeftParen,
Expand Down
1 change: 1 addition & 0 deletions Sources/SwiftParser/TokenPrecedence.swift
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,7 @@ enum TokenPrecedence: Comparable {
.module,
.noasync,
.none,
.nonsending,
.obsoleted,
.of,
.Protocol,
Expand Down
Loading