-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Fix crash when considering invalid binary operator function for resolution <rdar://23719809&23720006> #163
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
Please add a test in the same commit that makes the fix. |
Where would you like the test to be added? I don't see any particularly relevant files in the Sema tests. I could add one though. |
|
Test case added. Still I recognize that this might not be the right way of fixing the bug. If there's a better approach, let me know! |
@cwillmor Would you mind reviewing this patch? |
LGTM. I'm currently seeing if it fixes any other compiler crashers in the suite. Thanks for looking into this! |
My pleasure 😃 Before it's merged, however, it would make sense for someone who really knows this code to look at the questions I posed in the original PR comment — I'm mildly worried that this patch might be sweeping other potential problems under the rug. |
@@ -0,0 +1,12 @@ | |||
// RUN: %target-swift-frontend %s -parse |
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.
The RUN line here should be // RUN: not %target-swift-frontend %s -parse
(note the not
). Adding "not" asserts that the parse will fail but not crash.
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.
OK, updated. (Is there a way to run individual tests using the build-script?)
…ution <rdar://23719809&23720006> This fixes compiler crashes resulting from an invalid FuncDecl which is later considered while resolving a binary application.
To answer your questions:
EDIT: re the last point, @DougGregor and I just spoke and we don't think this should be allowed; it should raise a diagnostic at |
Calling I'm sure there is more to understand here; as an outsider I'm just not that familiar with the codebase yet. I'll defer to y'all to merge this patch if you see fit, or recommend more changes. 🎱 |
This is good to merge — the RUN line was the only real issue. Feel free to follow up on the other comments. Thanks! |
Fix crash when considering invalid binary operator function for resolution. <rdar://23719809&23720006>
🎉 ! |
Nice! |
SR-2356 : Remove temporary APIs from Linux overlay
SR-2356 : Remove temporary APIs from Linux overlay Signed-off-by: Daniel A. Steffen <[email protected]>
Add support for FunctionTypeSyntax
Add Swift 4.0.3 hash for PanelKit.
This fixes compiler crashes resulting from an invalid FuncDecl which is later considered while resolving a binary application. <rdar://23719809&23720006>
Examples:
func ~=(){}
(empty tuple)func ~=(_:Int){}
(one argument which cannot be cast to a tuple)These are considered when type-checking something like
switch 0 { case 0: ... }
.Some questions I had while poking around to figure out this patch:
validation-test
. Should I still add a test intest/decl/operators.swift
, or perhaps somewhere undertest/Sema
?DeclChecker::bindFuncDeclToOperator
have calledFD->setInvalid(true)
when it emits error diagnostics for the function definitions, which happens earlier, to avoid getting this far into operator resolution with a bad operator function? I'm not familiar enough with the code to understand who's expected to callsetInvalid
, and who's expected to checkisInvalid
.FuncDecl::isBinaryOperator()
returns true if the argument tuple has 1 element with an ellipsis. I'm concerned thatfavorMatchingBinaryOperators
(the function being modified here) doesn't support this case properly. Should it?