Commit Graph

227 Commits

Author SHA1 Message Date
Chris Lattner
9b5fa7935c Merge pull request #924 from jtbandes/fix-curriedself
[Sema] Fix crash in addCurriedSelfType
2016-01-09 11:18:58 -08:00
Jacob Bandes-Storch
b97cb48c2b [AST] Fix inconsistent handling of generic args & params during BoundGenericType::getSubstitutions
A decl’s full GenericSignature is set during validateGenericTypeSignature().

Then during ConstraintSystem::openTypes(), in ReplaceDependentTypes, the GenericArgs list is built from the generic signature (via getGenericParamTypes()) and passed into a new BoundGenericType.

In BoundGenericType::getSubstitutions(), the GenericArgs are assumed to match getGenericParamsOfContext()->getParams().

However, in reality, the GenericArgs include all levels of generic args, whereas getGenericParamsOfContext() are the params of the innermost context only, so the params array is accessed past its end.

This commit changes NominalTypeDecl::getGenericParamTypes() to return the innermost params, in order to match the output of BoundGenericType::getGenericArgs(). For clarity and to hopefully prevent future confusion, we also rename getGenericParamTypes() to getInnermostGenericParamTypes().
2016-01-09 02:19:28 -08:00
Chris Lattner
675ca03b12 fix a compiler crasher that practicalswift recently found. 2016-01-08 23:03:18 -08:00
Jacob Bandes-Storch
ce2f5d6ba8 [Sema] Skip ErrorTypes in potential bindings during constraint solving 2016-01-08 22:45:52 -08:00
Jacob Bandes-Storch
824c1c043b [Sema] Fix crash in addCurriedSelfType
isGenericContext() returning true doesn’t necessarily imply that getGenericSignature() returns non-null. getGenericSignatureOfContext() performs a traversal equivalent to isGenericContext(), so we use it instead.
2016-01-08 22:08:46 -08:00
Jacob Bandes-Storch
8cc8c5cc22 [Sema] Improve handling of invalid protocols during conformance checking 2016-01-08 00:27:24 -08:00
Doug Gregor
1a38e0ad3b Merge branch 'master' into swift-3-api-guidelines 2016-01-06 15:32:55 -08:00
Chris Willmore
589a46f9ba Merge pull request #858 from jder/vararg-tuple-conversion-for-args-only
[SR-433][Sema] Don't produce vararg tuples outside of arglists
2016-01-05 17:39:17 -08:00
Max Moiseev
f51e708a8f Merge remote-tracking branch 'origin/master' into swift-3-api-guidelines 2016-01-04 12:25:25 -08:00
Jesse Rusak
63faeac77c [SR-433][Sema] Don't produce vararg tuples outside of arglists
Previously, we could produce such a tuple shuffle for non-arg
tuples, which would trigger an assert in SILGen.
2016-01-02 15:37:42 -05:00
Chris Lattner
5ce3de8dd6 remove & dial back three old bits of syntax auto-upgrading support:
1. Array type parsing for postfix array types Int[].  We now handle this
   in the parser, but remove the AST representation of this old form.  We
   also stop making vague promises about the future by saying that "fixed
   size arrays aren't supported... yet".  Removal of this fixes a compiler
   crasher too.

2. Remove the special case support for migrating @autoclosure from types
   to parameters, which was Swift 1.0/1.1 syntax.  The world has moved or
   we don't care anymore.

3. Remove upgrade support for # arguments (nee "backtick" arguments), which
   was a Swift 1.x'ism abolished in an effort to simplify method naming
   rules.

NFC on valid code.
2015-12-31 22:29:39 -08:00
practicalswift
48c40de31e Sync with https://github.com/practicalswift/swift-compiler-crashes
Add 2 compiler crashes (+ 1 fixed crash).
2015-12-27 19:35:50 +01:00
Doug Gregor
cd1c106e35 Merge remote-tracking branch 'origin/master' into swift-3-api-guidelines 2015-12-18 15:45:48 -08:00
Doug Gregor
3ba3bd359b Merge pull request #620 from jtbandes/member-fix
More error checking for member type lookup
2015-12-18 10:49:06 -08:00
Doug Gregor
a97ab6dd14 Merge remote-tracking branch 'origin/master' into swift-3-api-guidelines 2015-12-18 10:15:47 -08:00
Chris Willmore
92d230993a Merge pull request #619 from jtbandes/subscript-fix
Propagate ErrorType when checking subscript decls
2015-12-17 17:25:22 -08:00
Doug Gregor
824088a07d Merge remote-tracking branch 'origin/master' into swift-3-api-guidelines 2015-12-17 15:50:24 -08:00
Dmitri Gribenko
e31aae83ae Remove 'REQUIRES: asserts' from fixed crash tests: they don't crash anymore in any configuration 2015-12-17 14:54:32 -07:00
Max Moiseev
3fe0c60d7f Merge remote-tracking branch 'origin/master' into swift-3-api-guidelines 2015-12-17 11:00:02 -08:00
Jacob Bandes-Storch
ac95c1318f More error checking for member type lookup 2015-12-17 01:50:53 -08:00
Jacob Bandes-Storch
37207165f0 More error checking for subscript decls 2015-12-17 00:40:01 -08:00
Slava Pestov
d6ea5d8717 Sema: Chain all generic parameter lists
Previously, methods on DeclContext for getting generic parameters
and signatures did not walk up from type contexts to function
contexts, or function contexts to function contexts.

Presumably this is because SIL doesn't completely support nested
generics yet, instead only handling these two special cases:

- non-generic local function inside generic function
- generic method inside generic type

For local functions nested inside generic functions, SIL expects
the closure to not have an interface type or generic signature,
even if the contextual type signature contains archetypes.
This should probably be revisited some day.

Recall that these cases are explicitly rejected by Sema diagnostics
because they lack SIL support:

- generic function inside generic function
- generic type inside generic function

After the previous patches in this series, it becomes possible to
construct types that are the same as before for the supported uses of
nested generics, while introducing a more self-consistent conceptual
model for the unsupported cases.

Some new tests show we generate diagnotics in various cases that
used to crash.

The conceptual model might still not be completely right, and of
course SIL, IRGen and runtime support is still missing.
2015-12-16 11:32:56 -08:00
Max Moiseev
2021dd5a4d Merge remote-tracking branch 'origin/master' into swift-3-api-guidelines 2015-12-15 12:49:22 -08:00
Slava Pestov
57dfb45ba6 Sema: Add DeclContext::isGenericTypeContext()
Once nested generic parameter lists are properly chained, we need a
way of checking if we're inside a generic type context that's
distinct from just checking if we have a generic type signature
available.

This distinguishes between these two cases:

class A<T> {
  // generic signature
  func method() -> T { // <T> A<T> -> () -> T
  }
}

func f<T>() {
  class A {
    // no generic signature
    func method() -> T { // A -> () -> T
    }
  }
}
2015-12-14 13:46:45 -08:00
Slava Pestov
c258f991f6 Sema: Nuke NominalTypeDecl::markInvalidGenericSignature()
This would just set the NominalTypeDecl's declared type to
ErrorType, which caused problems elsewhere.

Instead, generalize the logic used for AbstractFunctionDecl.
This correctly wires up the GenericTypeParamDecl's archetypes even
if the signature didn't validate, fixing crashes if the generic
parameters of the type are referenced.
2015-12-14 13:29:55 -08:00
Slava Pestov
d56cbfaaf9 Sema: Check generic parameter inheritance clause after creating archetype
This fixes a crash with invalid code where the inheritance clause
refers back to itself, eg struct E<F : F.A> {}.
2015-12-14 13:29:52 -08:00
Max Moiseev
806be29941 Merge remote-tracking branch 'origin' into swift-3-api-guidelines 2015-12-14 12:05:35 -08:00
Jacob Bandes-Storch
1b142ed054 Add missing setIsParseError() during enum case parsing
An invalid `case` construct would incorrectly return a successful status, causing `parseDecl` to crash later when it assumed there were valid decls in the `Entries` vector.
2015-12-13 13:11:22 -08:00
Max Moiseev
786e1ea2b1 Merge remote-tracking branch 'origin' into swift-3-api-guidelines 2015-12-11 15:19:02 -08:00
Dmitri Gribenko
06d6dab133 Merge pull request #438 from practicalswift/sync-with-swift-compiler-crashes-20151211
Sync with https://github.com/practicalswift/swift-compiler-crashes
2015-12-11 14:42:05 -08:00
Doug Gregor
851f2eaf60 Merge pull request #272 from jtbandes/fix3
[AST] Improve ErrorType handling in TypeBase::getMemberSubstitutions()
2015-12-11 13:55:59 -08:00
Doug Gregor
53b1503a78 Merge pull request #253 from jtbandes/master
Fix crash in `DependentGenericTypeResolver::resolveDependentMemberType`
2015-12-11 13:53:01 -08:00
practicalswift
fe2bc2421e Sync with https://github.com/practicalswift/swift-compiler-crashes
Add 5 compiler crashes (+ 1 fixed crash).
2015-12-11 21:35:06 +01: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
Maxim Moiseev
2c95bb6d51 BooleanType => Boolean 2015-12-10 14:56:32 -08:00
Jacob Bandes-Storch
61dea21228 Fix crash in DependentGenericTypeResolver::resolveDependentMemberType
An erroneous `baseTy` would cause resolveArchetype to return nullptr, resulting in a null dereference.
2015-12-10 14:52:53 -08:00
Dmitri Gribenko
21f081fc1a Merge pull request #405 from practicalswift/normalize-run-directives
Compiler crashers: Normalize format of "RUN:" directives.
2015-12-10 14:36:19 -08:00
Dmitri Gribenko
5995ef2acd Mark one crasher test as fixed on OS X 2015-12-10 14:30:17 -08:00
practicalswift
eae3eea17f Compiler crashers: Normalize format of "RUN:" directives.
Will allow for easy parsing of common "RUN:" directives.
2015-12-10 22:58:00 +01:00
Jacob Bandes-Storch
71b15e9a06 [AST] Improve ErrorType handling in TypeBase::getMemberSubstitutions()
Historical note: a similar change was made in 0033bda.
2015-12-10 13:11:06 -08:00
Dmitri Gribenko
3e5ce67605 Merge pull request #398 from practicalswift/rename-to-match-naming-in-swift-compiler-crashes
Rename old crash cases to match the current naming scheme.
2015-12-10 13:02:21 -08:00
Max Moiseev
d610fa0d1c Merge remote-tracking branch 'origin' into swift-3-api-guidelines 2015-12-10 10:29:52 -08:00
practicalswift
6029492e9f Remove since identical with 01739-swift-constraints-constraintsystem-solvesimplified.swift. 2015-12-10 17:03:34 +01:00
practicalswift
d132d07b53 Remove since identical with 00924-swift-parser-consumetoken.swift. 2015-12-10 17:02:33 +01:00
practicalswift
dc5a6a740f Remove since identical with 00805-swift-constraints-constraintsystem-opengeneric.swift. 2015-12-10 17:01:30 +01:00
practicalswift
7efd093c6f Remove since identical with 0035-cerror.swift. 2015-12-10 17:00:04 +01:00
practicalswift
c4866885c8 Rename old crash cases to match the current naming scheme.
Will allow for easy import of crash cases from swift-compiler-crashes.
2015-12-10 16:50:15 +01:00
Maxim Moiseev
844b81c46b SequenceType => Sequence 2015-12-09 17:16:56 -08:00
Maxim Moiseev
09a6913622 RangeReplaceableCollectionType => RangeReplaceableCollection 2015-12-09 17:13:08 -08:00
Maxim Moiseev
7e2466c14e CollectionType => Collection 2015-12-09 17:12:48 -08:00