-
Notifications
You must be signed in to change notification settings - Fork 340
[lldb] Fix typealias not being emitted for weakly captured generic #7526
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
[lldb] Fix typealias not being emitted for weakly captured generic #7526
Conversation
@swift-ci test |
macOS test failures seem to be unrelated. |
Ping :) |
lldb/source/Plugins/ExpressionParser/Swift/SwiftExpressionParser.cpp
Outdated
Show resolved
Hide resolved
lldb/source/Plugins/ExpressionParser/Swift/SwiftExpressionParser.cpp
Outdated
Show resolved
Hide resolved
@@ -532,7 +532,7 @@ lldb::VariableSP SwiftExpressionParser::FindSelfVariable(Block *block) { | |||
return variable_list_sp->FindVariable(ConstString("self")); | |||
} | |||
|
|||
static void AddRequiredAliases(Block *block, lldb::StackFrameSP &stack_frame_sp, | |||
static bool AddRequiredAliases(Block *block, lldb::StackFrameSP &stack_frame_sp, |
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.
Can you document what the return value means?
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 you instead return a Status that contains an error message about what failed?
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 added the error messages, but I wonder if having them is better than a generic error. They aren't really actionable from the user's point of view.
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.
@PortalPete what do you think?
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 generally think more information is helpful to the community. The error messages certainly help me understand what the code is doing a bit better.
My answer hinges on what you mean by "actionable" and who could take action. Even if the message isn't about the developer's code that they're debugging, it could potentially inform them it's not responsible for the issue at hand.
900b25b
to
1923951
Compare
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.
Hi Augusto,
As my editor said to me on my first day as a tech writer, "You're going to see a lot of red, and that's ok!"
In this case it's actually green, but you get the idea. 🙂
I'd start with this one on line 535 (ish)
because it's the most interesting.
I know Stash sometimes mixes up the order of things in the Conversation tab.
The rest are just classic fixes for active voice and/or present tense, and you'll see the wording patterns right away.
lldb/source/Plugins/ExpressionParser/Swift/SwiftExpressionParser.cpp
Outdated
Show resolved
Hide resolved
lldb/source/Plugins/ExpressionParser/Swift/SwiftExpressionParser.cpp
Outdated
Show resolved
Hide resolved
lldb/source/Plugins/ExpressionParser/Swift/SwiftExpressionParser.cpp
Outdated
Show resolved
Hide resolved
lldb/source/Plugins/ExpressionParser/Swift/SwiftExpressionParser.cpp
Outdated
Show resolved
Hide resolved
lldb/source/Plugins/ExpressionParser/Swift/SwiftExpressionParser.cpp
Outdated
Show resolved
Hide resolved
lldb/source/Plugins/ExpressionParser/Swift/SwiftExpressionParser.cpp
Outdated
Show resolved
Hide resolved
lldb/source/Plugins/ExpressionParser/Swift/SwiftExpressionParser.cpp
Outdated
Show resolved
Hide resolved
|
||
if (!self_class_type) | ||
return; | ||
// Only class types can be weakly captured. |
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.
// Only class types can be weakly captured. | |
// The Swift expression parser can only weakly capture class types. |
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.
In this case it's not the Swift expression parser, it's in the rules of the Swift language that only a class type can be weakly captured. Also, "strongly captured" and "weakly captured" are already part of the Swift lingo.
I'll change it to:
// In Swift only class types can be weakly captured.
// Only class types can be weakly captured. | ||
if (!llvm::isa<swift::ClassType>(first_arg_type) && | ||
!llvm::isa<swift::BoundGenericClassType>(first_arg_type)) | ||
return Status("Could not add required aliases: weakly captured type is " |
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.
return Status("Could not add required aliases: weakly captured type is " | |
return Status("Unable to add the aliases the expression needs because " |
If the word "Unable" isn't a valid option, then I suggest the contraction "Couldn't".
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.
Since "weakly captured" is already part of the Swift lingo I think we should keep it, maybe:
"Unable to add the aliases the expression needs because weakly captured type is not a class type"?
lldb/source/Plugins/ExpressionParser/Swift/SwiftExpressionParser.cpp
Outdated
Show resolved
Hide resolved
1923951
to
b617a1c
Compare
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.
A found a few more things that I missed yesterday.
Other than that, I noticed there's a few cases of self
inside backticks and some more without. I suggest choosing one way for consistency.
Personally, I prefer `self`
with backticks because it refers to the language's keyword as opposed to the normal English word self.
lldb/source/Plugins/ExpressionParser/Swift/SwiftExpressionParser.cpp
Outdated
Show resolved
Hide resolved
lldb/source/Plugins/ExpressionParser/Swift/SwiftExpressionParser.cpp
Outdated
Show resolved
Hide resolved
lldb/source/Plugins/ExpressionParser/Swift/SwiftExpressionParser.cpp
Outdated
Show resolved
Hide resolved
lldb/source/Plugins/ExpressionParser/Swift/SwiftExpressionParser.cpp
Outdated
Show resolved
Hide resolved
lldb/test/API/lang/swift/expression/weak_generic_self/TestSwiftWeakGenericSelf.py
Outdated
Show resolved
Hide resolved
lldb/source/Plugins/ExpressionParser/Swift/SwiftExpressionParser.cpp
Outdated
Show resolved
Hide resolved
lldb/source/Plugins/ExpressionParser/Swift/SwiftExpressionParser.cpp
Outdated
Show resolved
Hide resolved
lldb/source/Plugins/ExpressionParser/Swift/SwiftExpressionParser.cpp
Outdated
Show resolved
Hide resolved
lldb/source/Plugins/ExpressionParser/Swift/SwiftExpressionParser.cpp
Outdated
Show resolved
Hide resolved
Hmm, I think we should do it without backticks because:
|
The typealias to $__lldb_context (the self type) was not being emitted when self was weakly captured and the type of self was a generic class type. Fix this, and also make AddRequiredAliases return an error code in case it was unable to emit one of the required aliases. rdar://104697539
b617a1c
to
6fb5c0f
Compare
The typealias to $__lldb_context (the self type) was not being emitted when self was weakly captured and the type of self was a generic class type. Fix this, and also make AddRequiredAliases return an error code in case it was unable to emit one of the required aliases.
rdar://104697539