Commit Graph

716 Commits

Author SHA1 Message Date
Matthew Carroll
6285579855 Remove the expectation of this test crashing, and move it into the compiler crashers fixed test suite.
The crash was fixed accidentally in 93a7a9f80d.
2017-01-22 13:20:04 -05:00
practicalswift
23d53a3a4a Remove REQUIRES annotation from fixed crashers. 2017-01-21 10:32:59 +01:00
Pavel Yaskevich
671d470322 [Diagnostics] Don't attempt member lookup if base type has unresolved type parameters
If there are unresolved generic parameters present and we are trying
to diagnose problems related to initializer call, it makes sense to
check argument expression first, which might be erroneous and then move
on to the ambiguity checking instead of trying to lookup possible
constructors directly.
2017-01-19 14:01:57 -08:00
practicalswift
39a35729ef Mark previously non-deterministic crashers as fixed. 2017-01-18 10:29:12 +01:00
swift-ci
36ab93a95d Merge pull request #6860 from DougGregor/optional-conversions 2017-01-17 15:11:12 -08:00
Doug Gregor
ecfea608db [Type checker] Classify the various optional conversion kinds.
1efafbcd9b restricted our classification
of various optional-related conversions (implicit forcing of IUOs,
optional-to-optional conversions, value-to-optional conversions) to
produce a single potential classification. However, in the presence of
type variables, we cannot always determine which particular conversion
restriction might apply. Prior to 1efafb, we produced too many
options; after 1efafb, we produced too few. Here, enumerate a more
bounded (but complete) set of potential conversions, taking into
account embedded type variables.

This is a better fix for rdar://problem/29977523 than simply reverting
1efafb, because it bounds the set of optional conversions we attempt.
2017-01-17 13:10:26 -08:00
Pavel Yaskevich
35b0ffeff8 [Diagnostics] Fix diagnoseImplicitSelfErrors to accept only valid argument types.
Add additional checks before trying to re-check argument expression in
`FailureDiagnosis::diagnoseImplicitSelfErrors` and before trying to use
its resulting type, which can only be either tuple or paren type.
2017-01-17 01:49:09 -08:00
Slava Pestov
9bc057c156 Merge pull request #6846 from rintaro/crasher-crasher-28600
[Lexer] Disable all SIL_KEYWORDs in non-SIL mode
2017-01-16 18:48:06 -08:00
Slava Pestov
c49be072d1 Merge pull request #6826 from xedin/implicit-cleanup
[QoI] Move from RAII to direct sub-expression cleanup. NFC
2017-01-16 15:47:42 -08:00
Slava Pestov
6d5e4822a2 Merge pull request #6844 from rintaro/crasher-crasher-28602
[Diag] Don't attempt 'fixOverrideDeclarationTypes' when indices count doesn't match for subscript
2017-01-16 15:40:34 -08:00
Jacob Bandes-Storch
8673a60c0d [Sema] Add missing case to %select in resilience diagnostics (#6847)
Fixes a crasher added in #6839.
2017-01-16 11:28:23 -08:00
Rintaro Ishizaki
0affdb057d [Lexer] Disable all SIL_KEYWORDs in non-SIL mode
Instead of long '||' conditions, use SIL_KEYWORD in Tokens.def.
2017-01-16 23:33:54 +09:00
Rintaro Ishizaki
3952e0043c [Diag] Don't attempt 'fixOverrideDeclarationTypes' when indices count doesn't match for subscript
Fixes a crasher
2017-01-16 22:51:35 +09:00
Pavel Yaskevich
6f217dbe2a [ConstraintSystem] Don't attempt to solve candidates which have closures.
While shrinking constraint system, avoid candidates which contain
closures inside, because closure expressions require special handling
and allow no rollback.
2017-01-15 14:15:04 -08:00
practicalswift
de87201237 Mark crashers as fixed. 2017-01-14 17:56:32 +01:00
Pavel Yaskevich
488fc0fad5 [QoI] Cleanup AST after trying to shrink constraint system of invalid expression
Since `ConstraintSystem::shrink` is going to attempt to type-check
sub-expressions separately it's essential to clean-up AST if constraint
generation or solving of the such expressions fails, otherwise if
such solving resulted in creation of implicit expression type variables
might leak to the outside.
2017-01-13 17:20:56 -08:00
Arnold Schwaighofer
e46e63ebc6 Revert "[QoI] Cleanup AST after trying to shrink constraint system of invalid expression" 2017-01-13 13:35:19 -08:00
Pavel Yaskevich
9b7d632160 [QoI] Cleanup AST after trying to shrink constraint system of invalid expression
Since `ConstraintSystem::shrink` is going to attempt to type-check
sub-expressions separately it's essential to clean-up AST if constraint
generation or solving of the such expressions fails, otherwise if
such solving resulted in creation of implicit expression type variables
might leak to the outside.
2017-01-13 00:39:37 -08:00
practicalswift
c9e534d4ea [gardening] Fix annotations for fixed crashers 2017-01-07 21:05:03 +01:00
practicalswift
a076f6cf27 Update crashers with correct annotations. 2017-01-07 18:44:35 +01:00
Robert Widmann
d2570cb964 Restore local type declarations list 2017-01-06 16:16:39 -07:00
Robert Widmann
9c7a6cfaa3 Fix a crasher 2017-01-06 16:16:39 -07:00
practicalswift
7e66ecfde8 Mark previously non-deterministic compiler crashes as fixed. 2017-01-06 23:01:34 +01:00
practicalswift
6d1ae2a39c [gardening] 2016 → 2017 2017-01-06 16:41:22 +01:00
practicalswift
724e2efa02 [gardening] Remove "REQUIRES: asserts" from fixed crashers 2017-01-06 16:38:25 +01:00
Erik Eckstein
8cf641ce2b Mangling: fix crash when mangling an identifier which has a unicode char as first character and a digit as second char. 2017-01-04 16:20:09 -08:00
Slava Pestov
18adb53226 Sema: Tighten up name lookup routines to not look through metatypes/lvalues/etc
Previously all of the following would strip off varying amounts of
MetatypeType, LValueType, InOutType, DynamicSelfType, etc:

- ConstraintSystem::performMemberLookup()
- ConstraintSystem::lookupMember()
- TypeChecker::lookupMember()
- DeclContext::lookupQualified()
- Type::getContextSubstitutions()

The problem is that the higher level methods that took a lookup type
would call the lower level methods, and post-process the result using
the given lookup type. Since different levels of sugar were stripped,
it made the code hard to reason about and opened up edge cases, eg
if a DynamicSelfType or InOutType appears where we didn't expect it.

Since filtering out static/instance and mutating/nonmutating members
is done at higher levels, there's no reason for these name lookup
operations to accept anything other than nominal types, existentials
and archetypes.

Make this so with assertions, and deal with the fallout.
2017-01-04 01:40:19 -08:00
Slava Pestov
584f47d025 Sema: Fix crashes in CSDiag
- TypeMatchVisitor doesn't like seeing ErrorTypes -- stop if we have one.

- Common logic for replacing type parameters and variables with
  UnresolvedType.

- Fix crash in coerceToType() if one of the two types has an UnresolvedType
  in it, but not at the top level.

Fixes one compiler_crasher and some regressions with upcoming patches.
2017-01-04 01:40:19 -08:00
Slava Pestov
0a7e1d5568 Sema: Fix crash in conformance checking
Yeah, the repro is really just "class A : RangeReplaceableCollection { }".
2017-01-04 01:27:41 -07:00
Slava Pestov
e4abdfc2bd AST: Model protocols nested inside other types
We might allow protocols inside non-generic class/struct/enum
declarations eventually; there's no conceptual difficulty, just
some IRGen and Serialization work that has to happen first.

Also, this fixes a crasher :-)
2017-01-04 00:10:29 -08:00
Slava Pestov
2b05dd9d85 AST: Remove error path that was causing crashes 2017-01-04 00:10:28 -08:00
Slava Pestov
b6d8bbb698 AST: Return abstract conformance for UnresolvedType
We "fake" a conformance of UnresolvedType to any protocol.
Instead of returning a concrete conformance, return an
abstract conformance. The concrete conformance had several
problems leading to further crashes:

- The DC was set to a module, not a type declaration context,
  since there is not type declaration context here.

- The conformance was marked complete even though it was missing
  inherited conformances.
2017-01-04 00:10:28 -08:00
Slava Pestov
cc2ae7b7d5 AST: Fix crash with invalid generic environment 2017-01-04 00:10:28 -08:00
Slava Pestov
a230bde7e7 AST: Clean up getDeclaredType() and friends 2017-01-03 23:40:47 -08:00
Slava Pestov
e455085d94 Sema: When opening an UnboundGenericType, don't put replacements in the same map
When inserting a new value, assert that there's no existing
value at that key, and to avoid the assert firing when
opening up UnboundGenericTypes, put those replacements in
their own map. We don't need them later.
2017-01-03 23:40:46 -08:00
Slava Pestov
469cccdef1 Sema: Avoid infinite recursion in associated type inference 2017-01-03 23:40:46 -08:00
Slava Pestov
d406c4d002 ASTVerifier: Don't check Override attribute if we haven't done early attribute validation
If the 'override' attribute appears on an invalid decl,
it is removed at the start of typeCheckDecl(). However if
the decl is nested inside a multi-statement closure which
is invalid for other reasons, we may have validated it
but not type checked it, in which case we don't want to
crash in the verifier.
2017-01-03 23:40:45 -08:00
Slava Pestov
2932aac03a AST: More accurate AbstractFunctionDecl::getImplicitSelfDecl()
Now, the following are both true or both false:

- AFD->getDeclContext()->isTypeContext()
- AFD->getImplicitSelfDecl() != nullptr

Also, if var->isSelfParameter() returns true, then it is also
the case that var == var->getDeclContext()->getImplicitSelfDecl().
2017-01-03 23:40:45 -08:00
Slava Pestov
c7ab11f228 Sema: Fix crash in 'var' parameter migration 2017-01-03 23:40:44 -08:00
Slava Pestov
e6ada30291 Parse: Fix crash when alignment is too large 2017-01-03 23:40:44 -08:00
Slava Pestov
32ebe2db5a Parse: Don't crash if property with no declared type has addressors 2017-01-03 23:40:44 -08:00
Slava Pestov
8f96606cb2 Sema: Remove TupleToScalar conversion, which did nothing useful except crash
As far as I can tell there's no way to trigger this from valid code.
2017-01-03 23:00:07 -08:00
Slava Pestov
f19cbef54d Sema: Try harder not to perform lookups into tuple types 2017-01-03 23:00:07 -08:00
Slava Pestov
9f30532641 Sema: Fix closeExistential() in CSApply with invalid direct call of metatype
When we have a value 'p' of type 'P.Type' for some protocol 'P',
we require the user to write 'p.init()' rather than 'p()' to
construct an instance of a concrete type conforming to 'P'.

If they write 'p()', we suggest a fixit to insert '.init',
however if there is also a subsequent member access on the
result, for example 'p().foo', we would crash.

Another invalid case that used to crash is when you construct
a protocol metatype directly and then access a member of it,
eg. 'P().foo'.
2017-01-03 21:28:11 -08:00
Slava Pestov
2c7aae4128 Sema: 'Never'-returning functions can be represented in Objective-C
Fixes <https://bugs.swift.org/browse/SR-3203>.
2017-01-03 20:13:42 -08:00
Slava Pestov
88ecaad180 Merge pull request #6543 from slavapestov/small-silgen-fixes
Fixes for assorted SILGen bugs
2017-01-03 19:48:10 -08:00
Slava Pestov
7258861d73 Merge pull request #6515 from xedin/crasher-28588
[QoI] While merging equivalence classes don't forget to merge fixed types (if any).
2017-01-03 19:35:47 -08:00
Slava Pestov
a8da5b8d80 Merge pull request #6514 from xedin/SR_3506
[Diagnostics] When checking AssignExpr properly diagnose destination
2017-01-03 19:24:52 -08:00
Slava Pestov
dfed050794 Merge pull request #6505 from practicalswift/mark-as-fixed
Mark two disabled and previously non-deterministic crashers as fixed
2017-01-03 19:14:52 -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