Commit Graph

16 Commits

Author SHA1 Message Date
Chris Lattner
cf2e7f6f45 Fix SR-718: Type mismatch reported as extraneous parameter
The issue here is that the constraint solver was deciding on
FixKind::RelabelCallTuple as the fix for the problem and emitting the
diagnostic, even though there were two different fixes possible.

CSDiags has the infrastructure to support doing doing the right thing
here, but is only being used for ApplyExprs, not SubscriptExprs.

The solution is to fix both problems: remove FixKind::RelabelCallTuple,
to let CSDiags handle the problem, and enhance CSDiags to treat
SubscriptExpr more commonly with ApplyExpr.  This improves several cases
where the solver was picking one solution randomly and suggesting that
as a fix, instead of listing that there are multiple different solutions.
2016-02-12 17:19:54 -08:00
David Farler
3f635d04c7 Reinstante var bindings in refutable patterns, except function parameters.
This reverts commits: b96e06da44,
                      8f2fbdc93a,
                      93b6962478,
                      64024118f4,
                      a759ca9141,
                      3434f9642b,
                      9f33429891,
                      47c043e8a6.

This commit leaves 'var' on function parameters as a warning to be
merged into Swift 2.2. For Swift 3, this will be an error, to be
converted in a follow-up.
2016-01-29 15:27:08 -08:00
Chris Lattner
a5a988e726 Fix rdar://22509125 QoI: Error when unable to infer generic archetype lacks greatness
Rearrange diagnoseGeneralConversionFailure to diagnose structural problems
even if we have some UnresolvedTypes floating around, then reject constraint
failures with UnresolvedTypes in them even harder.  This keeps us giving
good errors about failures where we have a structural problem (with buried
irrelevant details) while not complaining about cases that are actually
ambiguous.

The end result of this is that we produce a lot better error messages in the
case of failed archetype inference.  This also highlights the poor job we do
handling multi-stmt closureexprs...
2016-01-11 20:45:11 -08:00
Slava Pestov
f6e4355b69 Sema: Fix monthly TypeNullifier bug
This time, the issue is that TypeNullifier skips bodies of
multi-statement closures. However, ExprRewriter will type
happily pass them on to typeCheckClosureBody(). This could
trigger assertions. Fix this by skipping type checking of
multi-statement closures when diagnosing.

There seems to be a minor QoI regression in some test cases
that already looked pretty dodgy and/or had FIXMEs. However
I think its worth fixing a crash.
2015-12-11 08:58:52 -08:00
Chris Lattner
4ebb461d63 Fix: <rdar://problem/23670252> QoI: Misleading error message when assigning a value from [String : AnyObject]
This teaches SubscriptExpr diagnostics to substitute the base type of a
subscript expr through the generic argument types, resolving achetypes in
common situations to concrete types.  We previously complained:

  error: cannot subscript a value of type '[String : AnyObject]' with an index of type 'String'

which is completely wrong, we now produce the correct error:

  error: cannot assign value of type 'AnyObject?' to type 'String?'
2015-12-07 17:28:16 -08:00
Chris Lattner
6636bafadf Fix <rdar://problem/23272739> Poor diagnostic due to contextual constraint
Previously we erroneously complained:
  error: cannot invoke 'contains' with an argument list of type '(String)'
now we correctly complain:
  error: unexpected non-void return value in void function

This enhances CSDiags to use "getTypeOfMember" when analyzing method
candidates that are applied to a known base type.  Using it allows us to
substitute information about the base, resolving archetypes that exist in
subsequent argument positions.  In the testcase, this means that we use
information about Set<String> to know that the argument to "contains" is a
String.

This allows us to generate much better diagnostics in some cases, and works
around some limitations in the existing stuff for handling unresolved
archetypes.  One unfortunate change is the notes in Misc/misc_diagnostics.swift.
Because we don't track argument lists very well, we are flattening an argument
list that is actually ((Int,Int)) into (Int, Int) so we get a bogus looking
diagnostic.  This was possible before this patch though, it is just one
more case that triggers the issue.
2015-12-01 21:22:24 -08:00
David Farler
93b6962478 Warn when using 'var' bindings in function parameters
These will no longer be allowed in a future Swift release.

rdar://problem/23172698
2015-11-03 17:24:20 -08:00
Chris Lattner
778d8d67e6 Use isUnresolvedOrTypeVarType more generally, and fix a crash on the new testcase, handling
unresolved subscript bases.


Swift SVN r31698
2015-09-04 23:03:11 +00:00
Chris Lattner
bb35cbcd38 Teach CSDiag how to resolve SubscriptMember locators, fixing
<rdar://problem/21364448> QoI: Poor error message for ambiguous subscript call

and improving several other subscript-related diagnostics.



Swift SVN r31082
2015-08-07 20:00:32 +00:00
Chris Lattner
6dc013ac8e testcase showing a poor diagnostic.
Swift SVN r31080
2015-08-07 19:45:15 +00:00
Chris Lattner
e4b6afb9ae Start moving the testsuite to the "_ = foo()" idiom for evaluating an
expression but ignoring its value.  This is the right canonical way to do
this.  NFC, just testsuite changes.



Swift SVN r28638
2015-05-15 20:15:54 +00:00
Chris Lattner
4366da9250 more testcase updates for upcoming diagnostics change.
Swift SVN r28409
2015-05-11 06:05:00 +00:00
Dmitri Hrybenko
3b04d1b013 tests: reorganize tests so that they actually use the target platform
Most tests were using %swift or similar substitutions, which did not
include the target triple and SDK.  The driver was defaulting to the
host OS.  Thus, we could not run the tests when the standard library was
not built for OS X.

Swift SVN r24504
2015-01-19 06:52:49 +00:00
Doug Gregor
9210cd5ff4 Replace T[] array syntax with [T] in the test suite
Swift SVN r19192
2014-06-25 23:39:24 +00:00
Ted Kremenek
fad874708e Adjust test cases.
Swift SVN r17964
2014-05-12 22:01:52 +00:00
Doug Gregor
1ea5b4d801 [Constraint application] Start weaning us from semaSubscriptExpr().
Handle the application of SubscriptExprs directly in constraint
application. This is the easy case.


Swift SVN r5147
2013-05-10 18:25:32 +00:00