Commit Graph

40 Commits

Author SHA1 Message Date
Dmitri Hrybenko
5d41b6ac9f Validation testsuite: annotate compiler crashers for AddressSanitizer
Tests that crash the compiler are expected to fail under
AddressSanitizer.

Swift SVN r24071
2014-12-22 18:22:07 +00:00
Dmitri Hrybenko
6cad796ec8 Annotate compiler crasher tests so that the tests succeed reliably when
the compiler is built without assertions

Swift SVN r24061
2014-12-20 09:42:59 +00:00
Chris Willmore
b1e9e09ae7 Swift r23756 fixed crash test 2258.
<rdar://problem/19179412> compiler_crashers 1260, 2258 regress in Swift Stdlib (Release+Asserts) #1620

Swift SVN r23796
2014-12-09 00:05:59 +00:00
Joe Pamer
dc338c2a71 Update wording of some new diagnostics.
Swift SVN r23783
2014-12-08 21:56:52 +00:00
Joe Pamer
2912159776 Improve diagnostics for expression typecheck errors
These changes make the following improvements to how we generate diagnostics for expression typecheck failure:
- Customizing a diagnostic for a specific expression kind is as easy as adding a new method to the FailureDiagnosis class,
  and does not require intimate knowledge of the constraint solver’s inner workings.
    - As part of this patch, I’ve introduced specialized diagnostics for call, binop, unop, subscript, assignment and inout
      expressions, but we can go pretty far with this.
    - This also opens up the possibility to customize diagnostics not just for the expression kind, but for the specific types
      involved as well.
- For the purpose of presenting accurate type info, partially-specialized subexpressions are individually re-typechecked
  free of any contextual types. This allows us to:
    - Properly surface subexpression errors.
    - Almost completely avoid any type variables in our diagnostics. In cases where they could not be eliminated, we now
      substitute in "_".
    - More accurately indicate the sources of errors.
- We do a much better job of diagnosing disjunction failures. (So no more nonsensical ‘UInt8’ error messages.)
- We now present reasonable error messages for overload resolution failures, informing the user of partially-matching
  parameter lists when possible.

At the very least, these changes address the following bugs:

<rdar://problem/15863738> More information needed in type-checking error messages
<rdar://problem/16306600> QoI: passing a 'let' value as an inout results in an unfriendly diagnostic
<rdar://problem/16449805> Wrong error for struct-to-protocol downcast
<rdar://problem/16699932> improve type checker diagnostic when passing Double to function taking a Float
<rdar://problem/16707914> fatal error: Can't unwrap Optional.None…Optional.swift, line 75 running Master-Detail Swift app built from template
<rdar://problem/16785829> Inout parameter fixit
<rdar://problem/16900438> We shouldn't leak the internal type placeholder
<rdar://problem/16909379> confusing type check diagnostics
<rdar://problem/16951521> Extra arguments to functions result in an unhelpful error
<rdar://problem/16971025> Two Terrible Diagnostics
<rdar://problem/17007804> $T2 in compiler error string
<rdar://problem/17027483> Terrible diagnostic
<rdar://problem/17083239> Mysterious error using find() with Foundation types
<rdar://problem/17149771> Diagnostic for closure with no inferred return value leaks type variables
<rdar://problem/17212371> Swift poorly-worded error message when overload resolution fails on return type
<rdar://problem/17236976> QoI: Swift error for incorrectly typed parameter is confusing/misleading
<rdar://problem/17304200> Wrong error for non-self-conforming protocols
<rdar://problem/17321369> better error message for inout protocols
<rdar://problem/17539380> Swift error seems wrong
<rdar://problem/17559593> Bogus locationless "treating a forced downcast to 'NSData' as optional will never produce 'nil'" warning
<rdar://problem/17567973> 32-bit error message is really far from the mark: error: missing argument for parameter 'withFont' in call
<rdar://problem/17671058> Wrong error message: "Missing argument for parameter 'completion' in call"
<rdar://problem/17704609> Float is not convertible to UInt8
<rdar://problem/17705424> Poor error reporting for passing Doubles to NSColor: extra argument 'red' in call
<rdar://problem/17743603> Swift compiler gives misleading error message in "NSLayoutConstraint.constraintsWithVisualFormat("x", options: 123, metrics: nil, views: views)"
<rdar://problem/17784167> application of operator to generic type results in odd diagnostic
<rdar://problem/17801696> Awful diagnostic trying to construct an Int when .Int is around
<rdar://problem/17863882> cannot convert the expression's type '()' to type 'Seq'
<rdar://problem/17865869> "has different argument names" diagnostic when parameter defaulted-ness differs
<rdar://problem/17937593> Unclear error message for empty array literal without type context
<rdar://problem/17943023> QoI: compiler displays wrong error when a float is provided to a Int16 parameter in init method
<rdar://problem/17951148> Improve error messages for expressions inside if statements by pre-evaluating outside the 'if'
<rdar://problem/18057815> Unhelpful Swift error message
<rdar://problem/18077468> Incorrect argument label for insertSubview(...)
<rdar://problem/18079213> 'T1' is not identical to 'T2' lacks directionality
<rdar://problem/18086470> Confusing Swift error message: error: 'T' is not convertible to 'MirrorDisposition'
<rdar://problem/18098995> QoI: Unhelpful compiler error when leaving off an & on an inout parameter
<rdar://problem/18104379> Terrible error message
<rdar://problem/18121897> unexpected low-level error on assignment to immutable value through array writeback
<rdar://problem/18123596> unexpected error on self. capture inside class method
<rdar://problem/18152074> QoI: Improve diagnostic for type mismatch in dictionary subscripting
<rdar://problem/18242160> There could be a better error message when using [] instead of [:]
<rdar://problem/18242812> 6A1021a : Type variable leaked
<rdar://problem/18331819> Unclear error message when trying to set an element of an array constant (Swift)
<rdar://problem/18414834> Bad diagnostics example
<rdar://problem/18422468> Calculation of constant value yields unexplainable error
<rdar://problem/18427217> Misleading error message makes debugging difficult
<rdar://problem/18439742> Misleading error: "cannot invoke" mentions completely unrelated types as arguments
<rdar://problem/18535804> Wrong compiler error from swift compiler
<rdar://problem/18567914> Xcode 6.1. GM, Swift, assignment from Int64 to NSNumber. Warning shown as problem with UInt8
<rdar://problem/18784027> Negating Int? Yields Float
<rdar://problem/17691565> attempt to modify a 'let' variable with ++ results in typecheck error about @lvalue Float
<rdar://problem/17164001> "++" on let value could give a better error message

Swift SVN r23782
2014-12-08 21:56:47 +00:00
Dmitri Hrybenko
1eea220932 Use one module cache directory for all the lit tests to speed them up
Doing so is safe even though we have mock SDK.  The include paths for
modules with the same name in the real and mock SDKs are different, and
the module files will be distinct (because they will have a different
hash).

This reduces test runtime on OS X by 30% and brings it under a minute on
a 16-core machine.

This also uncovered some problems with some tests -- even when run for
iOS configurations, some tests would still run with macosx triple.  I
fixed the tests where I noticed this issue.

rdar://problem/19125022

Swift SVN r23683
2014-12-04 11:21:48 +00:00
Chris Willmore
007204a595 Crash tests 0730, 0911, 0916, 1660, 2027, 2203 no longer crash.
Swift SVN r23541
2014-11-21 23:27:40 +00:00
Chris Willmore
513b05c283 compiler_crashers: Use %target-swift-frontend instead of %swift -sdk %sdk
This fixes compiler_crashers tests that use the ObjC interface on
iOS hardware SDKs.

Swift SVN r23458
2014-11-20 00:32:59 +00:00
Chris Willmore
4e1fa4a63f Import the swift-compiler-crashes test suite.
Add all compiler crash tests to the validation-test/compiler_crashers
subdirectory. Add a RUN: line to each test case according to the current
behavior of the Swift compiler.

Swift SVN r23418
2014-11-19 01:27:58 +00:00
Doug Gregor
72e9ca5d67 Move the computation of generic signatures into the archetype builder.
The archetype builder is responsible for figuring out what should go
into a generic signature anyway, so move the generic signature
creation there. This will also allow us to eliminate some code
duplication across Sema and AST.

Fixes compiler crasher 033.

Swift SVN r23030
2014-10-31 06:04:05 +00:00
Joe Groff
1c2ec918bd Update validation test for diagnostic drift.
Swift SVN r22946
2014-10-26 04:38:02 +00:00
Doug Gregor
e3573b2fd2 Drop expected-* annotations from test; it's too messy to -verify. NFC
Swift SVN r22411
2014-09-30 22:32:31 +00:00
Doug Gregor
073af87f3c Fail more gracefully when we're unable to map a dependent type to an archetype.
This can happen due to an error upstream, so don't assert on it. Fixes
rdar://problem/18503131, and crashers #51, #079, and #128.

Swift SVN r22409
2014-09-30 22:27:07 +00:00
Joe Groff
bdacc06d86 Check off crasher #025.
Swift SVN r22203
2014-09-23 03:28:50 +00:00
Joe Pamer
a474d86305 When checking for shadowed values, account for the fact that we may be checking the rhs of a recursive binding.
This addresses crash suite scenarios 016 and 034. (rdar://problem/17837823)

Swift SVN r22125
2014-09-19 06:12:32 +00:00
Joe Groff
da26c54c06 IRGen: Preserve associated types and witness tables in NecessaryBindings.
Fixes crasher #003 (rdar://problem/18232605). This time, also increase the buffer size for the necessary bindings so we don't clobber memory.

Swift SVN r22118
2014-09-19 04:00:58 +00:00
Joe Pamer
f9db2f0c9d When checking conformances, if we fail to find a witness for one associated type member refrain from attempting to resolve the others.
(If any other associated type member has a dependency on the invalid one, we won't be able to substitute and the compiler will crash.)

This addresses crash suite scenario 035. (rdar://problem/18233020)

Swift SVN r22116
2014-09-19 03:25:35 +00:00
Joe Pamer
ffc37729c8 Revert "IRGen: Preserve associated types and witness tables in NecessaryBindings."
This reverts commit r22108

Swift SVN r22115
2014-09-19 02:49:17 +00:00
Joe Pamer
783a8c6247 Prohibit type declarations within generic functions, which were causing the compiler to crash.
You'll notice that we already had tests that made it appear that such declarations could work,
but they were only avoiding crashes because downstream errors were already marking the
enclosing functions as invalid. (If the errors were fixed, they would also crash the compiler.)

This addresses crash suite scenario 018. (rdar://problem/18299547)

Swift SVN r22109
2014-09-19 00:18:43 +00:00
Joe Groff
b0dea1625f IRGen: Preserve associated types and witness tables in NecessaryBindings.
Fixes crasher #003 (rdar://problem/18232605).

Swift SVN r22108
2014-09-19 00:06:18 +00:00
Joe Groff
bee33a060c Sema: Ban pattern bindings without variables in globals and properties.
There's no real use for declaring a property or global variable without binding it to anything, and closure context mangling relies on having a name to associate with closures. Fixes crash suite #006 (rdar://problem/18232699).

Swift SVN r22105
2014-09-18 22:59:58 +00:00
Joe Pamer
b2891be810 When performing module lookups, respect the resolution mode when deciding whether or not to validate any found declarations.
Doing so prevents another common source of stack overflows in the validator, and addresses crash suite scenarios 002 and 004.
(rdar://problem/18232499, rdar://problem/18232668)

Swift SVN r22104
2014-09-18 22:51:34 +00:00
Joe Pamer
1ea993c317 If the generic type parameters of a class or struct declaration are invalid or otherwise broken, we should treat the declaration as invalid, and be more careful about doing anything that could lead to the creation of bogus archetypes. (Such as implicit constructor/destructor generation, or conformance checking.)
This addresses crash suite scenario 022. (rdar://problem/18232772)

Swift SVN r22095
2014-09-18 20:10:02 +00:00
Joe Pamer
436e135d3d Prevent another stack overflow in the type checker by avoiding recursively validating generic parameter lists. (rdar://problem/18072109 and crash suite scenario 021.)
Swift SVN r22094
2014-09-18 20:10:00 +00:00
Joe Pamer
dd141c7cad Account for recursive validation when checking if an existential conforms to itself. (rdar://problem/18042380)
This can only occur when validating mutually recursive existentials in type reference expressions, so it's "safe" to avoid validating member value decls in this case. There are still potential holes in our mechanism for checking for unsupported existentials, but at least this will eliminate another common crasher. (Crash suite scenario 010.)

Swift SVN r22035
2014-09-17 20:23:41 +00:00
Joe Groff
d3702950af SILGen: Materialize class-constrained "self" parameters when passed to non-class-constrained protocol methods.
Fixes rdar://problem/17480006, rdar://problem/17557409, rdar://problem/17929884 and crash suite #019.

Swift SVN r21981
2014-09-16 21:12:40 +00:00
Joe Groff
041c179e01 SIL: Continue type lowering after address-only fields of aggregates.
Now that we rely on type lowering to catch recursive value types, this optimization is no longer valid. Fixes rdar://problem/18232757 (crash suite #015).

Swift SVN r21967
2014-09-16 04:55:44 +00:00
Joe Groff
1c4e08a9c8 Fix up a tangle of issues related to reabstraction.
- A spot fix in SILGen for reabstracting the result of a downcast, which fixes checked casts to function types.
- Associate the layout information in type metadata records with the most abstract representation of the type. This is the correct thing to do in cases where we need the metadata as a tag for an opaque value--if we store a value in an Any, or pass it as an unconstrained generic parameter, we must maximally reabstract it. This fixes the value semantics of existentials containing trivial metatypes.
- To ensure that we get runtime layout of structs and enums correct when they contain reabstractable types, introduce a "metadata for layout" concept, which doesn't need to describe the canonical metadata for the type, but only needs to describe a type with equivalent layout and value semantics. This is a correctness fix that allows us to correctly lay out generic types containing dependent tuples and functions, and although we don't really take advantage of it here, it's also a potential runtime performance win down the road, because we could potentially produce direct metadata for a primitive type that's layout-equivalent with a runtime-instantiated type. To aid in type safety here, push SILType deeper into IRGen in places where we potentially care about specific representations of types.
- Finally, fix an inconsistency between the runtime and IRGen's concept of what spare bits unmanaged references and thick metatypes have.

Together, these fixes address rdar://problem/16406907, rdar://problem/17822208, rdar://problem/18189508, and likely many other related issues, and also fixes crash suite cases 012 and 024.

Swift SVN r21963
2014-09-16 01:44:34 +00:00
Doug Gregor
f7458a8e05 Update compiler-crashers testsuite r21946
Swift SVN r21952
2014-09-15 21:00:17 +00:00
Joe Pamer
ede74dd90e When solving for call witness argument conversions, post diagnostics in the case of failures rather than raise an assertion. This addresses crash suite issue 040. (rdar://problem/18233081)
Swift SVN r21852
2014-09-10 22:28:03 +00:00
Dmitri Hrybenko
2c93cf71f0 Mark compiler_crashers/036-lisp-style.swift as passing
Swift SVN r21833
2014-09-10 08:07:47 +00:00
Joe Pamer
9bbf4ac5fe Improve diagnostic so as not to mystify users.
Swift SVN r21824
2014-09-10 01:52:07 +00:00
Joe Pamer
acce45bdc8 Lock down existential metatype to metatype coercions. Since they're currently unsupported, we'll display a semantic error rather than crash.
This addresses crash suite scenarios 011 and 013. (rdar://problem/17777218, rdar://problem/18232728)

Swift SVN r21822
2014-09-10 00:54:34 +00:00
Joe Pamer
aeef7f736f Now that we now longer crash, reinstate test.
Swift SVN r21818
2014-09-10 00:05:29 +00:00
Joe Pamer
fa692976f5 If an expression fails to type check, and there were no failures posted or constraints to mine for a reason, we can be fairly certain that the reason for the failure was a lack of contextual type data. In this case, we should post a diagnostic rather than let the failure slip through. This addresses crash suite scenarios 001, 005, 020 and 045. (rdar://problem/16712071, rdar://problem/17317691, rdar://problem/17317691)
You'll notice that emitting this diagnostic will make some already noisy closure-related errors slightly more so. This is unfortunate, but for the time-being it's better than crashing.

Swift SVN r21817
2014-09-09 23:58:59 +00:00
Jordan Rose
e5bfd3c5dd [test] Mark three known crashers as "XFAIL: asan".
We're going to crash anyway, we'll fix it when we fix the main issue, and
the main issue isn't memory-error-related. Should unblock the ASan bot.

Swift SVN r21814
2014-09-09 22:46:56 +00:00
Dmitri Hrybenko
decff06131 Remove the test that is duplicate with
test/IRGen/mixed_objc_native_protocol_constraints.swift

Swift SVN r21804
2014-09-09 06:55:24 +00:00
Mishal Awadah
e5ca8be1a0 Add README with details on swift-compiler-crashes community repo.
Swift SVN r21717
2014-09-04 18:21:03 +00:00
Mishal Awadah
798315edd5 Add recent crasher test case from swift-compiler-crashes.
Swift SVN r21716
2014-09-04 18:21:02 +00:00
Mishal Awadah
d8ce0b80cb Add basic compilation tests from swift-compiler-crashes (https://github.com/practicalswift/swift-compiler-crashes.git)
Swift SVN r21693
2014-09-04 01:06:26 +00:00