-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[ASTGen] Generate Swift key-path expressions #77398
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
Conversation
@swift-ci Please smoke test |
|
||
// RUN: %empty-directory(%t) | ||
// RUN: %target-swift-frontend %s -dump-ast -enable-experimental-feature ParserASTGen -verify > %t/astgen.ast.raw | ||
// RUN: not %target-swift-frontend %s -dump-ast > %t/cpp-parser.ast.raw |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Comparing -dump-ast
instead of -dump-parse
because we generate KeyPathExpr
differently.
In libParse
the root expression is parsed as a normal expression, but in SwiftParser
it's parsed as a TypeSyntax
, so we generate it as TypeExpr
. But they are normalized in PreCheckTarget
and should be end up with the same type-checked AST.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be worth adding this as a comment to the test?
var i = \[A].property.nonMutatingProperty | ||
expect(&i, toHaveType: Exactly<ReferenceWritableKeyPath<[A], B>>.self) | ||
|
||
var j = \[A].[x] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Amusingly you can also do \[A][x]
😄
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm I thought we require a dot if the first "path" part is a subscript. But apparently not 🤔
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FWIW this cases are pulled from test/expr/unary/keypath/keypath.swift
And I will add more test cases from it when I revisit here for adding AST diagnostics (for e.g. empty components)
c4d183d
to
dc156a6
Compare
@swift-ci Please smoke test |
@swift-ci Please smoke test Windows |
1 similar comment
@swift-ci Please smoke test Windows |
No description provided.