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
[SR-11399] Operator returning IUO doesn't implicitly unwrap #53800
Comments
cc @xedin |
@swift-ci create |
Comment by Vuk (JIRA) When type checking the example in the Description let x: Int = 1^^^ It does not attempt a disjunction choice for an implicitly unwrapped optional because the function ref kind is Unapplied so it returns false in this method in `ConstraintSystem.cpp`. which causes it not to introduce a disjunction and causes the failure in the example. bool OverloadChoice::isImplicitlyUnwrappedValueOrReturnValue() const {
...
switch (getFunctionRefKind()) {
case FunctionRefKind::Unapplied:
case FunctionRefKind::Compound:
return false;
case FunctionRefKind::SingleApply:
case FunctionRefKind::DoubleApply:
return true;
}
llvm_unreachable("unhandled kind");
} Here is the expression dump (postfix_unary_expr type='$T2' location=/Users/vuk/Desktop/test.swift:5:15 range=[/Users/vuk/Desktop/test.swift:5:14 - line:5:15]
(declref_expr type='$T0' location=/Users/vuk/Desktop/test.swift:5:15 range=[/Users/vuk/Desktop/test.swift:5:15 - line:5:15] decl=test.(file).^^^@/Users/vuk/Desktop/test.swift:3:14 function_ref=unapplied)
(paren_expr implicit type='($T1)' location=/Users/vuk/Desktop/test.swift:5:14 range=[/Users/vuk/Desktop/test.swift:5:14 - line:5:14]
(integer_literal_expr type='$T1' location=/Users/vuk/Desktop/test.swift:5:14 range=[/Users/vuk/Desktop/test.swift:5:14 - line:5:14] value=1 builtin_initializer=**NULL** initializer=**NULL**))) Should the FunctionRefKind be SingleApply for the postfix operator and if so would that be an issue prior to type checking or does that get resolved/changed during type checking? In an equivalent function call the function_ref is SingleApply. Any help is greatly appreciated! |
vukrado (JIRA User) Yes, the |
Comment by Vuk (JIRA) It looks like that was it @hamishknight. Thank you! I made a PR here #32737. |
Resolving as PR was merged |
Environment
Swift version 5.1-dev (LLVM c5340df2d1, Swift 4fa3cef)
Target: x86_64-apple-darwin18.5.0
Additional Detail from JIRA
md5: 1035c13ed31b14c0199f689b983bb170
Issue Description:
The following fails to compile:
But arguably should, as the result of the call to
^^^
should be implicitly unwrapped, just like an equivalent function call would.The text was updated successfully, but these errors were encountered: