Commit Graph

6 Commits

Author SHA1 Message Date
Hamish Knight
c667d2b361 Use DefaultArgumentExpr for caller-side defaults
This commit changes how we represent caller-side
default arguments within the AST. Instead of
directly inserting them into the call-site, use
a DefaultArgumentExpr to refer to them indirectly.

The main goal of this change is to make it such
that the expression type-checker no longer cares
about the difference between caller-side and
callee-side default arguments. In particular, it
no longer cares about whether a caller-side
default argument is well-formed when type-checking
an apply. This is important because any
conversions introduced by the default argument
shouldn't affect the score of the resulting
solution.

Instead, caller-side defaults are now lazily
type-checked when we want to emit them in SILGen.
This is done through introducing a request, and
adjusting the logic in SILGen to be more lenient
with ErrorExprs. Caller-side defaults in primary
files are still also currently checked as a part
of the declaration by `checkDefaultArguments`.

Resolves SR-11085.
Resolves rdar://problem/56144412.
2019-11-20 15:07:32 -08:00
Robert Widmann
dd1b15775d Partially Revert #27862
When SE-110 was being implemented, we accidentally began to accept
closure parameter declarations that had no associated parameter names,
e.g.

foo { ([Int]) in /**/ }

This syntax has never been sanctioned by any version of Swift and should
be banned.  However, the change was made long enough ago and there are
enough clients relying on this, that we cannot accept the source break
at the moment.  For now, add a bit to ParamDecl that marks a parameter
as destructured, and back out setting the invalid bit on the type repr
for these kinds of declarations.

To prevent further spread of this syntax, stub in a warning that offers
to insert an anonymous parameter.

Resolves part of rdar://56673657 and improves QoI for errors like
rdar://56911630
2019-11-10 22:10:53 -08:00
Robert Widmann
a1e956d3e7 Resolve a compiler crasher 2019-10-24 16:03:41 -07:00
Slava Pestov
eef8c11dd9 This test case only fails with asserts on
Fixes <rdar://problem/56196703>.
2019-10-11 18:44:10 -04:00
Slava Pestov
de8745b733 Sema: Simplify error handling in typeCheckParameterList() 2019-10-10 13:08:08 -04:00
Pavel Yaskevich
ddaccf88bb [QoI] Properly diagnose closure parameter distructuring after SE-0110
Swift 3 supported limited argument destructuring when it comes to
declaring (trailing) closures. Such behavior has been changed by
SE-0110. This patch aims to provide better error message as well
as fix-it (if structure of the expected and actual arguments matches)
to make the migration easier and disambiguate some of the common
mistakes.

Resolves: SR-4738, SR-4745, rdar://problem/31892961.
2017-05-08 23:04:37 -07:00