Commit Graph

123 Commits

Author SHA1 Message Date
Doug Gregor
d12dbf99ea [Type checker] Diagnose failed attempts to resolve associated type witnesses.
If unqualified name lookup finds an associated type, but resolution to
the type witness fails, produce a diagnostic rather than silently
failing. Fixes the crash in SR-5825, SR-5881, and SR-5905.

It's conceivable that we could resolve this with suitably global
associated type inference... but that's far off and it's best not to
crash until then.
2017-10-03 21:59:14 -07:00
Doug Gregor
9c3d6ce265 Add compiler crasher from SR-5825 2017-10-03 10:24:26 -07:00
Doug Gregor
19caa2027d Add failing test from rdar://problem/31164540. 2017-10-03 10:02:52 -07:00
Doug Gregor
2db79df9f5 Add crasher for rdar://problem/27383752. 2017-10-02 16:30:36 -07:00
Doug Gregor
e770910aad Add crashing test case for rdar://problem/26498438. 2017-10-02 16:22:03 -07:00
Doug Gregor
5426fe2b16 Resolve another fixed crasher. It also doesn't need to be a long test 2017-10-01 21:42:42 -07:00
Slava Pestov
044af751f3 Sema: Fix a failure to emit a diagnostic
CSDiag was misinterpreting the result of checkGenericArguments().

A result of SubstitutionFailure does not mean a diagnostic was
emitted, only a result of Failure means that. This fixes a case
where we did not emit a diagnostic, result in a crash on invalid.

The diagnostic is still poor, but that's better than crashing.

Fixes <https://bugs.swift.org/browse/SR-5932>,
<rdar://problem/34522739>.
2017-09-27 16:39:06 -07:00
Graydon Hoare
44b795dda5 Modify crasher for SR-5836 to require asserts 2017-09-07 10:04:36 -07:00
Mark Lacey
09846e0b68 Add a test for a crasher that was reported. 2017-09-05 12:42:52 -07:00
Maxim Moiseev
a5ff35cd41 [stdlib] extendingOrTruncating: => truncatingIfNeeded: 2017-07-26 11:09:36 -07:00
Doug Gregor
ac8e8aa1b3 [GSB] Stop creating unresolved potential archetypes; rework typo correction.
The small-but-significant change to the generic signature builder is
to refuse to create unresolved potential archetypes. Instead, delay
any requirement that depends on such type, to be reprocessed once
we've seen all of the other requirements. If the type can be resolved
later, it will be; Otherwise, the type checker will complain when it
sees an unresolvable type. By itself, this fixes the crash in SR-2796.

Doing this by itself regresses diagnostics because typo correction in
the generic signature builder no longer kicks in. Therefore, implement
typo correction for these cases in the type checker proper, using its
existing facilities for typo correction. The result is more consistent
code with a better result.

Fixes SR-2796 / rdar://problem/28544316.
2017-06-29 16:52:46 -07:00
Doug Gregor
c1cb8eb9a2 Reinstate crasher from SR-4737 / rdar://problem/31905232.
It was failing to crash for the wrong reasons; this needs more work
(and a proper reduction).
2017-06-28 09:41:06 -07:00
Doug Gregor
dd3869739e [GSB] Don't add invalid concrete requirements.
When a concrete requirement is invalid due to the concrete type
lacking a conformance to a particular, required protocol, don't emit
that incorrect requirement---it causes invalid states further down the
line.

Fixes SR-5014 / rdar://problem/32402482.

While here, fix a comment that Huon noticed trailed off into oblivion.
2017-06-23 22:23:46 -07:00
Doug Gregor
52e52b564b [GSB] Improve handling of conformances resolved by concrete types.
Centralize and simplify the handling of conformance requirements
resolved by same-type-to-concrete requirements in a few ways:

* Always store a ProtocolConformanceRef in via-superclass and
  via-concrete requirement sources, so we never lose this information.

* When concretizing a nested type based on its parent, use the
  via-concrete conformance information rather than performing lookup
  again, simplifying this operation considerably and avoiding
  redundant lookups.

* When adding a conformance requirement to a potential archetype that
  is equivalent to a concrete type, attempt to find and record the
  conformance.

Fixes SR-4295 / rdar://problem/31372308.
2017-06-23 09:34:57 -07:00
Doug Gregor
fe7ba8b79b [GSB] Pull typo correction for nested types into delayed reqs handling.
Rather than performing typo correction at the very end of finalize(),
do it as part of delayed requirement handling when we cannot otherwise
make progress. This is a cleaner way to cope with typo correction that
gives us a better chance of getting to a sane result.

Fixes rdar://problem/31048352 by eliminating the need for tracking the
number of unresolved potential archetypes altogether. Fixes
rdar://problem/32077627.
2017-06-19 22:47:33 -07:00
Slava Pestov
65c3565c2d Sema: Fix failure to produce diagnostics when 'is' casts are involved
When re-typechecking an expression during diagnostics, we begin by
erasing all the types in the expression. However, any expressions
created as part of applying the solution will remain.

CSGen was doing the wrong thing when it encountered EnumIsCaseExpr,
which can only appear in already-type checked ASTs.

Returning expr->getType() is not correct, because the type is not
yet set; returning a null type is intended to signal that a
diagnostic was already emitted, which causes Sema to stop
type checking.

The end result is that certain combinations of invalid code with
an 'is' cast nested inside would crash either the AST verifier
(with asserts on) or in SILGen (with asserts off), because we
would stop trying to diagnose the issue prematurely, and possibly
not emit a diagnostic at all.

Fixes <https://bugs.swift.org/browse/SR-5050> and
<rdar://problem/32487948>.
2017-06-13 20:19:43 -07:00
Ben Langmuir
f958566ba5 Add missing REQUIRES: asserts to crasher 2017-06-05 08:25:34 -07:00
Slava Pestov
945f6cfeb1 Add a fixed crasher and an unfixed one 2017-06-02 20:43:27 -07:00
Ben Langmuir
1cab613fa9 [test] Mark two crashers with REQUIRES: asserts 2017-05-30 10:36:16 -07:00
Pavel Yaskevich
9c1e9756e4 Merge pull request #9971 from xedin/sr-4301
[QoI] Fix crash when constructing existential metatype without '.init'
2017-05-29 23:16:45 -07:00
Pavel Yaskevich
29b8f5615d [QoI] Fix crash when constructing existential metatype without '.init'
Resolves: SR-4301.
2017-05-29 22:08:50 -07:00
Slava Pestov
5a894423fd Add a couple of crashers 2017-05-28 23:12:43 -07:00
Slava Pestov
a3ff37c1ad Add an unfixed crasher and two fixed ones 2017-05-23 23:14:10 -07:00
Slava Pestov
b5721e8d8e AST: Remove AnyObject protocol 2017-05-02 19:45:00 -07:00
Slava Pestov
3749a0066d Add a couple of crashers 2017-04-23 01:49:02 -07:00
Doug Gregor
8dfc25edc7 [GSB] Filter out conformance constraints derived from concrete conformance.
When an otherwise abstract conformance constraint is derived from a
concrete conformance, retain the abstract conformance by removing the
requirement source that involves the concrete conformance. This
eliminates our reliance on the concrete conformance, which is not
retained as part of the generic signature.

Fixes rdar://problem/31163470 and rdar://problem/31520386.
2017-04-16 23:05:23 -07:00
Doug Gregor
44c2f849d6 [Type checker] Continue validating requirements after an error.
We want to validate both type in same-type or conformance constraints,
even when the first type is ill-formed, so we don't leave null types
around for later phases to crash on.

Fixes rdar://problem/31093854.
2017-04-05 14:05:59 -07:00
Slava Pestov
9db6b10059 AST: Targeted fix for conformance lookup issue
When substituting a type like T.A.B where A and B are
associated types and the conformance requirement on T.A
is implied by conformance requirements on T, we would
crash.

The problem is that we have no way of representing an
abstract conformance with nested concrete types.

This patch adds a workaround that we can live with until
ConformanceAccessPaths are plumbed through all the way.

Fixes <rdar://problem/30737546> and
<https://bugs.swift.org/browse/SR-3500>.

Possibly fixes <rdar://problem/31334245>.
2017-04-03 15:35:10 -07:00
Slava Pestov
19b12aa3b1 Sema: Fix convenience init delegation to a convenience init in a generic base class
While in the constraint system, the delegation is modeled as
returning an instance of the derived class, in the AST we type
the reference as returning an instance of the base class, and
insert a downcast, because in SILGen we're calling the base
class initializer which is typed as returning the base class.

This bit of fixup logic wasn't happening if the base class was
generic, and so we were not inserting the cast, which would
crash in SILGen with an assert.

Fixes <rdar://problem/31000248>.
2017-03-26 00:00:53 -07:00
Slava Pestov
3ef5ef0ac9 Merge pull request #8232 from slavapestov/two-more-crashers
Last two crashers for the evening
2017-03-21 02:25:57 -07:00
Slava Pestov
e8413ba134 Merge pull request #8229 from slavapestov/another-protocol-typealias-crasher-yay
Add another crasher with protocol typealiases
2017-03-21 02:02:16 -07:00
Slava Pestov
6019754b54 Last two crashers for the evening 2017-03-21 01:45:53 -07:00
Slava Pestov
47a0cb1861 Add another crasher with protocol typealiases 2017-03-21 00:21:21 -07:00
Slava Pestov
a3a290eb60 Mangling: Fix bug in the logic for dropping same-type constraints
It's not correct to drop a constraint if one of the two types
structurally contains generic parameters at the method depth.
2017-03-21 00:15:18 -07:00
Slava Pestov
a3067a19bd Add a couple of crashers 2017-03-20 23:15:23 -07:00
John McCall
22382f7e15 Reimplement associated conformance IRGen using Doug's conformance
access path work.

Having done so, simplify archetype TypeInfos by removing a now-
unnecessary layer of abstraction.
2017-03-14 03:48:10 -04:00
Slava Pestov
9d22ff0edc Add a crasher 2017-02-26 22:17:31 -08:00
Slava Pestov
412c71d8c2 Add some crashers
One is already fixed so let's make sure it won't regress again; the
other two are pending some improvements to GenericSignatureBuilder.
2017-02-25 16:17:28 -08:00
Slava Pestov
5f9fe6fa2c SILGen: Fix crash with non-scalar casts requiring re-abstraction
This might only come up in invalid code, but for example
casting a function type to String would trigger it.
2017-01-03 19:05:41 -08:00
Slava Pestov
ad01c1e929 SILGen: Implement missing function conversions from tuples to Any
Fixes <https://bugs.swift.org/browse/SR-3267> and
<rdar://problem/22465834>.
2017-01-03 19:05:40 -08:00
Slava Pestov
e063e8297c Sema: Some fixes for the ITC
- In functions called from resolveType(), consistently
  use a Type() return value to indicate 'unsatisfied
  dependency', and ErrorType to indicate failure.

- Plumb the unsatisfiedDependency callback through the
  resolution of the arguments of BoundGenericTypes, and
  also pass down the options.

- Before doing a conformance check on the argument of a
  BoundGenericType, kick off a TypeCheckSuperclass request
  if the type in question is a class. This ensures we don't
  recurse through NominalTypeDecl::prepareConformanceTable(),
  which wants to see a class with a valid superclass.

- The ResolveTypeOfDecl request was assuming that
  the request was satisfied after calling validateDecl().
  This is not the case when the ITC is invoked from a
  recursive call to validateDecl(), hack this up by returning
  *true* from isResolveTypeDeclSatisfied(); otherwise we
  assert in satisfy(), and we can't make forward progress
  in this case anyway.

- Fix a bug in cycle breaking; it seems if we don't invoke
  the cycle break callback on all pending requests, we end
  up looping forever in an outer call to satisfy().

- Remove unused TR_GlobalTypeAlias option.
2016-12-09 17:36:49 -08:00
practicalswift
e8fad3a2a1 [gardening] Mark crash cases as fixed. 2016-12-09 21:46:43 +01:00
practicalswift
1d47f657eb [gardening] Rename and move crash case to correct dir.
* validation-test/compiler_crashers_2/ is recommended for manually added crashes like this one
* validation-test/compiler_crashers/ is synchronized against https://github.com/practicalswift/swift-compiler-crashes

This crasher was added in ff830ce4aa.
2016-12-08 18:22:11 +01:00
Pavel Yaskevich
d111e9b4be [Diagnostics] When building a subscript don't assume that overload is always present
This handles situation when overload for the subscript hasn't been resolved
by constraint solver, such might happen, for example, if solver was allowed to
produce solutions with free or unresolved type variables (e.g. when running diagnostics).

Resolves: <rdar://problem/27329076>, <rdar://problem/28619118>, <rdar://problem/2778734>.
2016-11-28 19:18:44 -08:00
David Farler
b7d17b25ba Rename -parse flag to -typecheck
A parse-only option is needed for parse performance tracking and the
current option also includes semantic analysis.
2016-11-28 10:50:55 -08:00
Jacob Bandes-Storch
a272b4640f [test] Add crasher in ResultPlanner::planTupleIntoIndirectResult 2016-11-24 14:14:09 -08:00
Daniel Duan
830c6de8be [crasher] add a crasher 2016-05-16 21:51:34 -07:00
Mark Lacey
eb1c4dc240 Fix two validation tests that require asserts. 2016-04-16 16:10:51 -07:00
Manav Gabhawala
7928140f79 [SE-0046] Implements consistent function parameter labels by discarding extraneous parameter names and adding _ where necessary 2016-04-06 20:21:58 -04:00
gregomni
e17e7ab8ae Make resolveTypeInContext for aliases just use interface type as dependent member.
Much cleane. Also fixes one more validation crasher.
2016-03-22 23:13:10 -07:00