Skip to content

[Variadic Generics] Change pack expansion types and expressions to use the repeat syntax. #62766

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

Merged
merged 12 commits into from
Jan 7, 2023

Conversation

hborla
Copy link
Member

@hborla hborla commented Dec 22, 2022

The compiler side change corresponding to swiftlang/swift-syntax#1167

We're explaining patterned pack expansion as using repetition patterns. Given a concrete pack substitution, the pattern is repeated for each element in the substituted pack. This syntax expresses this idea directly using the repeat keyword, and each contextual keywords applied to pack references:

func tuplify<T...>(_ t: repeat each T) -> (repeat each T) {
  return (repeat each t)
}

This change replaces postfix ellipsis with a prefix repeat keyword for pack expansion types and expressions. This also introduces a syntactic distinction between pack expansion types and classic variadic parameter types.

@hborla hborla force-pushed the pack-expansion-syntax branch 3 times, most recently from 02c59b3 to 20ff52f Compare January 6, 2023 00:42
@hborla hborla marked this pull request as ready for review January 6, 2023 04:18
@hborla
Copy link
Member Author

hborla commented Jan 6, 2023

swiftlang/swift-syntax#1167

@swift-ci please smoke test

@hborla hborla force-pushed the pack-expansion-syntax branch from 3a2c00c to cac7fbe Compare January 7, 2023 03:52
@hborla
Copy link
Member Author

hborla commented Jan 7, 2023

swiftlang/swift-syntax#1167

@swift-ci please smoke test

hborla added 12 commits January 7, 2023 09:49
This wasn't used, and callers can instead use getExpandedPacks, which
also includes TypeReprs.
archetypes from the enclosing context, the ASTVerifier can cleanup these
environments in 'cleanup'.
…pack

expansion expressions, and create them in the parser instead of during
pre-checking in the constraint system.
pack expansion type reprs.

Classic variadic parameters still use the postfix ellipsis syntax, and
pack expansion types now use a prefix 'repeat' keyword.
…imental

feature flag to preserve existing parser diagnostics until the feature is
official.
Previously, pack expansion types of plain parameter packs whose reduced
shape is another parameter pack (i.e. as a result of parallel pack expansion
somewhere else in the signature) was previously incorrect. Fixing that "broke"
the incorrect mangling in these tests.
@hborla
Copy link
Member Author

hborla commented Jan 7, 2023

swiftlang/swift-syntax#1167

@swift-ci please smoke test

@hborla hborla merged commit 68ceda4 into swiftlang:main Jan 7, 2023
@hborla hborla deleted the pack-expansion-syntax branch January 7, 2023 23:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant