Commit Graph

566 Commits

Author SHA1 Message Date
Chris Willmore
48987d6a20 Update validation test suite after fixing 21967211.
Commit da15fbf fixed 32 compiler crashers.
2015-11-10 23:09:54 -08:00
David Farler
a759ca9141 Disallow 'var' bindings in case patterns
Make the following illegal:

switch thing {
  case .A(var x):
    modify(x0
}

And provide a replacement 'var' -> 'let' fix-it.

rdar://problem/23172698

Swift SVN r32883
2015-10-25 18:53:02 +00:00
Doug Gregor
ea3d0b37bf Archetype builder: clean up typo correction and unresolved references.
When typo-correcting a potential archetype (i.e., a nested name
T.foo), record the rename within the potential archetype but don't
consider the signature to be invalid. Move the actual typo-correction
diagnostics and AST fix-ups outside of the archetype builder, so we
get proper Fix-Its and a correct generic signature. Fixes
rdar://problem/20789924.

Swift SVN r32677
2015-10-14 06:27:28 +00:00
Doug Gregor
70968a38fc Use the iterative type checker for TypeChecker::resolveInheritedProtocols.
Swift SVN r32564
2015-10-09 17:18:42 +00:00
Doug Gregor
f247447f03 Iterative type checker: compute inherited protocols of a protocol.
Introduce a type check request for computing inherited protocols and
start using it in a few places.

Swift SVN r32562
2015-10-09 17:18:40 +00:00
Doug Gregor
2feed84c91 Sketch out the interface to an iterative, lazy type checker.
This is all effectively NFC, but lays out the shape of the iterative
type checker: requests are packaged up in TypeCheckRequest, we can
check whether the request has been satisfied already (isSatisfied),
enumerate its dependencies (enumerateDependenciesOf) in terms of other
TypeCheckRequests, and satisfy a request (satisfy).

Lazily-computed semantic information is captured directly in the
AST, but has been set aside in its own structure to allow us to
experiment with moving it into a lookaside table.

The only request that exists now is to type-check the superclass of
the given class. It currently performs unhealthy recursion into the
existing type checker. As we detangle dependencies, this recursion
between the IterativeTypeChecker and the TypeChecker can go away.

Swift SVN r32558
2015-10-09 17:18:36 +00:00
Doug Gregor
34106f7f32 Include the Self type of a protocol type in the list of "all" generic arguments.
It's never bound, but this maintains invariants better and fixes a
number of crashes.

Swift SVN r32430
2015-10-04 06:18:15 +00:00
Doug Gregor
98dadc9800 Teach resolveTopLevelIdentTypeComponent not to modify the component.
Instead, always return the computed Type and let the caller deal with
it. NFC except for accidentally fixing a crasher.

Swift SVN r32377
2015-10-01 20:17:24 +00:00
Slava Pestov
69981a63eb Fix a handful of compiler_crashers were failing on OS X but passing on Linux
I'm too lazy to XFAIL: these, so fix the crash instead.

Swift SVN r32188
2015-09-23 22:27:36 +00:00
Slava Pestov
9fcf7f1bb9 Import latest compiler crashers and regressions from practicalswift
Swift SVN r32157
2015-09-22 21:08:21 +00:00
Doug Gregor
ca3e3968c6 Add back two recently-fixed tests that accidentally got unstaged.
Swift SVN r32019
2015-09-16 23:50:29 +00:00
Doug Gregor
cab320296d Stop recording protocol lists in nominal types.
The conformance lookup table is responsible for answering queries
about the protocols to which a particular nominal type conforms, so
stop storing (redundant and incorrect) protocol lists on the ASTs for
nominal types. Protocol types still store the list of protocols that
they inherit, however.

As a drive-by, stop lying about the number of bits that ProtocolDecl
uses on top of NominalTypeDecl, and move the overflow bits down into
ProtocolDecl itself so we don't bloat Decl unnecessarily.

Swift SVN r31381
2015-08-21 17:51:23 +00:00
Doug Gregor
f0fcd594c0 Stop using TypeDecl::Protocols within abstract type parameters.
More baby steps toward sinking protocol lists down into
NominalTypeDecl. Fixes another 12 crashers along the way.

Swift SVN r31333
2015-08-19 06:42:30 +00:00
Doug Gregor
f898887894 Eliminate getConformsTo() callback from the archetype builder.
The getConformsTo() callback was responsible for forcing the
collection of the requirements directly placed on an associated type,
which then get added to the archetype builder. This resulted in an
unhealthy dependency on the list of protocols attached to TypeDecl
(which should go away). Instead, retrieve the requirements from the
associated type's archetype (once it's been computed) or directly from
its list of "inherited" types (while we're building the generic
signature for the protocol itself).

Swift SVN r31332
2015-08-19 06:42:27 +00:00
Doug Gregor
dd93c6390b Teach name lookup to cope with missing archetypes on associated types.
Name lookup shouldn't even depend on such semantic information, but
this fixes 13 crashers.

Swift SVN r31331
2015-08-19 06:42:23 +00:00
Dmitri Hrybenko
ee20926b20 stdlib: rename join() to joinWithSeparator()
rdar://22022419, rdar://21474222

Swift SVN r31188
2015-08-12 21:16:38 +00:00
Chris Lattner
54ace2547f fix test, this actually successfully completes now.
Swift SVN r31137
2015-08-11 18:27:21 +00:00
Chris Lattner
654cb861ed fix <rdar://problem/21886435> Swift compiler crashes on "()=()"
... which was just a pair of over-conservative SILGen assertions.

This was our shortest practical swift crasher.



Swift SVN r31135
2015-08-11 17:41:44 +00:00
Chris Lattner
a899872d91 Reapply r31105, with some fixes to invalid unconstrained generics. These fixes correct
the regressions that r31105 introduced in the validation tests, as well as fixing a number
of other validation tests as well.

Introduce a new UnresolvedType to the type system, and have CSDiags start to use it
as a way to get more type information out of incorrect subexpressions.  UnresolvedType
generally just propagates around the type system like a type variable:
 - it magically conforms to all protocols
 - it CSGens as an unconstrained type variable.
 - it ASTPrints as _, just like a type variable.

The major difference is that UnresolvedType can be used outside the context of a
ConstraintSystem, which is useful for CSGen since it sets up several of them to 
diagnose subexpressions w.r.t. their types.

For now, our use of this is extremely limited: when a closureexpr has no contextual
type available and its parameters are invalid, we wipe them out with UnresolvedType
(instead of the previous nulltype dance) to get ambiguities later on.

We also introduce a new FreeTypeVariableBinding::UnresolvedType approach for
constraint solving (and use this only in one place in CSDiags so far, to resolve
the callee of a CallExpr) which solves a system and rewrites any leftover type 
variables as UnresolvedTypes.  This allows us to get more precise information out,
for example, diagnosing:

 func r22162441(lines: [String]) {
   lines.map { line in line.fooBar() }
 }

with: value of type 'String' has no member 'fooBar'
instead of: type of expression is ambiguous without more context

This improves a number of other diagnostics as well, but is just the infrastructural
stepping stone for greater things.





Swift SVN r31130
2015-08-11 06:06:05 +00:00
Slava Pestov
08f1421a5a Import latest compiler crashers from practicalswift
68% are already fixed, including all those marked as beta 4 regressions.

Swift SVN r30914
2015-08-01 08:31:45 +00:00
Chris Lattner
d3b1bcbd73 update validation tests for diagnostics changes.
Swift SVN r30906
2015-08-01 05:01:49 +00:00
Chris Lattner
4718f29742 testcase fixed by recent changes.
Swift SVN r30827
2015-07-31 00:15:43 +00:00
Jordan Rose
63b0cf6997 [test] Remove -verify from former compiler_crasher.
(changed in my previous commit)

Swift SVN r30699
2015-07-27 21:59:22 +00:00
Slava Pestov
ccf21ff90a Revert "Sema: Fix infinite recursion when associated type default references itself"
This reverts revision r30688. The patch needs more work, because it flags a
valid case as circular, see r15054, "Relax restriction on indirectly-self-
recursive protocol conformances.  (rdar://problem/16306715)".

Swift SVN r30690
2015-07-27 06:41:10 +00:00
Slava Pestov
29d3f8f400 Sema: Fix infinite recursion when associated type default references itself
Fixes <rdar://problem/20985232>.

Swift SVN r30688
2015-07-27 05:05:05 +00:00
Slava Pestov
1a34667419 AST: Fix a couple of crashes with nested generic types
- When we walk up through parent types of 'this', we also have to walk up
  the parent contexts of 'gpContext', otherwise an assertion fires.

- getSuperclass() needs to map generic type parameters of the parent
  type even if the superclass is not generic.

Swift SVN r30676
2015-07-27 00:40:43 +00:00
Slava Pestov
7dd472686a Sema: When recursively visiting a BoundGenericType, it may not have a generic signature yet
Let the original call diagnose any problems and just return successfully
without crashing.

Swift SVN r30675
2015-07-27 00:40:41 +00:00
Slava Pestov
7bca00afc1 Sema: When adding implicit constructors, bail out if superclass is invalid
Swift SVN r30674
2015-07-27 00:40:38 +00:00
Slava Pestov
5cc4f2b93d Sema: Use isTypeChecking() to avoid recursively validating EnumElementDecls
Validating the argument type might validate the enum decl in malformed (or
maybe even some valid?) code. We would call computeTwice() in this case,
leading to a crash.

Also clean up some test cases.

Swift SVN r30673
2015-07-27 00:40:37 +00:00
Chris Lattner
eff5cb3d48 remove a -verify line from a validation test.
Swift SVN r30663
2015-07-26 21:47:27 +00:00
Chris Lattner
b1f77b5b18 the default args recovery change fixed this crasher.
Swift SVN r30646
2015-07-26 02:29:16 +00:00
Slava Pestov
0af2b4709f Sema: Fix crash with protocol erroneously nested inside generic class
The protocol Self parameter is the last generic parameter in the signature,
not the first. While we don't allow protocols nested inside generic classes,
we would still crash in member type lookup from this.

Fixes <rdar://problem/21287703>.

Swift SVN r30635
2015-07-25 19:55:12 +00:00
Slava Pestov
e373a559c6 Sema: Fix type member lookup if generic signature validation fails
When validateGenericFuncSignature() returns true, finalizeGenericParamList()
is never called. Name lookup, via PartialGenericTypeToArchetypeResolver would
return a dependent member type of the generic type parameter type, not an
archetype as expected in this case. This would later on lead to a crash in
ReplaceDependentTypes if the function body contained a reference to such a
member type.

Fix this by marking the GenericTypeParamDecls as invalid in this case, and
returning an ErrorType from PartialGenericTypeToArchetypeResolver if given
an invalid GenericTypeParamDecl.

While we're at it, there was an unused isInvalid local variable in
TypeCheckDecl::visitFuncDecl(). It was written to but never read. Replace
the writes with calls to setInvalid().

Fixes <rdar://problem/19620340>.

Swift SVN r30632
2015-07-25 19:55:07 +00:00
Doug Gregor
902f486c16 Don't allow superclass constraints to involve type parameters.
Fixes the crash in rdar://problem/21268222; eventually, we can support
this.

Swift SVN r30585
2015-07-24 18:45:06 +00:00
Slava Pestov
abfcf63e7d Sema: Break recursion leading to 'Already set generic signature' crash
Swift SVN r30532
2015-07-23 06:49:21 +00:00
Slava Pestov
0033bda331 AST: Correct handling of ErrorType in TypeBase::getMemberSubstitutions()
Swift SVN r30531
2015-07-23 06:49:19 +00:00
Slava Pestov
226ada6fba Sema: The function may already have a type by this point
Swift SVN r30529
2015-07-23 06:49:13 +00:00
Luke Larson
eb8d11b48a 25847-emitsimpleassignment.swift crashes with -emit-silgen
Swift SVN r30506
2015-07-22 22:10:56 +00:00
Luke Larson
f15745b287 Add 622 new practicalswift tests
rdar://problem/21796335

Swift SVN r30504
2015-07-22 21:22:29 +00:00
Jordan Rose
a27bc42f44 [test] Unstick the Linux bot on compiler_crashers.
Neither of these crash on Linux any more.

Swift SVN r30448
2015-07-21 16:54:11 +00:00
Chris Lattner
db49e9fe49 -verify mode in compiler_crashers isn't a good use of broken bots.
Swift SVN r30440
2015-07-21 04:44:38 +00:00
John McCall
0ea7b2fba9 Fix some validation-test regressions, mostly by tweaking tests
but also by being a little more defensive during recovery.

Swift SVN r30424
2015-07-21 00:32:26 +00:00
Slava Pestov
6b7647c0a7 Sema: Don't set type of AssociatedTypeDecl until we have an archetype
Otherwise the verifier can crash because hasType() returns true but
getType() gives us a MetatypeType that hits a null pointer in
desugaring.

The computeType() calls appear in a few too many places for my liking;
would be nice to clean this up further or replace everything with
interface types one day.

Fixes <rdar://problem/19606899>.

Swift SVN r30388
2015-07-19 20:57:18 +00:00
Slava Pestov
e748908990 Sema: Don't set type of TypeAliasDecl until we resolve the alias type
This changes the behavior to match NominalTypeDecls, which don't have a type
until everything is set up either. In a few places we construct TypeAliasDecls
from known types directly, and we have to call computeType().

Fixes <rdar://problem/19534837>.

Swift SVN r30386
2015-07-19 20:55:53 +00:00
Slava Pestov
c83cc8ccd6 Parser: Fix a couple of crashes when parsing invalid enum cases
Also make some diagnostic wording more consistent.

Fixes <rdar://problem/19582394>.

Swift SVN r30300
2015-07-17 04:31:03 +00:00
Jordan Rose
7b37043857 Fix some but not all of the errors that had been fixed by the reverted commit.
...and regress a few cases that were previously passing. On the whole I think it's
a win, though.

Swift SVN r30296
2015-07-17 01:57:28 +00:00
Jordan Rose
2177a75b44 Revert "Validate decls before doing redeclaration checking."
It may fix a lot of crashers, but it breaks working code.

This reverts r30293.

Swift SVN r30294
2015-07-17 01:57:23 +00:00
Jordan Rose
6765a765a3 Validate decls before doing redeclaration checking.
This fixes a surprising number of compiler crashers. The reason this is an issue
at all is because we visit variables before their parent pattern binding decls.
(At least, that's one of the reasons...)

Swift SVN r30293
2015-07-17 00:22:24 +00:00
Chris Lattner
cf14158405 When type checking an arbitrary subexpression of the current node, we can run
into trouble when we dive into a subexpr of a ClosureExpr, because that subexpr
may refer to type variables on the closureexpr's parameters.

Check for this case, and refuse to dive into the subexpr in this case.  It would
be great to rewrite the closure parameter types to Type() or ErrorType or something
so that we can proceed even in this case, but this causes us to fail to catch
nested constraint checking failures.

This was figured out while working on other things, but fixes a validation test.



Swift SVN r30135
2015-07-13 05:34:31 +00:00
Chris Lattner
5b043a2e0a Fix <rdar://problem/21783334> compiler crashes on "{ x in x = 42"
which was the regression I introduced that broke "1616" out of the validation test.



Swift SVN r30123
2015-07-11 23:05:04 +00:00