Commit Graph

1575 Commits

Author SHA1 Message Date
Jordan Rose
e635d6a993 In the spirit of r25276, break circularity with generic functions, too.
Also beef up the main test case a little.

I don't have a Radar, but this fixes 177 compiler_crashers!

Swift SVN r25281
2015-02-13 19:59:48 +00:00
Jordan Rose
b2dd3cea7c Update compiler_crashers for r25276.
Swift SVN r25277
2015-02-13 19:20:21 +00:00
Dmitri Hrybenko
38a14768e7 Annotate a crasher test that is not crashing anymore
Swift SVN r25223
2015-02-12 02:29:00 +00:00
Joe Groff
63463f54ac SIL: Mangle the static-ness of declarations.
This lets us disambiguate the symbols for static and instance properties, and enables us to eventually leave the useless "self" type mangling out of method symbols. Fixes rdar://19012022 and dupes thereof, including crasher #1341.

Swift SVN r25111
2015-02-10 02:37:35 +00:00
Jordan Rose
1e4f4b1939 Update fixed compiler crashers for r25059.
Swift SVN r25066
2015-02-07 04:09:32 +00:00
Dmitri Hrybenko
f3972edecd Annotate a crash test that does not crash now
Swift SVN r24992
2015-02-05 05:31:35 +00:00
Dmitri Hrybenko
eae39871bc Annotate tests that no longer crash under AddressSanitizer
Swift SVN r24988
2015-02-05 02:44:55 +00:00
Doug Gregor
e855ae8f58 Clang importer: only consider imported initializers when filtering out duplicates.
Fixes rdar://problem/18500201 and 16 of the crashes in the crash suite.

Swift SVN r24982
2015-02-05 00:07:58 +00:00
Dmitri Hrybenko
de14227634 validation-test: annotate test that started hitting an assertion
Swift SVN r24979
2015-02-04 23:41:59 +00:00
Dmitri Hrybenko
f09b4f3a81 validation-test: annotate tests that don't crash anymore
Swift SVN r24978
2015-02-04 22:55:41 +00:00
Dmitri Hrybenko
0b5843ab43 Add XFAILs for tests that started failing under AddressSanitizer
Swift SVN r24952
2015-02-04 10:43:56 +00:00
Dmitri Hrybenko
c4123d78f4 Remove XFAIL annotations in tests that don't fail under AddressSanitizer anymore
Swift SVN r24951
2015-02-04 10:43:54 +00:00
Dmitri Hrybenko
abc3f1078d Annotate tests that don't crash anymore
Swift SVN r24940
2015-02-04 04:53:05 +00:00
Dmitri Hrybenko
bea947c53b Annotate compiler crasher tests that now hit assertions under
AddressSanitizer

This is an improvement, previously these tests used to trigger a trap in
AddressSanitizer.

Swift SVN r24919
2015-02-03 17:15:40 +00:00
Joe Pamer
666646fee9 Fix "the world's shortest Swift crasher" (case 1083), as described this afternoon on Twitter by @PracticalSwift. Doing so has the nice side effect of addressing several other crashers.
Swift SVN r24857
2015-01-30 21:50:22 +00:00
Denis Vnukov
68b756bf90 Fix for rdar://19548610, Fuzzing Swift: performSema(...) crashes: Assertion failed: (Done && "Parser returned early?")
Parser may stop at some erroneous constructions like stray #else or #endif, in some cases closing brace ‘}’, etc…
continue parsing until we are done.



Swift SVN r24822
2015-01-29 21:51:06 +00:00
Denis Vnukov
acda305d01 Fix for rdar://problem/19605164, Fuzzing Swift: abort() in Verifier::checkSourceRanges(...)
Corrected type end location in some erroneous cases.



Swift SVN r24810
2015-01-29 00:43:27 +00:00
Jordan Rose
406592e5c2 Update validation tests for no-asserts builds.
Swift SVN r24803
2015-01-28 19:27:16 +00:00
Jordan Rose
af9fe66606 Update crash suite for recently fixed cases, likely fixed by Denis.
Swift SVN r24776
2015-01-28 02:37:20 +00:00
Joe Pamer
d2c2add5de Introduce a hack for ensuring that, in the face of unresolved member exprs, call argument types line up nicely with the associated argument tuple type. (rdar://problem/18841652, rdar://problem/18913150, etc.)
This was one of our most visible user-facing crashers, manifesting itself any time a user performed an equality comparison on an unresolved enum case.

Swift SVN r24753
2015-01-27 20:56:03 +00:00
Jordan Rose
0a9d60485f Don't look into a type context to resolve types in the inheritance clause.
Instead, just check the generic parameters, then do a lookup as usual in the
enclosing context.

Fixes crash suite #58 and quite a few others (~200). This looks way more
impressive than it is; in most of these test cases it's the exact same
pattern causing the crash, and that pattern was just the last outstanding
crash trigger in a sea of garbage. (The few deleted tests were identical
to #58.)

Swift SVN r24748
2015-01-27 02:45:29 +00:00
Jordan Rose
c4503ac953 Discard default arguments when inferring a type for a variable.
func a(b: Int = 0) {}
  let c = a // should be (b: Int) -> Void, not (b: Int = 0) -> Void

Fixes crash suite #23.

rdar://problem/18232797

Swift SVN r24747
2015-01-27 02:45:26 +00:00
Jordan Rose
e9839523c9 [test] Add a Radar number to crash suite #55.
Swift SVN r24746
2015-01-27 02:45:25 +00:00
Joe Pamer
1985f1454c Partially unblock SourceKit fuzz-testing by fixing rdar://problem/19534837. To be honest, there are likely many ways to raise the assertion mentioned in the radar, so I don't see this as the end of the unblocking work.
Swift SVN r24723
2015-01-25 22:01:03 +00:00
Dmitri Hrybenko
a503831f36 tests: annotate that 0901-ab.swift does not fail consistently on all
platforms when the compiler is built without assertions

Swift SVN r24718
2015-01-25 06:26:37 +00:00
Dmitri Hrybenko
f808b18eb7 Validation tests: annotate that 0240-argemitter-emitexpanded.swift does
not crash anymore

Swift SVN r24711
2015-01-24 23:53:21 +00:00
Maxwell Swadling
d379fd2050 updated fixed test assertion
Swift SVN r24617
2015-01-21 23:52:37 +00:00
Dmitri Hrybenko
ff0a6319cc tests: annotate that 0424-no-stacktrace.random.swift now crashes when
assertions are disabled

Swift SVN r24594
2015-01-21 05:45:30 +00:00
Dmitri Hrybenko
3b04d1b013 tests: reorganize tests so that they actually use the target platform
Most tests were using %swift or similar substitutions, which did not
include the target triple and SDK.  The driver was defaulting to the
host OS.  Thus, we could not run the tests when the standard library was
not built for OS X.

Swift SVN r24504
2015-01-19 06:52:49 +00:00
Dmitri Hrybenko
2a744240fc Annotate compiler crasher tests that no longer crash when the compiler
is built without assertions

Swift SVN r24476
2015-01-16 18:01:12 +00:00
Doug Gregor
fea55d98f2 Eliminate dependent types from within archetypes.
When dealing with multiple levels of generic parameters, the mapping
from potential archetypes down to actual archetypes did not have
access to the archetypes for outer generic parameters. When same-type
requirements equated a type from the inner generic parameter list with
one from the outer generic parameter list, the reference to the outer
generic parameter list's type would remain dependent. For example,
given:

  struct S<A: P> {
    init<Q: P where Q.T == A>(_ q: Q) {}
  }

we would end up with the dependent type for A (τ_0_0) in the same-type
constraint in the initializer requirement.

Now, notify the ArchetypeBuilder of outer generic signatures (and,
therefore, outer generic parameters), so that it has knowledge of the
mapping from those generic parameters to the corresponding
archetypes. Use that mapping when translating potential archetypes to
real archetypes. Additionally, when a potential archetype is mapped to
a concrete type (via a same-type constraint to a concrete type),
substitute archetypes for any dependent types within the concrete
type.

Remove a bunch of hacks in the compiler that identified dependent
types in "strange" places and tried to map them back to
archetypes. Those hacks handled some narrow cases we saw in the
standard library and some external code, but papered over the
underlying issue and left major gaps.

Sadly, introduce one hack into the type checker to help with the
matching of generic witnesses to generic requirements that follow the
pattern described above. See ConstraintSystem::SelfTypeVar; the proper
implementation for this matching involves substituting the adoptee
type in for Self within the requirement, and synthesizing new
archetypes from the result.

Fixes rdar://18435371, rdar://18803556, rdar://19082500,
rdar://19245317, rdar://19371678 and a half dozen compiler crashers
from the crash suite. There are a few other radars that I suspect this
fixes, but which require more steps to reproduce.

Swift SVN r24460
2015-01-16 00:27:18 +00:00
Dmitri Hrybenko
1679791dd2 The 0033 compiler crash test case now fails with an assertion, mark it
as such.

Swift SVN r24392
2015-01-13 06:56:03 +00:00
Dmitri Hrybenko
923c75bf42 tests: remove XFAIL, this test now fails under ASan
Swift SVN r24370
2015-01-12 17:41:10 +00:00
Doug Gregor
16927ccb3d Revert "Move the computation of generic signatures into the archetype builder."
This reverts commit r23030.

This puts non-primary archetypes back in the all-archetypes list,
which is the deepest underlying problem behind
rdar://problem/19049566.

Conflicts:
	lib/AST/ArchetypeBuilder.cpp
	validation-test/compiler_crashers/0033-error.swift
	validation-test/compiler_crashers/035-multiple-typecheck-segfault.swift

Swift SVN r24333
2015-01-09 23:19:28 +00:00
David Farler
87c3d7421f Refine static func and var syntax
rdar://problem/17198298

- Allow 'static' in protocol property and func requirements, but not 'class'.
- Allow 'static' methods in classes - they are 'class final'.
- Only allow 'class' methods in classes (or extensions of classes)
- Remove now unneeded diagnostics related to finding 'static' in previously banned places.
- Update relevant diagnostics to make the new rules clear.

Swift SVN r24260
2015-01-08 03:03:29 +00:00
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