Commit Graph

1575 Commits

Author SHA1 Message Date
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
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
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
Chris Lattner
63290f1f15 my diagnostics changes have provoked a preexisting CSGen crash regressing this test, move it until I can investigate.
Swift SVN r30119
2015-07-11 22:02:28 +00:00
Doug Gregor
03b1afce06 Don't revert the generic parameter list unless we're going to fill it in.
Fixes the crasher in rdar://problem/20000145 and 14 other compiler
crashers.

Swift SVN r29973
2015-07-08 13:13:17 +00:00
Doug Gregor
c410bce986 We cannot validate a declaration while its context is being type-checked.
Fixes rdar://problem/21538521 and a few crashers.

Swift SVN r29957
2015-07-08 04:21:51 +00:00
Doug Gregor
31787b66ee Generalize the "is being type checked" check to consider the type context.
Fixes 22 crashers.

Swift SVN r29948
2015-07-07 23:38:16 +00:00
Slava Pestov
9fb2080a94 Parser: Fix AST verifier failure with missing braces on struct and enum decls
Looks like classes were alrady doing the right thing.

Once again my fat fingers lead me to fix a compiler_crasher.

Swift SVN r29947
2015-07-07 21:44:59 +00:00
Slava Pestov
bb064da539 Sema: Fix AttributeChecker crash if getDeclaredTypeInContext() returns an ErrorType
Fixes <rdar://problem/21551616>.

Swift SVN r29943
2015-07-07 21:12:16 +00:00
Chris Lattner
8637bb4c01 fix <rdar://problem/21679169> compiler crashes on "{(=_=_)in"
Swift SVN r29914
2015-07-06 04:46:56 +00:00
Slava Pestov
6992dfc5d1 AST: Start unifying UnqualifiedLookup and lookupVisibleDecl()
For now, just update NameLookup's FindLocalVal to use a
VisibleDeclConsumer just like lookupVisibleDecl().

A subsequent patch will continue removing duplicated code
now that this is place.

This fixes compiler crashers where we were not handling
declarations with duplicate names (which of course is an
error, diagnosed elsewhere).

Swift SVN r29913
2015-07-04 01:53:38 +00:00
Slava Pestov
b03a77f13c Sema: Fix some compiler crashes related to ErrorType handling
- NominalTypeDecl::computeInterfaceType() crash when parent decl
  has error type
- createMaterializeForSetPrototype() crash when parent decl
  has error type
- Crashes in ConformanceChecker when decl has error type

Fixes <rdar://problem/21583601>.

Swift SVN r29912
2015-07-04 01:53:36 +00:00
Doug Gregor
8f31e03ebd Completely check the requirements of a protocol as part of validation.
We were doing piecemeal checking of the requirements of specific
associated type bindings, but such checking is incomplete: superclass
constraints and, although currently inexpressible, same-type
constraints are not validated by these early checks, so this is more
correct and more robust.

Swift SVN r29808
2015-06-30 21:11:20 +00:00
Doug Gregor
8a26662368 Use the generic signature to check specialized uses of generic types.
Previously, we were simply walking over the requirements of each of
the associated types, which meant that we weren't considering
same-type constraints. Also cleans up the diagnostics a little bit and
eliminates some extra computation whose results were getting thrown
away.

Swift SVN r29793
2015-06-29 22:06:19 +00:00
Dmitri Hrybenko
51e236c609 stdlib: rename Array's generic parameter from T to Element
Same for ArraySlice and ContiguousArray.

Part of rdar://21429126

Swift SVN r29618
2015-06-24 20:41:49 +00:00
Doug Gregor
54979b70a7 Remove uses of complete-unnamed function parameters from the testsuite.
Support for "func f(Int)" is going away.

Swift SVN r29608
2015-06-24 16:01:37 +00:00
Chris Lattner
9a65afff8d Two changes:
- In name lookup, if we find a decl that is already being type checked 
   (which only occurs on illegal code) just assume it is acceptable instead
   of blowing up with an assertion checking access control that hasn't been
   evaluated yet.
 - In checkInheritanceClause, make sure that the we mark the decl being
   resolved as being type checked when resolving the types involved.  That way,
   cyclic references are detected as invalid, instead of causing assertions and
   other explosions.

This fixes some compiler crashers.



Swift SVN r29538
2015-06-20 23:50:31 +00:00
Chris Lattner
0e20f24b95 fix <rdar://problem/18734297> Reject access to local variables from local types
init()'s implicitly evaluate the initial values for properties, and we aren't modeling
that correctly in the AST.  This prevented the closure checker from noticing these 
accesses, leading to SILGen crashing later.  In the absence of proper AST modeling of
this, add special case handling for them.



Swift SVN r29508
2015-06-19 06:15:19 +00:00
Slava Pestov
9deaf6c851 Sema: Fixes for partial application of protocol methods
Previously the placement of the OpenExistentialExpr was determined
entirely from the natural argument count of the function.

There was a hack to add any missing OpenExistentialExprs at the top
level, but this didn't work if the method had a Self return value
and there were intermediate expressions, eg, if someMethod has a
Self return, foo(anExistential.someMethod) would generate a
diagnostic about open existentials.

Change ExprRewriter to use a new existential placement algorithm
that instead walks up the expression stack to determine the outermost
function application of an existential base, and insert the
OpenExistentialExpr there.

Progress on <rdar://problem/21289579>.

Swift SVN r29448
2015-06-17 07:42:47 +00:00
Slava Pestov
6a9790ed30 Sema: Fix compiler_crasher with FixKind::ForceOptional
We were using getRValueType() and getRValueObjectType() when
setting up the constraint, but getRValueType() when simplifying
it. This led to a crash if the type was a single-argument tuple
with a named argument.

Swift SVN r29376
2015-06-15 02:00:46 +00:00
Slava Pestov
9e1f0c3855 Sema: Fix a compiler_crash when the generic signature is invalid
We might still try to call getDeclaredType(), which would
unexpectedly return nullptr.

Swift SVN r29358
2015-06-10 01:18:21 +00:00
Dmitri Hrybenko
d464a638f2 Annotate 0803-void.swift as passing on Linux
Swift SVN r29350
2015-06-08 08:59:57 +00:00
Slava Pestov
6550c7a858 Sema: Fix subtyping between metatypes and existential metatypes
X.Protocol is an instance of Y.Type only if X conforms to Y. Since X
is a protocol, this is only true if X contains Y and Y is
self-conforming.

Note that this updates some tests that actually contained invalid code.

Fixes <rdar://problem/20915927>.

Swift SVN r29349
2015-06-08 07:59:16 +00:00
Joe Groff
d9fbef1f2f Resolve fixed crashers.
Swift SVN r29348
2015-06-08 05:47:19 +00:00
Slava Pestov
fee95a3c06 AST: Fix a compiler_crash
Swift SVN r29341
2015-06-08 04:00:22 +00:00
Slava Pestov
0c88c13c0d IRGen: Brazenly nuke -enable-dynamic-value-type-layout flag
The last remaining case was apparently @objc generic classes, which
seem to work now.

Also nuke the IRGen/unimplemented_objc_generic_class.swift test,
this is now implemented and we have other tests that test this
functionality.

Swift SVN r29260
2015-06-03 00:01:29 +00:00
Jordan Rose
2cd2d9ceb2 [test] Remove XFAIL lines from still-crashing compiler_crashers.
This is handled by the directory's lit.local.cfg.

Swift SVN r29238
2015-06-02 17:45:20 +00:00
Chris Lattner
b6a15d6828 My error recovery fix improved types, likely because something wasn't handling a tok::invalid correctly.
Swift SVN r29225
2015-06-02 05:02:53 +00:00
Doug Gregor
bf310f5e1a Compute outer generic parameters even when 'self' already has a type.
Resolves a few compiler crashes on invalid. One could imagine this
triggering on well-formed code, but I was unable to form such a test
case.

Swift SVN r29149
2015-05-29 17:54:25 +00:00
Ted Kremenek
dad92b0084 Revert "IRGen: Brazenly nuke -enable-dynamic-value-type-layout flag"
Speculatively reverting because the iOS bots are broken.

Swift SVN r29145
2015-05-29 14:11:25 +00:00
Slava Pestov
9da369b5ba IRGen: Brazenly nuke -enable-dynamic-value-type-layout flag
The last remaining case was apparently @objc generic classes, which
seem to work now.

Also nuke the IRGen/unimplemented_objc_generic_class.swift test,
this is now implemented and we have other tests that test this
functionality.

Swift SVN r29138
2015-05-29 06:19:06 +00:00
Doug Gregor
a3f01190f3 Fill in nested types of an opened existential type.
We only attempt to access such nested types in ill-formed code, but
this helps maintain AST invariants. Fixes rdar://problem/20593294 and
resolves 18 compiler crashers.

Swift SVN r29135
2015-05-29 05:47:28 +00:00
Doug Gregor
3b7c0d446a Switch unqualified lookup over to the LookupResultBuilder.
Unifies the handling of witnesses in unqualified and qualified name
lookup, mostly.

Swift SVN r29081
2015-05-27 21:29:55 +00:00
Ben Langmuir
190208b187 Update compiler crashers after r29031
The aforementioned commit didn't really fix the problem, but it happened
to avoid the crash, so I've tweaked the tests to continue crashing.  In
order to keep in sync with upstream practical swift, I renamed the
tweaked tests and copied the original ones into "fixed".

Swift SVN r29033
2015-05-26 17:48:07 +00:00