Commit Graph

103 Commits

Author SHA1 Message Date
Hamish Knight
c667d2b361 Use DefaultArgumentExpr for caller-side defaults
This commit changes how we represent caller-side
default arguments within the AST. Instead of
directly inserting them into the call-site, use
a DefaultArgumentExpr to refer to them indirectly.

The main goal of this change is to make it such
that the expression type-checker no longer cares
about the difference between caller-side and
callee-side default arguments. In particular, it
no longer cares about whether a caller-side
default argument is well-formed when type-checking
an apply. This is important because any
conversions introduced by the default argument
shouldn't affect the score of the resulting
solution.

Instead, caller-side defaults are now lazily
type-checked when we want to emit them in SILGen.
This is done through introducing a request, and
adjusting the logic in SILGen to be more lenient
with ErrorExprs. Caller-side defaults in primary
files are still also currently checked as a part
of the declaration by `checkDefaultArguments`.

Resolves SR-11085.
Resolves rdar://problem/56144412.
2019-11-20 15:07:32 -08:00
Robert Widmann
3f36ecf5ba Add a regression test for a GSB crasher
From rdar://56673657
2019-11-11 10:27:33 -08:00
Suyash Srijan
d311879122 [Test] Move test case to compiler crashers 2019-10-19 03:34:09 +01:00
Slava Pestov
5189daafd3 Add a couple of crashing test cases 2019-09-20 15:08:47 -04:00
Jorge Revuelta Herrero
cec0821220 Compiler crash for SR11108 2019-09-11 13:47:15 +02:00
Suyash Srijan
8c5730abe6 [Test] Fix incorrect SR number 2019-08-31 20:10:19 +01:00
Suyash Srijan
d576fc1b83 [Test] Add a compiler crasher 2019-08-31 20:03:06 +01:00
Arnold Schwaighofer
031dead69c Try to fix failure of this test on noasserts builds of the compiler
This test failed on the oss-swift_tools-R_stdlib-RD_test-simulator bot.

rdar://54707188
2019-08-26 08:19:26 -07:00
Greg Titus
3556fdf557 Sample test in compiler_crashers for sr-11232. 2019-08-24 08:56:06 -07:00
Slava Pestov
e0c29408eb This test only fails when asserts are on 2019-03-06 15:42:14 -05:00
Slava Pestov
c47683cdeb Add failing test case for GSB bug 2019-03-01 21:01:51 -05:00
Greg Titus
c7ae3e6736 Crasher fixed. 2018-10-13 20:13:35 -07:00
Doug Gregor
92d622ab41 [Type checker] Eliminate TypeResolverContext::GenericSignature.
The name-lookup behavior that avoids looking for members of a nominal type
or extension therefore when resolving the inheritance clause is now
handled by UnqualifiedLookup, so remove it from the type checker itself.

Fixes rdar://problem/39130543.
2018-08-14 23:17:57 -07:00
Robert Widmann
0b33a69540 Merge pull request #17195 from brentdax/label-fable
Implicit tuple interpolations, take two
2018-06-18 15:54:30 -07:00
Doug Gregor
ef337bb8ba [Evaluator] Use the request-evaluator for the superclass of a class.
Wire up the request-evaluator with an instance in ASTContext, and
introduce two request kinds: one to retrieve the superclass of a class
declaration, and one to compute the type of an entry in the
inheritance clause.

Teach ClassDecl::getSuperclass() to go through the request-evaluator,
centralizing the logic to compute and extract the superclass
type.

Fixes the crasher from rdar://problem/26498438.
2018-06-14 15:28:36 -07:00
Brent Royal-Gordon
27dfa51be5 Wrap interpolated tuples in parens
Keeps them from being interpreted as parameter lists. Fixes SR-7958.
2018-06-13 22:55:48 -07:00
Robert Widmann
dfe42d2e55 Revert "Reject bad string interpolations (#17074)"
This reverts commit fc23f3404d.
2018-06-13 15:06:33 -07:00
Brent Royal-Gordon
fc23f3404d Reject bad string interpolations (#17074)
* Reject bad string interpolations

String interpolations with multiple comma-separate expressions or argument labels were being incorrectly accepted.

* Tweak error name to match message

* Diagnose empty interpolations more clearly

* Don’t double-diagnose parse errors

Fixes a test at Parse/recovery.swift:799 which the previous commit broke.

* Fix incorrect test RUN: line

A previous version of this test used FileCheck instead of -verify, and the run line wasn’t properly corrected to use -verify.

* Update comment

* Add more argument label tests

Ensures that we don’t get different results from an initializer that doesn’t exist or doesn’t take a String.

* Resolve the SR-7958 crasher test

We now diagnose the error and remove the label before it has an opportunity to crash.
2018-06-12 18:46:52 -07:00
Brent Royal-Gordon
16cc543eb3 Correct run line on unfixed crasher 2018-06-10 22:52:03 -07:00
Brent Royal-Gordon
2e8d0925fb Add reduced crasher for SR-7958
Trying to use an argument label in an interpolation can cause various crashes. In swiftlang-1000.0.16.7, these are usually in SILGen; in master at 8f6028d, they’re in CSApply.
2018-06-10 21:44:24 -07:00
Pavel Yaskevich
11ba7e0f42 [CSSimplify] When trying to simplify bind with error type fail gracefully
Since member lookup doesn't check requirements
it might sometimes return types which are not
visible in the current context e.g. typealias
defined in constrained extension, substitution
of which might produce error type for base, so
assignement should thead lightly and just fail
if it encounters such types.

Resolves: rdar://problem/39931339
Resolves: SR-5013
2018-05-28 00:24:54 -07:00
Doug Gregor
8d2ca387ef The test case from rdar://problem/31164540 is also fixed. 2018-04-20 11:15:22 -07:00
Slava Pestov
6f65d3d0a2 compiler_crashers_2/0153-rdar39130543.swift requires asserts 2018-04-19 14:09:56 -07:00
Doug Gregor
fec93f991c Add reduced, crashing test case for rdar://problem/39130543. 2018-04-16 11:25:34 -07:00
Huon Wilson
d33a5c16f2 [Sema] Explicit error for "extension GenericClass : ObjcProtocol".
If there was any requirements in the @objc protocol, the user got an error in
some form (a complaint about those requirements), but giving the direct error is
better, and handles @objc protocol with no requirements.

Also, fix a hole in that existing @objc method check: in `class Outer<T> { class
Inner {} }`, Inner should be considered generic, but the loop that was checking
for this didn't consider it.

Fixes https://bugs.swift.org/browse/SR-7370 and rdar://problem/39239512.
2018-04-13 08:09:02 +10:00
Slava Pestov
e1f50b2d36 SE-0193: Rename @_inlineable to @inlinable, @_versioned to @usableFromInline 2018-03-30 21:55:30 -07:00
Arnold Schwaighofer
66a2f5d05d Disable test that fails on linux asan bot
rdar://26498438
2017-11-27 14:35:06 -08:00
Slava Pestov
ccfa6e43f5 Add a crasher 2017-11-01 21:48:07 -07:00
Jordan Rose
dab697186b [test] Mark this recently-added crasher as requiring assertions. (#12284)
Added in Doug's f0e244cc.
2017-10-04 19:22:37 -07:00
Doug Gregor
b42585b98d Add crashing test case from SR-5546. 2017-10-04 10:51:55 -07:00
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