Skip to content
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

Swift: extract parameter packs #14734

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open

Conversation

AlexDenisov
Copy link
Contributor

No description provided.

@@ -1426,6 +1426,23 @@ module Exprs {
}
}

/** Control-flow for a Pack Expansion. See the QLDocs for `PackExpansionExpr` and `PackElementExpr` for the semantics. */
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no QLDoc on PackExpansionExpr nor PackElementExpr that explains the semantics of them. Is that a copy/pasting gone wrong? Or did you intend to write down what these actually mean? 😄

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I think it's just a bad copy-paste. There are some docs, but I guess those do not explain semantics. I'll update the docs and add some links to the official docs.

Comment on lines +185 to +187
func makeTuple<each T>(_ t: repeat each T) -> (repeat each T) {
return (repeat each t)
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

They really didn't want the C++ ... syntax, so they just relabeled it, eh? 😆

swift/schema.py Outdated

class PackExpansionExpr(Expr):
"""
A pattern expression followed by the expansion operator '...'.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

only that it's not ... any more, isn't it?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch, the sources refer to these as ... though, I'll update the docs in the other round when I'm done with the rest.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, I think their temporary syntax while they were implementing this in the background throughout 5.8 was that, but then they bikeshedded the sh*t out of it but did not update the naming everywhere 😆

"""
pattern_expr: Expr | child

class PackElementExpr(Expr):
Copy link
Contributor

@redsun82 redsun82 Nov 9, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you can now use @qltest.test_with(PackExpansionExpr) to avoid having a separate generated test directory for this, repeating the same sources. You also save on extraction time like this.

swift/schema.py Outdated
Comment on lines 1202 to 1244
class ElementArchetypeType(LocalArchetypeType):
pass

class PackArchetypeType(ArchetypeType):
pass

class PackType(Type):
elements: list[Type]

class PackExpansionType(Type):
pattern_type: Type
count_type: Type

class PackElementType(Type):
pack_type: Type

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

these can also have their tests grouped, right? They probably can go all under @qltest.test_with("PackType") (use PackType if the definition is there, and "PackType" if it is a kind of "forward" definition).

@AlexDenisov
Copy link
Contributor Author

Database upgrade is coming as a separate PR on top of this one.

@AlexDenisov AlexDenisov marked this pull request as ready for review November 10, 2023 09:32
@AlexDenisov AlexDenisov requested a review from a team as a code owner November 10, 2023 09:32
redsun82
redsun82 previously approved these changes Nov 10, 2023
Copy link
Contributor

@redsun82 redsun82 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this!

…upgrade

Swift: parameter packs migration scripts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants