-
Notifications
You must be signed in to change notification settings - Fork 10.5k
properly handle isolated
and _const
type reprs when printing
#58729
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 |
lib/AST/TypeRepr.cpp
Outdated
break; | ||
case TypeReprKind::CompileTimeConst: | ||
Printer.printKeyword("_const", Opts, " "); | ||
break; | ||
default: |
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.
This is why I dislike default
:)
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.
@QuietMisdreavus I am confused how this led to "inout" being printed. Is that the default for function parameters in the SGF? If no one is relying on this switch being exhaustive we could just remove the default
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.
It's an issue with builds that have assertions disabled. With assertions enabled, the code (correctly) crashes when seeing _const
or isolated
. Without assertions, though, the llvm_unreachable
macro turns the branch into UB - which i assume in this case just picks a different branch arbitrarily.
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.
Makes sense! should we just remove the default case if no one cares about being exhaustive though?
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.
I think having the default there is still useful - this is a problem of test coverage (i don't know what else uses the AST Printer, TBH), not necessarily the switch being incorrect.
rdar://92756749
8b940db
to
ba17e42
Compare
I added another test to check @swift-ci Please smoke test |
// CHECK-NEXT: }, | ||
// CHECK-NEXT: { | ||
// CHECK-NEXT: "kind": "text", | ||
// CHECK-NEXT: "spelling": ": " |
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.
Should there be a "_const" fragment after this or is this handled further down the stack from TypeRepr
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.
This is correct without the _const
fragment; SymbolGraphGen filters out any decl attributes that begin with an underscore. If/when the @const
feature is accepted, the attribute will be changed to one without an underscore (if the SE discussion continues to hold up, it should be @const
), at which point SymbolGraphGen will stop filtering it.
It looks like there were some CI issues last week; here goes nothing... @swift-ci Please smoke test |
After some offline discussion, i've pushed a commit that removes the @swift-ci Please test |
@swift-ci Please test |
@swift-ci Please test macOS |
@swift-ci Please test Windows |
Resolves rdar://92756749
When using the ASTPrinter to print functions with
isolated
or@const
parameters, the printer currently doesn't know how to handle these attributes. A build with assertions will crash, while a build without assertions will render it asinout
. This PR adds branches for these inSpecifierTypeRepr::printImpl
, so that they can be properly printed.