as a proper error, and change it to not be incorrect. Multi-statement
closures *only* need a return type if they cannot be inferred.
This fixes:
<rdar://problem/22086634> "multi-statement closures require an explicit return type" should be an error not a note
Swift SVN r30937
Fix construction and simplication of constructor member locators, so
that locators involving constructor members can be simplified during
diagnosis.
<rdar://problem/21427130> Swift can't discriminate on arity of function parameters
Swift SVN r30932
Take expression depth and preorder traversal index into account when
deciding which unresolved overload to complain about, rather than giving
up if there are two exprs with the same number of overloads. Don't
consider solutions with fixes when emitting ambiguous-system
diagnostics.
Swift SVN r30931
down to call argument lists that have more than one operand (heavily leveraging
"computeTupleShuffle"). This resolves a great number of QoI radars, including
things like:
<rdar://problem/19981782> QoI: poor diagnostic for call to memcmp with UInt length parameter
where we used to produce:
error: cannot invoke 'memcmp' with an argument list of type '([UInt8], [UInt8], UInt)'
return memcmp(left, right, UInt(left.count)) == 0
^
note: expected an argument list of type '(UnsafePointer<Void>, UnsafePointer<Void>, Int)'
but now we produce:
error: cannot convert value of type 'UInt' to expected argument type 'Int'
return memcmp(left, right, UInt(left.count)) == 0
^~~~~~~~~~~~~~~~
which is more "to the point"
Swift SVN r30930
machinery, instead of in multiple places in CSSolver and CSDiags. This leads
to more predictable behavior (e.g. by removing the UnboundGenericParameter
failure kind) and eliminates a class of "'_' is not convertible to 'FooType'"
diagnostics.
Swift SVN r30923
other constraints intentionally ripped off, tell the recursive solution that
we can tolerate an ambiguous result. The point of this walk is not to
produce a concrete type for the subexpression, it is to expose any structural
errors within that subsystem that don't depend on the contextual constraints.
Swift SVN r30917
noescape/throws bits to avoid confusing the issue with folks who don't know that you can
pass a nothrow closure to a throw parameter (which are going to be pervasive in the
stdlib)
Swift SVN r30912
argument. For now we start with some of the most simple cases: single argument
calls. This dramatically improves the QoI for error messages in argument lists,
typically turning a error+note combo into a single specific error message.
Some minor improvements coming (and also generalizing this to n-ary calls), but it
is nice that all the infrastructure is starting to come together...
Swift SVN r30905
so we complain about 'nil' instead of NilLiteralConvertible. This doesn't have
much effect on the testsuite at the moment, but will when other changes land.
Swift SVN r30873
fixing <rdar://problem/22020088> QoI: missing member diagnostic on optional gives worse error message than existential/bound generic/etc
Swift SVN r30844
- Produce more specific diagnostics relating to different kinds of invalid
- add a testcase, nfc
- Reimplement FailureDiagnosis::diagnoseGeneralMemberFailure in terms of
Not including r30787 means that we still generate bogus diagnostics like:
[1, 2, 3].doesntExist(0) // expected-error {{type 'Int2048' does not conform to protocol 'IntegerLiteralConvertible'}}
But it is an existing and separable problem from the issues addressed here.
Swift SVN r30819
r30787 causes our tests to time out; the other commits depend on r30787.
Revert "revert part of my previous patch."
Revert "Produce more specific diagnostics relating to different kinds of invalid"
Revert "add a testcase, nfc"
Revert "- Reimplement FailureDiagnosis::diagnoseGeneralMemberFailure in terms of"
Revert "Fix places in the constraint solver where it would give up once a single "
Swift SVN r30805
member references:
- Use of instance members from types
- Use of type members from instances
- Use of mutating getters.
This surely resolves some radars, but I'll have to dig them out later.
Swift SVN r30796
performMemberLookup, eliminating a ton of duplicated logic, but keeping the
same general behavior.
- Now that r30787 landed, we can have diagnoseGeneralMemberFailure inform
clients when a member lookup fails due to referencing a candidate decl of
ErrorType (i.e, it is already invalid somehow). When this happens, there is
no reason to diagnose a problem, because the original issue has been diagnosed
and anything we produce now is just garbage.
The second point cleans up a bunch of bogus diagnostics in the testsuite, which are
*actually* due to upstream error that are already diagnosed.
Swift SVN r30789
"unavoidable failure" path, along with Failure::DoesNotHaveNonMutatingMember and
just doing some basic disambiguation in CSDiags.
This provides some benefits:
- Allows us to plug in much more specific diagnostics for the existing "only has
mutating members" diagnostic, including producing notes for why the base expr
isn't mutable (see e.g. test/Sema/immutability.swift diffs).
- Corrects issues where we'd drop full decl name info for selector references.
- Wordsmiths diagnostics to not complain about "values of type Foo.Type" instead
complaining about "type Foo"
- Where before we would diagnose all failures with "has no member named", we now
distinguish between when there is no member, and when you can't use it. When you
can't use it, you get a vauge "cannot use it" diagnostic, but...
- This provides an infrastructure for diagnosing other kinds of problems (e.g.
trying to use a private member or a static member from an instance).
- Improves a number of cases where failed type member constraints would produce uglier
diagnostics than a different constraint failure would.
- Resolves a number of rdars, e.g. (and probably others):
<rdar://problem/20294245> QoI: Error message mentions value rather than key for subscript
Swift SVN r30715
get the same wording, fixing <rdar://problem/21964599> Different diagnostics for the same issue
While I'm in the area, remove some dead code.
Swift SVN r30713
which we have a contextual type that was the failure reason. These are a bit
longer but also more explicit than the previous diagnostics.
Swift SVN r30669
version of the new CTP_ReturnStmt conversion, used to generate return-specific
diagnostics. Now that we have a general solution, we can just use that.
This improves diagnostics in returns for accessors, since they were apparently
not getting the bit set.
Swift SVN r30665
typeCheckExpression takes a convertType and a contextualType, but the only
client of contextualType is pattern binding initialization that wants to
provide a hint to the initializer, but the type may not be fully formed
(e.g. just Array instead of Array<Int>) so it can't provide a full
convertType to that type.
After trying various ways of eliminating the concept and failing, repaint it
instead: instead of typeCheckExpression taking *both* a convertType and a
contextualType (even though they are mutually exclusive), have it only take
a single convertType and add a bit to TypeCheckExprOptions to indicate whether
it is a hint or a strong conversion. This simplifies all the callers of
typeCheckExpression and makes further evolution simpler.
Swift SVN r30658
- Improve handling of if_expr in a couple of ways: teach constraint simplification
about IfThen/IfElse and teach CSDiags about the case when the cond expr doesn't match
BooleanType. This is rarely necessary, but CSDiags is all about cornercases, and this
does fix a problem in a testcase.
- Be a bit more specific about the constraint failure kind (e.g. say subtype) and when
we have a protocol conformance failure, emit a specific diagnostic about it, instead of
just saying that the types aren't convertible.
Swift SVN r30650
conversion failures, making a bunch of diagnostics more specific and useful.
UnavoidableFailures can be very helpful, but they can also be the first constraint
failure that the system happened to come across... which is not always the most
meaningful one. CSDiag's expr processing machinery has a generally better way of
narrowing down which ones make the most sense.
Swift SVN r30647
- Don't "aka" a Builtin.Int2123 type, it just makes a bad diagnostic worse.
- Split out the predicate that CSDiag uses to determine what a conversion
constraint is to a helper fn, and add subtype constraints to the mix.
- Move eraseTypeData into CSDiag (its own client) as a static function.
- Make eraseTypeData be a bit more careful about literals, in an attempt to
improve diagnostics when literals get re-type-checked. It turns out that
this still isn't enough as shown by the regression on the
decl/func/default-values.swift testcase, and the
Constraints/dictionary_literal.swift testcase where one bad diagnostic turns
into another different one, but I'll keep working on it.
- Beef up diagnoseContextualConversionError and the caller to it to be more
self contained and principled about the conversion constraints it digs out
of the system. This improves the diagnostics on a couple of cases.
Swift SVN r30642
setConversionType along with the constraints they install. The constraints
should be enough by themselves, and CSDiags shouldn't need them to
bias the solution.
Of course, the constraints weren't enough, so improve CSDiags so that it can
do the right thing without them.
Swift SVN r30636
directly into the diagnostics subsystem. This ensures a more consistent
treatment of type printing (e.g. catches a case where a diagnostic didn't
single quote the type) and gives these diagnostics access to "aka".
Swift SVN r30609