Commit Graph

7604 Commits

Author SHA1 Message Date
Jordan Rose
406592e5c2 Update validation tests for no-asserts builds.
Swift SVN r24803
2015-01-28 19:27:16 +00:00
Dmitri Hrybenko
f4e35f90eb stdlib: remove Unsafe[Mutable]Pointer.null()
This API is redundant with nil literals and the default initializer.

rdar://19159145

Swift SVN r24796
2015-01-28 08:42:28 +00:00
Dmitri Hrybenko
f747652061 tests: clarify some XFAILs with a clear wording from Dave
Swift SVN r24790
2015-01-28 06:03:22 +00:00
Dmitri Hrybenko
263ceabd1e tests: clarify some XFAILs
Swift SVN r24782
2015-01-28 05:22:36 +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
Dmitri Hrybenko
b7e61965eb Remove redundant test
Swift SVN r24696
2015-01-24 00:12:21 +00:00
Dmitri Hrybenko
cb2870c230 Update Unicode data files to 7.0.0
rdar://17561742

Swift SVN r24692
2015-01-23 22:17:45 +00:00
Dmitri Hrybenko
7209392bb4 stdlib/Unicode: fix encoding U+20000 and higher to UTF-16
UTF16.{leadSurrogate,trailSurrogate} were converting intermediate
results to UInt16 too soon, causing a trap on U+20000 and higher.

rdar://19156359

Swift SVN r24678
2015-01-23 04:47:02 +00:00
Dmitri Hrybenko
3087d186cb tests: use a more appropriate test name and remove a redundant test
Swift SVN r24676
2015-01-23 03:29:31 +00:00
Dmitri Hrybenko
bbf79427ac stdlib: remove bitwise operations on Bool
Bitwise operations on Bool are redundant with other logic operations
that stdlib already provides.  The only reason to have them was to avoid
branching in the short-circuiting && and ||.

rdar://19340952

Surprisingly, replacing & and | in the standard library with && and ||
brought performance improvements and no significant performance
regressions:

RecursiveOwnedParameter 1.14
SelectionSort 1.19

Swift SVN r24674
2015-01-23 03:09:55 +00:00
Dmitri Hrybenko
2d12d510f2 Lowercase the first character in compiler diagnostics for consistency
Swift SVN r24634
2015-01-22 06:19:14 +00:00
Dmitri Hrybenko
9257f00d27 Update validation tests for compiler changes
Swift SVN r24633
2015-01-22 06:03:46 +00:00
Maxwell Swadling
d379fd2050 updated fixed test assertion
Swift SVN r24617
2015-01-21 23:52:37 +00:00
Maxwell Swadling
007e94c571 [stdlib] updated error message in validation tests
Swift SVN r24616
2015-01-21 23:35:56 +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
Flash Sheridan
3a074e5a50 Assign the result of binary operations to a variable, in preparation for checking its type in my next check-in.
Ugly (both in layout and functionality) workaround for Gyb rdar://15928178, using operator if/else if/else instead of if/elif statements;
this was fiddly to get working, hence the separate check-in.
Sharpen the expected error string for mixed type operators, and add an expected warning and note for assigning the result of
an assignment, which is righteous since we're not C.
Approved by Dmitri.


Swift SVN r24586
2015-01-21 03:54:48 +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
Chris Willmore
68dd563fbf <rdar://problem/18311362> TLF: Eliminate implicit bridging conversions
Require 'as' when converting from Objective-C type to native type (but
continue to allow implicit conversion from native to Objective-C). This
conversion constraint is called ExplicitConversion; all implicit
conversions are covered by the existing Conversion constraint. Update
standard library and tests to match.

Swift SVN r24496
2015-01-18 00:07:45 +00:00
Flash Sheridan
420b05735e Purely cosmetic changes, with a count comment and noting what each %end is closing, to make it easier to track (in both the gyb source and the Swift output) the functional changes I'm struggling with.
Swift SVN r24494
2015-01-17 03:44:43 +00:00
Andrew Trick
e2760a7036 Add a return statement to Variant[Set|Dictionary]Storage.removeAtIndex.
This fast path is only taken when the code is specialized.
Fixes <rdar://problem/19331717> Optimizer breaks Set<T> and Dictionary<K, V>

Swift SVN r24479
2015-01-16 21:10:48 +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
Jordan Rose
cb702a9035 [test] parse_stdlib.sil should parse the current target's standard library.
I'm not sure how this ever worked -- it was previously always parsing the
OS X standard library but with the current target's triple.

Should fix the buildbot.

Swift SVN r24472
2015-01-16 04:24:23 +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
Dmitri Hrybenko
2000bdfb61 tests: check that terminating with exit(1) or abort() is counted as test
failure

Certain iOS simulator versions have a bug in 'simctl' that prevents it
from propagating the exit code to lit in all cases.  We are not running
these iOS versions on the buildbots yet.

rdar://19408362

Swift SVN r24369
2015-01-12 07:38:39 +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
Chris Willmore
03a6190a1f <rdar://problem/19031957> Change failable casts from "as" to "as!"
Previously the "as" keyword could either represent coercion or or forced
downcasting. This change separates the two notions. "as" now only means
type conversion, while the new "as!" operator is used to perform forced
downcasting. If a program uses "as" where "as!" is called for, we emit a
diagnostic and fixit.

Internally, this change removes the UnresolvedCheckedCastExpr class, in
favor of directly instantiating CoerceExpr when parsing the "as"
operator, and ForcedCheckedCastExpr when parsing the "as!" operator.

Swift SVN r24253
2015-01-08 00:33:59 +00:00
Flash Sheridan
c5ebf4f2b5 Add tests for Float80, but only on the desktop; which is tricky, since Gyb doesn't know its destination.
Now 3835 tests.  Reviewed by Dmitri.

Swift SVN r24237
2015-01-07 04:58:25 +00:00
Dmitri Hrybenko
6670bb76ec Rewrite the CMake build system
Swift SVN r24124
2014-12-23 22:15:30 +00:00
Dmitri Hrybenko
d7179e3c03 Consolidate arithmetic trap tests
Reduces iOS testing time by 25 seconds (machine time, not wall clock
time).

Swift SVN r24086
2014-12-22 23:58:41 +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
Dmitri Hrybenko
90a8ba9de6 Tests: add a no_asserts fetaure
Swift SVN r24058
2014-12-20 09:42:52 +00:00
Flash Sheridan
c11eb40008 Iterate over more documented operators, now that the documentation has improved; now 3460 tests.
Replace hard-coded lists of real-number types, and of arithmetic and logical operators I’m testing, with lists added to SwiftIntTypes.py, which becomes a bit of a misnomer.  
Separate them into ones which only work on integer types, and those which also allow reals.
Do a double loop, over just the integers and then the reals as well.
Change the run line to allow importing StdlibUnittest with help from Dmitri, which I won't actually need until I do result type checking.

Approved by Dmitri.

Swift SVN r24029
2014-12-19 04:20:03 +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