Commit Graph

3633 Commits

Author SHA1 Message Date
Joe Groff
a506af06c7 Merge pull request #4933 from jckarter/nsnumber-bridging
SE-0139: Bridge all standard number types to NSNumber.
2016-09-23 13:06:43 -07:00
Joe Groff
9b1f238e5b SE-0139: Bridge all standard number types to NSNumber.
Extend NSNumber bridging to cover not only `Int`, `UInt`, `Double`, and `Bool`, but all of the standard types as well. Extend the `TypePreservingNSNumber` subclass to accommodate all of these types, so that we preserve type identity for `AnyHashable` and dynamic casting of Swift-bridged NSNumbers. If a pure Cocoa NSNumber is cast, just trust that the user knows what they're doing.

This XFAILs a couple of serialization tests that attempt to build the Foundation overlay, but which don't properly handle `gyb` files.
2016-09-23 10:34:22 -07:00
swift-ci
e1712df7d4 Merge pull request #4956 from practicalswift/swiftc-28426-swift-expr-walk 2016-09-23 09:16:31 -07:00
practicalswift
c9657d1486 [swiftc (73 vs. 5165)] Add crasher in swift::Expr::walk(...)
Add test case for crash triggered in `swift::Expr::walk(...)`.

Current number of unresolved compiler crashers: 73 (5165 resolved)

Assertion failure in [`include/swift/AST/Pattern.h (line 111)`](https://github.com/apple/swift/blob/master/include/swift/AST/Pattern.h#L111):

```
Assertion `hasType()' failed.

When executing: swift::Type swift::Pattern::getType() const
```

Assertion context:

```
  /// Returns whether this pattern has been type-checked yet.
  bool hasType() const { return !Ty.isNull(); }

  /// If this pattern has been type-checked, return the type it
  /// matches.
  Type getType() const { assert(hasType()); return Ty; }

  /// Set the type of this pattern, given that it was previously not
  /// type-checked.
  void setType(Type ty) { Ty = ty; }

```
Stack trace:

```
swift: /path/to/swift/include/swift/AST/Pattern.h:111: swift::Type swift::Pattern::getType() const: Assertion `hasType()' failed.
14 swift           0x00000000010aa5eb swift::Expr::walk(swift::ASTWalker&) + 75
15 swift           0x0000000000fe4b34 swift::constraints::ConstraintSystem::Candidate::solve() + 324
16 swift           0x0000000000fe73e8 swift::constraints::ConstraintSystem::shrink(swift::Expr*) + 648
17 swift           0x0000000000fe75d1 swift::constraints::ConstraintSystem::solve(swift::Expr*&, swift::Type, swift::ExprTypeCheckListener*, llvm::SmallVectorImpl<swift::constraints::Solution>&, swift::FreeTypeVariableBinding) + 65
18 swift           0x0000000000ec5d33 swift::TypeChecker::solveForExpression(swift::Expr*&, swift::DeclContext*, swift::Type, swift::FreeTypeVariableBinding, swift::ExprTypeCheckListener*, swift::constraints::ConstraintSystem&, llvm::SmallVectorImpl<swift::constraints::Solution>&, swift::OptionSet<swift::TypeCheckExprFlags, unsigned int>) + 403
19 swift           0x0000000000ec9455 swift::TypeChecker::typeCheckExpression(swift::Expr*&, swift::DeclContext*, swift::TypeLoc, swift::ContextualTypePurpose, swift::OptionSet<swift::TypeCheckExprFlags, unsigned int>, swift::ExprTypeCheckListener*, swift::constraints::ConstraintSystem*) + 949
20 swift           0x0000000000ece2f4 swift::TypeChecker::typeCheckCondition(swift::Expr*&, swift::DeclContext*) + 180
21 swift           0x0000000000eceb3e swift::TypeChecker::typeCheckExprPattern(swift::ExprPattern*, swift::DeclContext*, swift::Type) + 894
22 swift           0x0000000000f22ebf swift::TypeChecker::coercePatternToType(swift::Pattern*&, swift::DeclContext*, swift::Type, swift::OptionSet<swift::TypeResolutionFlags, unsigned int>, swift::GenericTypeResolver*, swift::TypeLoc) + 2879
23 swift           0x0000000000f226ca swift::TypeChecker::coercePatternToType(swift::Pattern*&, swift::DeclContext*, swift::Type, swift::OptionSet<swift::TypeResolutionFlags, unsigned int>, swift::GenericTypeResolver*, swift::TypeLoc) + 842
24 swift           0x0000000000f222a1 swift::TypeChecker::typeCheckPattern(swift::Pattern*, swift::DeclContext*, swift::OptionSet<swift::TypeResolutionFlags, unsigned int>, swift::GenericTypeResolver*) + 1041
25 swift           0x0000000000ece40d swift::TypeChecker::typeCheckStmtCondition(llvm::MutableArrayRef<swift::StmtConditionElement>&, swift::DeclContext*, swift::Diag<>) + 189
29 swift           0x0000000000f4a52a swift::TypeChecker::typeCheckFunctionBodyUntil(swift::FuncDecl*, swift::SourceLoc) + 346
30 swift           0x0000000000f4a38e swift::TypeChecker::typeCheckAbstractFunctionBodyUntil(swift::AbstractFunctionDecl*, swift::SourceLoc) + 46
31 swift           0x0000000000f4af63 swift::TypeChecker::typeCheckAbstractFunctionBody(swift::AbstractFunctionDecl*) + 179
33 swift           0x0000000000f045c1 swift::performTypeChecking(swift::SourceFile&, swift::TopLevelContext&, swift::OptionSet<swift::TypeCheckingFlags, unsigned int>, unsigned int, unsigned int) + 1281
34 swift           0x0000000000c86e69 swift::CompilerInstance::performSema() + 3289
36 swift           0x00000000007e0947 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 2887
37 swift           0x00000000007a8e08 main + 2984
Stack dump:
0.	Program arguments: /path/to/swift/bin/swift -frontend -c -primary-file validation-test/compiler_crashers/28426-swift-expr-walk.swift -target x86_64-unknown-linux-gnu -disable-objc-interop -module-name main -o /tmp/28426-swift-expr-walk-c7d0ab.o
1.	While type-checking 'a' at validation-test/compiler_crashers/28426-swift-expr-walk.swift:10:1
2.	While type-checking pattern at [validation-test/compiler_crashers/28426-swift-expr-walk.swift:10:17 - line:10:19] RangeText="a<T"
3.	While type-checking expression at [validation-test/compiler_crashers/28426-swift-expr-walk.swift:10:17 - line:10:19] RangeText="a<T"
<unknown>:0: error: unable to execute command: Aborted
<unknown>:0: error: compile command failed due to signal (use -v to see invocation)
```
2016-09-23 11:23:58 +02:00
practicalswift
d5a9b73564 [SIL] Add test case for crash triggered in swift::SourceFile::LookupCache::lookupClassMembers(llvm::ArrayRef<std::pair<swift::Identifier, swift::SourceLoc> >, swift::VisibleDeclConsumer&, swift::SourceFile const&)
Stack trace:

```
<stdin>:3:1: error: statement cannot begin with a closure expression
{
^
<stdin>:3:1: note: explicitly discard the result of the closure by assigning to '_'
{
^
_ =
<stdin>:4:3: error: consecutive statements on a line must be separated by ';'
()AnyObject
  ^
  ;
<stdin>:3:1: error: expressions are not allowed at the top level
{
^
<stdin>:3:1: error: braced block of statements is an unused closure
{
^
<stdin>:8:22: error: unnamed parameters must be written with the empty name '_'
class b{@objc func a(c)
                     ^
                     _:
<stdin>:8:24: error: consecutive declarations on a line must be separated by ';'
class b{@objc func a(c)
                       ^
                       ;
<stdin>:8:24: error: expected declaration
class b{@objc func a(c)
                       ^
<stdin>:8:7: note: in declaration of 'b'
class b{@objc func a(c)
      ^
<stdin>:8:22: error: use of undeclared type 'c'
class b{@objc func a(c)
                     ^
sil-opt: /path/to/llvm/include/llvm/Support/Casting.h:237: typename cast_retty<X, Y *>::ret_type llvm::cast(Y *) [X = swift::AnyFunctionType, Y = swift::TypeBase]: Assertion `isa<X>(Val) && "cast<Ty>() argument of incompatible type!"' failed.
9  sil-opt         0x0000000000e51dd3 swift::SourceFile::LookupCache::lookupClassMembers(llvm::ArrayRef<std::pair<swift::Identifier, swift::SourceLoc> >, swift::VisibleDeclConsumer&, swift::SourceFile const&) + 787
10 sil-opt         0x0000000000e532a2 swift::ModuleDecl::lookupClassMembers(llvm::ArrayRef<std::pair<swift::Identifier, swift::SourceLoc> >, swift::VisibleDeclConsumer&) const + 50
12 sil-opt         0x0000000000e582ed swift::ModuleDecl::forAllVisibleModules(llvm::ArrayRef<std::pair<swift::Identifier, swift::SourceLoc> >, bool, llvm::function_ref<bool (std::pair<llvm::ArrayRef<std::pair<swift::Identifier, swift::SourceLoc> >, swift::ModuleDecl*>)>) + 477
13 sil-opt         0x0000000000e58461 swift::FileUnit::forAllVisibleModules(llvm::function_ref<bool (std::pair<llvm::ArrayRef<std::pair<swift::Identifier, swift::SourceLoc> >, swift::ModuleDecl*>)>) + 81
17 sil-opt         0x0000000000b3a51b swift::TypeChecker::performTypoCorrection(swift::DeclContext*, swift::DeclRefKind, swift::Type, swift::DeclName, swift::SourceLoc, swift::OptionSet<swift::NameLookupFlags, unsigned int>, swift::LookupResult&, unsigned int) + 267
19 sil-opt         0x0000000000bb1773 swift::constraints::ConstraintSystem::diagnoseFailureForExpr(swift::Expr*) + 2899
20 sil-opt         0x0000000000bb750e swift::constraints::ConstraintSystem::salvage(llvm::SmallVectorImpl<swift::constraints::Solution>&, swift::Expr*) + 4078
21 sil-opt         0x0000000000adf6f7 swift::TypeChecker::solveForExpression(swift::Expr*&, swift::DeclContext*, swift::Type, swift::FreeTypeVariableBinding, swift::ExprTypeCheckListener*, swift::constraints::ConstraintSystem&, llvm::SmallVectorImpl<swift::constraints::Solution>&, swift::OptionSet<swift::TypeCheckExprFlags, unsigned int>) + 471
22 sil-opt         0x0000000000ae2dd5 swift::TypeChecker::typeCheckExpression(swift::Expr*&, swift::DeclContext*, swift::TypeLoc, swift::ContextualTypePurpose, swift::OptionSet<swift::TypeCheckExprFlags, unsigned int>, swift::ExprTypeCheckListener*, swift::constraints::ConstraintSystem*) + 949
25 sil-opt         0x0000000000b66b94 swift::TypeChecker::typeCheckClosureBody(swift::ClosureExpr*) + 244
26 sil-opt         0x0000000000b93f5c swift::constraints::ConstraintSystem::applySolution(swift::constraints::Solution&, swift::Expr*, swift::Type, bool, bool, bool) + 876
27 sil-opt         0x0000000000ae2e86 swift::TypeChecker::typeCheckExpression(swift::Expr*&, swift::DeclContext*, swift::TypeLoc, swift::ContextualTypePurpose, swift::OptionSet<swift::TypeCheckExprFlags, unsigned int>, swift::ExprTypeCheckListener*, swift::constraints::ConstraintSystem*) + 1126
29 sil-opt         0x0000000000b66cd6 swift::TypeChecker::typeCheckTopLevelCodeDecl(swift::TopLevelCodeDecl*) + 134
30 sil-opt         0x0000000000b1f3cd swift::performTypeChecking(swift::SourceFile&, swift::TopLevelContext&, swift::OptionSet<swift::TypeCheckingFlags, unsigned int>, unsigned int, unsigned int) + 1133
31 sil-opt         0x00000000007758a9 swift::CompilerInstance::performSema() + 3289
32 sil-opt         0x000000000075ec65 main + 1813
Stack dump:
0.	Program arguments: sil-opt -enable-sil-verify-all
1.	While type-checking expression at [<stdin>:3:1 - line:6:1] RangeText="{
()AnyObject
.n
}"
2.	While type-checking expression at [<stdin>:4:3 - line:5:2] RangeText="AnyObject
.n"
```
2016-09-23 11:22:42 +02:00
practicalswift
c4a6c054b1 Merge pull request #4855 from practicalswift/spacing-consistency
[gardening] Increase consistency with regards to spacing after colons
2016-09-23 11:20:23 +02:00
swift-ci
96e078f9ce Merge pull request #4952 from DougGregor/ckerror-bridging-27936562 2016-09-23 00:37:01 -07:00
Slava Pestov
a9c68c0736 AST: Remove archetype from AbstractTypeParamDecl
There's a bit of a hack to deal with generic typealiases, but
overall this makes things more logical.

This is the last big refactoring before we can allow constrained
extensions to make generic parameters concrete. All that remains
is a small set of changes to SIL type lowering, and retooling
some diagnostics in Sema.
2016-09-22 19:48:30 -07:00
swift-ci
675e542f3b Merge pull request #4939 from rudkx/fix-27830834 2016-09-22 18:02:09 -07:00
Mark Lacey
b44a93ea84 Fix crash on typecheck failure in interpolated strings.
We were attempting to clean up stray type variables before creating a
new constraint system and moving forward with narrowing down the
typecheck failure, but we were failing to remove type variables for
interpolated strings.

Fix that, as well as removing them from TypeExpr's, and add an assert
that on exit from the pre-order visitor we don't have any type
variables (except for literals that aren't interpolated strings, which
I'm going to dig into further).

Fixes rdar://problem/27830834 and SR-2716.
2016-09-22 17:09:31 -07:00
Doug Gregor
a60f7d7702 [AnyHashable tests] Minor NFC cleanup 2016-09-22 16:31:33 -07:00
Doug Gregor
6f34118cb6 [AnyHashable] Handle comparisons/casting for wrappers around bridged types.
Swift value types are their bridged Objective-C classes can have
different hash values. To address this, AnyHashable's responds to the
_HasCustomAnyHashableRepresentation protocol, which bridge objects of
those class types---NSString, NSNumber, etc---into their Swift
counterparts. That way, we get consistent (Swift) hashing behavior
across platforms.

However, there are cases where multiple Swift value types map to the
same Objective-C class type. In such cases, AnyHashable ends up
converting the object of class type back to some canonical type. For
example, an NS_STRING_ENUM (such as (NS)RunLoopMode) is a Swift
wrapper around a String. If an (NS)RunLoopMode is placed into an
AnyHashable, it maintains it's Swift type identity (which is correct
behavior). If it is bridged to Objective-C, it becomes an NSString; if
that NSString is placed into an AnyHashable, it produces a String. The
hash values still line up, but equality of the AnyHashable values
fails, which breaks when (for example) a dictionary with AnyHashable
keys is used from Objective-C. See SR-2648 / rdar://problem/27992351
for a case where this breaks interoperability.

To address this problem, make AnyHashable's casting and equality
sensitive to the origin of the hashed value: if the AnyHashable was
created through a _HasCustomAnyHashableRepresentation conformance,
treat comparisons/casting from it as "fuzzy":

* For equality, if one of the AnyHashable's comes from a custom
  representation (e.g., it originated with an Objective-C type like
  NSString) but the other did not, bridge the value of the *other*
  AnyHashable to Objective-C, re-wrap it in an AnyHashable, and
  compare that. This allows, e.g., an (NS)RunLoopMode created in Swift
  to compare to an NSString constant with the same string value.
* For casting, if the AnyHashable we're casting from came from a
  custom representation and the cast would fail, bridge to Objective-C
  and then initiate the cast again. This allows an NSString to be
  casted to (NS)RunLoopMode.

Fixes SR-2648 / rdar://problem/27992351.
2016-09-22 14:16:21 -07:00
practicalswift
ef8e43b519 [gardening] Increase consistency with regards to spacing after colons 2016-09-22 16:28:57 +02:00
Max Moiseev
ea8e0f0e15 Merge remote-tracking branch 'origin/master' into new-integer-protocols 2016-09-21 14:48:35 -07:00
Doug Gregor
f1a4dd7631 Merge pull request #4479 from gmilos/SR-755-linux-fatal-stacktrace-symbolication
[SR-755] Tool for re-symbolicating fatal stacktraces on Linux.
2016-09-21 10:13:21 -07:00
Erik Eckstein
9d631eb3d9 tests: use Set<Int> instead of Dictionary<Int, Void> 2016-09-20 16:34:51 -07:00
Erik Eckstein
8b1184708e stdlib: replace _squeezeHashValue with a specialized version for power-of-2 ranges.
This function is only used for Set and Dictionary and there the range (which is the capacity) is always a power of 2.
2016-09-20 16:34:51 -07:00
Grzegorz Miłoś
f96b655a89 Merge remote-tracking branch 'upstream/master' into SR-755-linux-fatal-stacktrace-symbolication 2016-09-20 18:24:04 +01:00
practicalswift
58a87c63e4 [swiftc (74 vs. 5163)] Add crasher in swift::constraints::Solution::convertBooleanTypeToBuiltinI1(...)
Add test case for crash triggered in `swift::constraints::Solution::convertBooleanTypeToBuiltinI1(...)`.

Current number of unresolved compiler crashers: 74 (5163 resolved)

Assertion failure in [`lib/Sema/TypeCheckNameLookup.cpp (line 254)`](https://github.com/apple/swift/blob/master/lib/Sema/TypeCheckNameLookup.cpp#L254):

```
Assertion `!type->is<TupleType>()' failed.

When executing: swift::LookupResult swift::TypeChecker::lookupMember(swift::DeclContext *, swift::Type, swift::DeclName, NameLookupOptions)
```

Assertion context:

```
  // We handle our own overriding/shadowing filtering.
  subOptions &= ~NL_RemoveOverridden;
  subOptions &= ~NL_RemoveNonVisible;

  // We can't have tuple types here; they need to be handled elsewhere.
  assert(!type->is<TupleType>());

  // Local function that performs lookup.
  auto doLookup = [&]() {
    result.clear();

```
Stack trace:

```
swift: /path/to/swift/lib/Sema/TypeCheckNameLookup.cpp:254: swift::LookupResult swift::TypeChecker::lookupMember(swift::DeclContext *, swift::Type, swift::DeclName, NameLookupOptions): Assertion `!type->is<TupleType>()' failed.
9  swift           0x0000000000f7f779 swift::constraints::Solution::convertBooleanTypeToBuiltinI1(swift::Expr*, swift::constraints::ConstraintLocator*) const + 169
10 swift           0x0000000000ec95ab swift::TypeChecker::typeCheckExpression(swift::Expr*&, swift::DeclContext*, swift::TypeLoc, swift::ContextualTypePurpose, swift::OptionSet<swift::TypeCheckExprFlags, unsigned int>, swift::ExprTypeCheckListener*, swift::constraints::ConstraintSystem*) + 1291
11 swift           0x0000000000ece2f4 swift::TypeChecker::typeCheckCondition(swift::Expr*&, swift::DeclContext*) + 180
12 swift           0x0000000000ece44b swift::TypeChecker::typeCheckStmtCondition(llvm::MutableArrayRef<swift::StmtConditionElement>&, swift::DeclContext*, swift::Diag<>) + 251
16 swift           0x0000000000f4b744 swift::TypeChecker::typeCheckClosureBody(swift::ClosureExpr*) + 244
17 swift           0x0000000000f78aec swift::constraints::ConstraintSystem::applySolution(swift::constraints::Solution&, swift::Expr*, swift::Type, bool, bool, bool) + 876
18 swift           0x0000000000ec9506 swift::TypeChecker::typeCheckExpression(swift::Expr*&, swift::DeclContext*, swift::TypeLoc, swift::ContextualTypePurpose, swift::OptionSet<swift::TypeCheckExprFlags, unsigned int>, swift::ExprTypeCheckListener*, swift::constraints::ConstraintSystem*) + 1126
21 swift           0x0000000000f4adf5 swift::TypeChecker::typeCheckDestructorBodyUntil(swift::DestructorDecl*, swift::SourceLoc) + 181
22 swift           0x0000000000f4a37b swift::TypeChecker::typeCheckAbstractFunctionBodyUntil(swift::AbstractFunctionDecl*, swift::SourceLoc) + 27
23 swift           0x0000000000f4af63 swift::TypeChecker::typeCheckAbstractFunctionBody(swift::AbstractFunctionDecl*) + 179
25 swift           0x0000000000f045c1 swift::performTypeChecking(swift::SourceFile&, swift::TopLevelContext&, swift::OptionSet<swift::TypeCheckingFlags, unsigned int>, unsigned int, unsigned int) + 1281
26 swift           0x0000000000c86e69 swift::CompilerInstance::performSema() + 3289
28 swift           0x00000000007e0947 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 2887
29 swift           0x00000000007a8e08 main + 2984
Stack dump:
0.	Program arguments: /path/to/swift/bin/swift -frontend -c -primary-file validation-test/compiler_crashers/28425-swift-constraints-solution-convertbooleantypetobuiltini.swift -target x86_64-unknown-linux-gnu -disable-objc-interop -module-name main -o /tmp/28425-swift-constraints-solution-convertbooleantypetobuiltini-0c6692.o
1.	While type-checking 'deinit' at validation-test/compiler_crashers/28425-swift-constraints-solution-convertbooleantypetobuiltini.swift:10:9
2.	While type-checking expression at [validation-test/compiler_crashers/28425-swift-constraints-solution-convertbooleantypetobuiltini.swift:10:16 - line:10:22] RangeText="{if(x:f"
3.	While type-checking expression at [validation-test/compiler_crashers/28425-swift-constraints-solution-convertbooleantypetobuiltini.swift:10:19 - line:10:22] RangeText="(x:f"
<unknown>:0: error: unable to execute command: Aborted
<unknown>:0: error: compile command failed due to signal (use -v to see invocation)
```
2016-09-20 11:19:18 +02:00
swift-ci
b0083654df Merge pull request #4882 from practicalswift/swiftc-28424-swift-valuedecl-getformalaccessscope 2016-09-20 02:08:24 -07:00
practicalswift
886985f5fb [swiftc (73 vs. 5163)] Add crasher in swift::ValueDecl::getFormalAccessScope(...)
Add test case for crash triggered in `swift::ValueDecl::getFormalAccessScope(...)`.

Current number of unresolved compiler crashers: 73 (5163 resolved)

Stack trace:

```
4  swift           0x000000000110d7bb swift::ValueDecl::getFormalAccessScope(swift::DeclContext const*) const + 11
6  swift           0x0000000000f28a57 swift::TypeChecker::checkConformance(swift::NormalProtocolConformance*) + 2103
7  swift           0x0000000000f28f67 swift::TypeChecker::checkConformancesInContext(swift::DeclContext*, swift::IterableDeclContext*) + 487
14 swift           0x0000000000edfc26 swift::TypeChecker::typeCheckDecl(swift::Decl*, bool) + 150
17 swift           0x0000000000f4b744 swift::TypeChecker::typeCheckClosureBody(swift::ClosureExpr*) + 244
18 swift           0x0000000000f78aec swift::constraints::ConstraintSystem::applySolution(swift::constraints::Solution&, swift::Expr*, swift::Type, bool, bool, bool) + 876
19 swift           0x0000000000ec9506 swift::TypeChecker::typeCheckExpression(swift::Expr*&, swift::DeclContext*, swift::TypeLoc, swift::ContextualTypePurpose, swift::OptionSet<swift::TypeCheckExprFlags, unsigned int>, swift::ExprTypeCheckListener*, swift::constraints::ConstraintSystem*) + 1126
22 swift           0x0000000000f4a52a swift::TypeChecker::typeCheckFunctionBodyUntil(swift::FuncDecl*, swift::SourceLoc) + 346
23 swift           0x0000000000f4a38e swift::TypeChecker::typeCheckAbstractFunctionBodyUntil(swift::AbstractFunctionDecl*, swift::SourceLoc) + 46
24 swift           0x0000000000f4af63 swift::TypeChecker::typeCheckAbstractFunctionBody(swift::AbstractFunctionDecl*) + 179
26 swift           0x0000000000f045c1 swift::performTypeChecking(swift::SourceFile&, swift::TopLevelContext&, swift::OptionSet<swift::TypeCheckingFlags, unsigned int>, unsigned int, unsigned int) + 1281
27 swift           0x0000000000c86e69 swift::CompilerInstance::performSema() + 3289
29 swift           0x00000000007e0947 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 2887
30 swift           0x00000000007a8e08 main + 2984
Stack dump:
0.	Program arguments: /path/to/swift/bin/swift -frontend -c -primary-file validation-test/compiler_crashers/28424-swift-valuedecl-getformalaccessscope.swift -target x86_64-unknown-linux-gnu -disable-objc-interop -module-name main -o /tmp/28424-swift-valuedecl-getformalaccessscope-60fe38.o
1.	While type-checking '<' at validation-test/compiler_crashers/28424-swift-valuedecl-getformalaccessscope.swift:9:1
2.	While type-checking expression at [validation-test/compiler_crashers/28424-swift-valuedecl-getformalaccessscope.swift:9:7 - line:9:41] RangeText="{protocol A{func<extension{enum B:A"
3.	While type-checking 'A' at validation-test/compiler_crashers/28424-swift-valuedecl-getformalaccessscope.swift:9:8
<unknown>:0: error: unable to execute command: Segmentation fault
<unknown>:0: error: compile command failed due to signal (use -v to see invocation)
```
2016-09-20 10:26:58 +02:00
practicalswift
47e31d5439 [SIL] Add test case for crash triggered in llvm::llvm_unreachable_internal(char const*, char const*, unsigned int)
Stack trace:

```
<stdin>:3:9: error: expected '>' to complete generic parameter list
func l<X{weak var c:X
        ^
<stdin>:3:7: note: to match this opening '<'
func l<X{weak var c:X
      ^
<stdin>:3:9: error: expected '(' in argument list of function declaration
func l<X{weak var c:X
        ^
<stdin>:3:22: error: expected '}' at end of brace statement
func l<X{weak var c:X
                     ^
<stdin>:3:9: note: to match this opening '{'
func l<X{weak var c:X
        ^
Dependent types can't answer reference-semantics query
UNREACHABLE executed at /path/to/swift/lib/AST/Type.cpp:174!
6  sil-opt         0x000000000309743d llvm::llvm_unreachable_internal(char const*, char const*, unsigned int) + 461
7  sil-opt         0x0000000000e77e13 swift::CanType::isReferenceTypeImpl(swift::CanType, bool) + 419
8  sil-opt         0x0000000000c2f52e swift::TypeChecker::checkOwnershipAttr(swift::VarDecl*, swift::OwnershipAttr*) + 190
9  sil-opt         0x0000000000c2f27c swift::TypeChecker::checkTypeModifyingDeclAttributes(swift::VarDecl*) + 76
10 sil-opt         0x0000000000b3dc8c swift::TypeChecker::coercePatternToType(swift::Pattern*&, swift::DeclContext*, swift::Type, swift::OptionSet<swift::TypeResolutionFlags, unsigned int>, swift::GenericTypeResolver*, swift::TypeLoc) + 2076
11 sil-opt         0x0000000000b3d391 swift::TypeChecker::typeCheckPattern(swift::Pattern*, swift::DeclContext*, swift::OptionSet<swift::TypeResolutionFlags, unsigned int>, swift::GenericTypeResolver*) + 1041
14 sil-opt         0x0000000000af99b6 swift::TypeChecker::typeCheckDecl(swift::Decl*, bool) + 150
17 sil-opt         0x0000000000b6597a swift::TypeChecker::typeCheckFunctionBodyUntil(swift::FuncDecl*, swift::SourceLoc) + 346
18 sil-opt         0x0000000000b657de swift::TypeChecker::typeCheckAbstractFunctionBodyUntil(swift::AbstractFunctionDecl*, swift::SourceLoc) + 46
19 sil-opt         0x0000000000b663b3 swift::TypeChecker::typeCheckAbstractFunctionBody(swift::AbstractFunctionDecl*) + 179
21 sil-opt         0x0000000000b1f461 swift::performTypeChecking(swift::SourceFile&, swift::TopLevelContext&, swift::OptionSet<swift::TypeCheckingFlags, unsigned int>, unsigned int, unsigned int) + 1281
22 sil-opt         0x00000000007758a9 swift::CompilerInstance::performSema() + 3289
23 sil-opt         0x000000000075ec65 main + 1813
Stack dump:
0.	Program arguments: sil-opt -enable-sil-verify-all
1.	While type-checking 'l' at <stdin>:3:1
2.	While type-checking declaration 0x5752658 at <stdin>:3:15
```
2016-09-20 10:24:11 +02:00
swift-ci
a995e3163e Merge pull request #4858 from practicalswift/sil-035-swift-typebase-getcanonicaltype 2016-09-20 01:19:39 -07:00
Greg Parker
9666d8d39a [test] Add a timeout to runRaceTest(). Use it to limit test AtomicInt.swift. (#4815)
[test] Add a timeout to runRaceTest(). Use it to limit test AtomicInt.swift.

This cuts AtomicInt.swift's execution time from several hours to
about ten minutes on slow hardware and slow build configurations.
2016-09-19 21:46:25 -07:00
Slava Pestov
ced715cb46 Sema: Fix crash when attempting to diagnose a contextual conversion of an ambiguous expression
The fixits call back into the type checker via typeCheckCheckedCast(),
which sets up a new constraint system. As a result we would hit
assertions by introducing type variables from a previous "generation".

It seems that if we bail out of this code path altogether, we get a
better diagnostic -- in the provided test, it complains about an
ambiguous member to '.value', rather than not being able to convert
_? to V?.

Fixes <https://bugs.swift.org/browse/SR-2592>.
2016-09-19 17:53:05 -07:00
airspeedswift
ed5231b47c Numbered all FIXME(ABI) entries for tracking purposes. (#4868) 2016-09-19 16:41:41 -07:00
Mark Lacey
126b9fcb2a Do not recurse infinitely when type checking constructor parameters.
Fully-qualified references to associated types in parameter lists of
constructors could result in infinite recursion and crash the compiler
when the typealias for the associated type is not defined.

Use the same approach used in normal function parameter lists of setting
IsBeingTypeChecked on the enclosing type to avoid going into an infinite
recursion here.

Resolves rdar://problem/27680407.
2016-09-19 14:55:25 -07:00
practicalswift
714ec9db28 [swiftc (73 vs. 5162)] Add crasher in swift::TypeChecker::validateDecl(...)
Add test case for crash triggered in `swift::TypeChecker::validateDecl(...)`.

Current number of unresolved compiler crashers: 73 (5162 resolved)

Assertion failure in [`lib/AST/GenericEnvironment.cpp (line 58)`](https://github.com/apple/swift/blob/master/lib/AST/GenericEnvironment.cpp#L58):

```
Assertion `!type->hasArchetype() && "not fully substituted"' failed.

When executing: swift::Type swift::GenericEnvironment::mapTypeOutOfContext(swift::ModuleDecl *, swift::Type) const
```

Assertion context:

```
  return ctx.Allocate(bytes, alignof(GenericEnvironment), AllocationArena::Permanent);
}

Type GenericEnvironment::mapTypeOutOfContext(ModuleDecl *M, Type type) const {
  type = type.subst(M, ArchetypeToInterfaceMap, SubstFlags::AllowLoweredTypes);
  assert(!type->hasArchetype() && "not fully substituted");
  return type;
}

Type GenericEnvironment::mapTypeIntoContext(ModuleDecl *M, Type type) const {
  type = type.subst(M, InterfaceToArchetypeMap, SubstFlags::AllowLoweredTypes);
```
Stack trace:

```
swift: /path/to/swift/lib/AST/GenericEnvironment.cpp:58: swift::Type swift::GenericEnvironment::mapTypeOutOfContext(swift::ModuleDecl *, swift::Type) const: Assertion `!type->hasArchetype() && "not fully substituted"' failed.
11 swift           0x0000000000eda3b1 swift::TypeChecker::validateDecl(swift::ValueDecl*, bool) + 3857
12 swift           0x0000000001110df7 swift::ProtocolDecl::existentialTypeSupportedSlow(swift::LazyResolver*) + 151
17 swift           0x00000000010aaa04 swift::Decl::walk(swift::ASTWalker&) + 20
18 swift           0x0000000000f5676d swift::TypeChecker::checkUnsupportedProtocolType(swift::Decl*) + 157
24 swift           0x0000000000edfc26 swift::TypeChecker::typeCheckDecl(swift::Decl*, bool) + 150
25 swift           0x0000000000f044c2 swift::performTypeChecking(swift::SourceFile&, swift::TopLevelContext&, swift::OptionSet<swift::TypeCheckingFlags, unsigned int>, unsigned int, unsigned int) + 1026
26 swift           0x0000000000c86e69 swift::CompilerInstance::performSema() + 3289
28 swift           0x00000000007e0947 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 2887
29 swift           0x00000000007a8e08 main + 2984
Stack dump:
0.	Program arguments: /path/to/swift/bin/swift -frontend -c -primary-file validation-test/compiler_crashers/28423-swift-typechecker-validatedecl.swift -target x86_64-unknown-linux-gnu -disable-objc-interop -module-name main -o /tmp/28423-swift-typechecker-validatedecl-a62cc0.o
1.	While type-checking 'a' at validation-test/compiler_crashers/28423-swift-typechecker-validatedecl.swift:11:1
<unknown>:0: error: unable to execute command: Aborted
<unknown>:0: error: compile command failed due to signal (use -v to see invocation)
```
2016-09-19 11:26:02 +02:00
practicalswift
8b3830773c [SIL] Add test case for crash triggered in swift::TypeBase::getCanonicalType()
Stack trace:

```
<stdin>:3:16: warning: operator '<' declared in protocol must be 'static'
protocol f{func<extension{func<
               ^
           static
<stdin>:3:17: error: expected '(' in argument list of function declaration
protocol f{func<extension{func<
                ^
<stdin>:3:17: error: consecutive declarations on a line must be separated by ';'
protocol f{func<extension{func<
                ^
                ;
<stdin>:3:26: error: expected type name in extension declaration
protocol f{func<extension{func<
                         ^
<stdin>:3:32: error: expected '(' in argument list of function declaration
protocol f{func<extension{func<
                               ^
<stdin>:3:32: error: expected declaration
protocol f{func<extension{func<
                               ^
<stdin>:3:17: error: declaration is only valid at file scope
protocol f{func<extension{func<
                ^
<stdin>:3:32: error: consecutive declarations on a line must be separated by ';'
protocol f{func<extension{func<
                               ^
                               ;
<stdin>:3:32: error: expected declaration
protocol f{func<extension{func<
                               ^
<stdin>:3:10: note: in declaration of 'f'
protocol f{func<extension{func<
         ^
<stdin>:3:16: error: operators must have one or two arguments
protocol f{func<extension{func<
               ^
<stdin>:3:16: error: member operator '<()' of protocol 'f' must have at least one argument of type 'Self'
protocol f{func<extension{func<
               ^
<stdin>:3:31: error: operator '<' declared in type '<<error type>>' must be 'static'
protocol f{func<extension{func<
                              ^
                          static
<stdin>:3:31: error: operators must have one or two arguments
protocol f{func<extension{func<
                              ^
4  sil-opt         0x0000000000e76f54 swift::TypeBase::getCanonicalType() + 20
5  sil-opt         0x0000000000e21744 swift::ExtensionDecl::isConstrainedExtension() const + 20
7  sil-opt         0x0000000000b46e40 swift::TypeChecker::inferDefaultWitnesses(swift::ProtocolDecl*) + 288
8  sil-opt         0x0000000000b1fa68 swift::finishTypeChecking(swift::SourceFile&) + 536
9  sil-opt         0x0000000000775a5a swift::CompilerInstance::performSema() + 3722
10 sil-opt         0x000000000075ec65 main + 1813
Stack dump:
0.	Program arguments: sil-opt -enable-sil-verify-all
```
2016-09-19 11:24:28 +02:00
practicalswift
2ee3c45b5b Merge pull request #4852 from practicalswift/optionals-set-to-nil
[gardening] Remove redundant nil-initialization of optional variables
2016-09-19 11:14:31 +02:00
Dave Abrahams
3bf6b60f1e Merge pull request #4825 from apple/stdlib-default-RangeReplaceableCollection.SubSequence
stdlib: make RangeReplaceableCollection.SubSequence a RangeReplaceableCollection
2016-09-18 20:49:53 -07:00
practicalswift
fa7fbdb8b0 [gardening] Remove redundant nil-initialization of optional variable
From the Swift documentation:

"If you define an optional variable without providing a default value,
 the variable is automatically set to nil for you."
2016-09-18 07:40:07 +02:00
Dmitri Gribenko
25378def9d stdlib: make RangeReplaceableCollection.SubSequence a RangeReplaceableCollection
Fixes rdar://problem/28330668.
2016-09-18 03:57:08 +03:00
Dmitri Gribenko
a6d1336a57 Foundation: add tests for associated types on Data 2016-09-18 03:57:07 +03:00
Dmitri Gribenko
1031efeabc Dictionary test: fix intermittent failures
The test was using an index from one dictionary with a different
dictionary instance.
2016-09-17 21:13:26 +03:00
swift-ci
e05afb233d Merge pull request #4844 from practicalswift/swiftc-28422-swift-genericfunctiontype-get 2016-09-16 23:26:47 -07:00
practicalswift
965d271389 [swiftc (72 vs. 5162)] Add crasher in swift::GenericFunctionType::get(...)
Add test case for crash triggered in `swift::GenericFunctionType::get(...)`.

Current number of unresolved compiler crashers: 72 (5162 resolved)

Assertion failure in [`lib/AST/ASTContext.cpp (line 3138)`](https://github.com/apple/swift/blob/master/lib/AST/ASTContext.cpp#L3138):

```
Assertion `!input->hasTypeVariable() && !output->hasTypeVariable()' failed.

When executing: static swift::GenericFunctionType *swift::GenericFunctionType::get(swift::GenericSignature *, swift::Type, swift::Type, const swift::AnyFunctionType::ExtInfo &)
```

Assertion context:

```
GenericFunctionType::get(GenericSignature *sig,
                         Type input,
                         Type output,
                         const ExtInfo &info) {
  assert(sig && "no generic signature for generic function type?!");
  assert(!input->hasTypeVariable() && !output->hasTypeVariable());

  llvm::FoldingSetNodeID id;
  GenericFunctionType::Profile(id, sig, input, output, info);

  const ASTContext &ctx = input->getASTContext();
```
Stack trace:

```
swift: /path/to/swift/lib/AST/ASTContext.cpp:3138: static swift::GenericFunctionType *swift::GenericFunctionType::get(swift::GenericSignature *, swift::Type, swift::Type, const swift::AnyFunctionType::ExtInfo &): Assertion `!input->hasTypeVariable() && !output->hasTypeVariable()' failed.
8  swift           0x0000000001040ffb swift::GenericFunctionType::get(swift::GenericSignature*, swift::Type, swift::Type, swift::AnyFunctionType::ExtInfo const&) + 603
9  swift           0x000000000116c7a9 swift::Type::transform(llvm::function_ref<swift::Type (swift::Type)>) const + 5129
10 swift           0x0000000001164329 swift::Type::subst(swift::ModuleDecl*, llvm::DenseMap<swift::TypeBase*, swift::Type, llvm::DenseMapInfo<swift::TypeBase*>, llvm::detail::DenseMapPair<swift::TypeBase*, swift::Type> > const&, swift::OptionSet<swift::SubstFlags, unsigned int>) const + 89
15 swift           0x0000000000f1f63b swift::TypeChecker::performTypoCorrection(swift::DeclContext*, swift::DeclRefKind, swift::Type, swift::DeclName, swift::SourceLoc, swift::OptionSet<swift::NameLookupFlags, unsigned int>, swift::LookupResult&, unsigned int) + 267
17 swift           0x0000000000f96303 swift::constraints::ConstraintSystem::diagnoseFailureForExpr(swift::Expr*) + 2899
18 swift           0x0000000000f9c09e swift::constraints::ConstraintSystem::salvage(llvm::SmallVectorImpl<swift::constraints::Solution>&, swift::Expr*) + 4078
19 swift           0x0000000000ec5d77 swift::TypeChecker::solveForExpression(swift::Expr*&, swift::DeclContext*, swift::Type, swift::FreeTypeVariableBinding, swift::ExprTypeCheckListener*, swift::constraints::ConstraintSystem&, llvm::SmallVectorImpl<swift::constraints::Solution>&, swift::OptionSet<swift::TypeCheckExprFlags, unsigned int>) + 471
20 swift           0x0000000000ec9455 swift::TypeChecker::typeCheckExpression(swift::Expr*&, swift::DeclContext*, swift::TypeLoc, swift::ContextualTypePurpose, swift::OptionSet<swift::TypeCheckExprFlags, unsigned int>, swift::ExprTypeCheckListener*, swift::constraints::ConstraintSystem*) + 949
21 swift           0x0000000000ecd7e0 swift::TypeChecker::typeCheckBinding(swift::Pattern*&, swift::Expr*&, swift::DeclContext*) + 352
22 swift           0x0000000000ecd9d5 swift::TypeChecker::typeCheckPatternBinding(swift::PatternBindingDecl*, unsigned int) + 229
27 swift           0x0000000000edfc26 swift::TypeChecker::typeCheckDecl(swift::Decl*, bool) + 150
30 swift           0x0000000000f4a52a swift::TypeChecker::typeCheckFunctionBodyUntil(swift::FuncDecl*, swift::SourceLoc) + 346
31 swift           0x0000000000f4a38e swift::TypeChecker::typeCheckAbstractFunctionBodyUntil(swift::AbstractFunctionDecl*, swift::SourceLoc) + 46
32 swift           0x0000000000f4af63 swift::TypeChecker::typeCheckAbstractFunctionBody(swift::AbstractFunctionDecl*) + 179
34 swift           0x0000000000f045c1 swift::performTypeChecking(swift::SourceFile&, swift::TopLevelContext&, swift::OptionSet<swift::TypeCheckingFlags, unsigned int>, unsigned int, unsigned int) + 1281
35 swift           0x0000000000c86e69 swift::CompilerInstance::performSema() + 3289
37 swift           0x00000000007e0947 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 2887
38 swift           0x00000000007a8e08 main + 2984
Stack dump:
0.	Program arguments: /path/to/swift/bin/swift -frontend -c -primary-file validation-test/compiler_crashers/28422-swift-genericfunctiontype-get.swift -target x86_64-unknown-linux-gnu -disable-objc-interop -module-name main -o /tmp/28422-swift-genericfunctiontype-get-8820f1.o
1.	While type-checking 'd' at validation-test/compiler_crashers/28422-swift-genericfunctiontype-get.swift:10:1
2.	While type-checking 'S' at validation-test/compiler_crashers/28422-swift-genericfunctiontype-get.swift:13:1
3.	While type-checking expression at [validation-test/compiler_crashers/28422-swift-genericfunctiontype-get.swift:13:16 - line:13:18] RangeText="d.j"
<unknown>:0: error: unable to execute command: Aborted
<unknown>:0: error: compile command failed due to signal (use -v to see invocation)
```
2016-09-17 07:38:37 +02:00
practicalswift
34c173cb35 [SourceKit] Add test case for crash triggered in swift::GenericEnvironment::GenericEnvironment(llvm::DenseMap<swift::TypeBase*, swift::Type, llvm::DenseMapInfo<swift::TypeBase*>, llvm::detail::DenseMapPair<swift::TypeBase*, swift::Type> >)
Stack trace:

```
found code completion token A at offset 160
swift-ide-test: /path/to/swift/lib/AST/GenericEnvironment.cpp:40: swift::GenericEnvironment::GenericEnvironment(TypeSubstitutionMap): Assertion `result.second && "duplicate generic parameters in environment"' failed.
8  swift-ide-test  0x0000000000c4d578 swift::GenericEnvironment::GenericEnvironment(llvm::DenseMap<swift::TypeBase*, swift::Type, llvm::DenseMapInfo<swift::TypeBase*>, llvm::detail::DenseMapPair<swift::TypeBase*, swift::Type> >) + 728
9  swift-ide-test  0x0000000000b6eea9 swift::GenericEnvironment::get(swift::ASTContext&, llvm::DenseMap<swift::TypeBase*, swift::Type, llvm::DenseMapInfo<swift::TypeBase*>, llvm::detail::DenseMapPair<swift::TypeBase*, swift::Type> >) + 57
10 swift-ide-test  0x0000000000b57c16 swift::ArchetypeBuilder::getGenericEnvironment(llvm::ArrayRef<swift::GenericTypeParamType*>) + 326
11 swift-ide-test  0x00000000009cfdf6 swift::TypeChecker::finalizeGenericParamList(swift::ArchetypeBuilder&, swift::GenericParamList*, swift::GenericSignature*, swift::DeclContext*) + 150
14 swift-ide-test  0x000000000098d101 swift::TypeChecker::validateDecl(swift::ValueDecl*, bool) + 945
17 swift-ide-test  0x0000000000c50ac0 swift::lookupVisibleDecls(swift::VisibleDeclConsumer&, swift::DeclContext const*, swift::LazyResolver*, bool, swift::SourceLoc) + 256
22 swift-ide-test  0x0000000000bcce84 swift::Decl::walk(swift::ASTWalker&) + 20
23 swift-ide-test  0x0000000000c65a5e swift::SourceFile::walk(swift::ASTWalker&) + 174
24 swift-ide-test  0x0000000000c64b7f swift::ModuleDecl::walk(swift::ASTWalker&) + 79
25 swift-ide-test  0x0000000000c3b90b swift::DeclContext::walkContext(swift::ASTWalker&) + 187
26 swift-ide-test  0x00000000008f29c8 swift::performDelayedParsing(swift::DeclContext*, swift::PersistentParserState&, swift::CodeCompletionCallbacksFactory*) + 136
27 swift-ide-test  0x00000000007abd9d swift::CompilerInstance::performSema() + 3597
28 swift-ide-test  0x000000000074d981 main + 36401
Stack dump:
0.	Program arguments: swift-ide-test -code-completion -code-completion-token=A -source-filename=<INPUT-FILE>
1.	While walking into decl getter for a at <INPUT-FILE>:3:6
2.	While type-checking 'a' at <INPUT-FILE>:3:23
```
2016-09-17 07:38:07 +02:00
swift-ci
76428a4c1d Merge pull request #4832 from practicalswift/swiftc-28421-swift-constraints-constraintsystem-diagnosefailureforexpr 2016-09-16 08:11:58 -07:00
practicalswift
8169d4a254 [swiftc (71 vs. 5162)] Add crasher in swift::constraints::ConstraintSystem::diagnoseFailureForExpr(...)
Add test case for crash triggered in `swift::constraints::ConstraintSystem::diagnoseFailureForExpr(...)`.

Current number of unresolved compiler crashers: 71 (5162 resolved)

Assertion failure in [`lib/Sema/TypeCheckNameLookup.cpp (line 254)`](https://github.com/apple/swift/blob/master/lib/Sema/TypeCheckNameLookup.cpp#L254):

```
Assertion `!type->is<TupleType>()' failed.

When executing: swift::LookupResult swift::TypeChecker::lookupMember(swift::DeclContext *, swift::Type, swift::DeclName, NameLookupOptions)
```

Assertion context:

```
  // We handle our own overriding/shadowing filtering.
  subOptions &= ~NL_RemoveOverridden;
  subOptions &= ~NL_RemoveNonVisible;

  // We can't have tuple types here; they need to be handled elsewhere.
  assert(!type->is<TupleType>());

  // Local function that performs lookup.
  auto doLookup = [&]() {
    result.clear();

```
Stack trace:

```
swift: /path/to/swift/lib/Sema/TypeCheckNameLookup.cpp:254: swift::LookupResult swift::TypeChecker::lookupMember(swift::DeclContext *, swift::Type, swift::DeclName, NameLookupOptions): Assertion `!type->is<TupleType>()' failed.
9  swift           0x0000000000f96f16 swift::constraints::ConstraintSystem::diagnoseFailureForExpr(swift::Expr*) + 5990
10 swift           0x0000000000f9c09e swift::constraints::ConstraintSystem::salvage(llvm::SmallVectorImpl<swift::constraints::Solution>&, swift::Expr*) + 4078
11 swift           0x0000000000ec5d77 swift::TypeChecker::solveForExpression(swift::Expr*&, swift::DeclContext*, swift::Type, swift::FreeTypeVariableBinding, swift::ExprTypeCheckListener*, swift::constraints::ConstraintSystem&, llvm::SmallVectorImpl<swift::constraints::Solution>&, swift::OptionSet<swift::TypeCheckExprFlags, unsigned int>) + 471
12 swift           0x0000000000ec9455 swift::TypeChecker::typeCheckExpression(swift::Expr*&, swift::DeclContext*, swift::TypeLoc, swift::ContextualTypePurpose, swift::OptionSet<swift::TypeCheckExprFlags, unsigned int>, swift::ExprTypeCheckListener*, swift::constraints::ConstraintSystem*) + 949
13 swift           0x0000000000ece2f4 swift::TypeChecker::typeCheckCondition(swift::Expr*&, swift::DeclContext*) + 180
17 swift           0x0000000000f4b744 swift::TypeChecker::typeCheckClosureBody(swift::ClosureExpr*) + 244
18 swift           0x0000000000f78aec swift::constraints::ConstraintSystem::applySolution(swift::constraints::Solution&, swift::Expr*, swift::Type, bool, bool, bool) + 876
19 swift           0x0000000000ec9506 swift::TypeChecker::typeCheckExpression(swift::Expr*&, swift::DeclContext*, swift::TypeLoc, swift::ContextualTypePurpose, swift::OptionSet<swift::TypeCheckExprFlags, unsigned int>, swift::ExprTypeCheckListener*, swift::constraints::ConstraintSystem*) + 1126
22 swift           0x0000000000f4a986 swift::TypeChecker::typeCheckConstructorBodyUntil(swift::ConstructorDecl*, swift::SourceLoc) + 854
23 swift           0x0000000000f4a382 swift::TypeChecker::typeCheckAbstractFunctionBodyUntil(swift::AbstractFunctionDecl*, swift::SourceLoc) + 34
24 swift           0x0000000000f4af63 swift::TypeChecker::typeCheckAbstractFunctionBody(swift::AbstractFunctionDecl*) + 179
26 swift           0x0000000000f045c1 swift::performTypeChecking(swift::SourceFile&, swift::TopLevelContext&, swift::OptionSet<swift::TypeCheckingFlags, unsigned int>, unsigned int, unsigned int) + 1281
27 swift           0x0000000000c86e69 swift::CompilerInstance::performSema() + 3289
29 swift           0x00000000007e0947 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 2887
30 swift           0x00000000007a8e08 main + 2984
Stack dump:
0.	Program arguments: /path/to/swift/bin/swift -frontend -c -primary-file validation-test/compiler_crashers/28421-swift-constraints-constraintsystem-diagnosefailureforexpr.swift -target x86_64-unknown-linux-gnu -disable-objc-interop -module-name main -o /tmp/28421-swift-constraints-constraintsystem-diagnosefailureforexpr-aed2bd.o
1.	While type-checking 'init' at validation-test/compiler_crashers/28421-swift-constraints-constraintsystem-diagnosefailureforexpr.swift:12:2
2.	While type-checking expression at [validation-test/compiler_crashers/28421-swift-constraints-constraintsystem-diagnosefailureforexpr.swift:12:12 - line:14:1] RangeText="{
3.	While type-checking expression at [validation-test/compiler_crashers/28421-swift-constraints-constraintsystem-diagnosefailureforexpr.swift:14:1 - line:14:1] RangeText="("
<unknown>:0: error: unable to execute command: Aborted
<unknown>:0: error: compile command failed due to signal (use -v to see invocation)
```
2016-09-16 16:28:48 +02:00
practicalswift
23494931bf [SourceKit] Add test case for crash triggered in swift::TypeChecker::computeDefaultAccessibility(swift::ExtensionDecl*)
Stack trace:

```
found code completion token A at offset 176
swift-ide-test: /path/to/swift/include/swift/AST/Decl.h:1572: void swift::ExtensionDecl::setDefaultAndMaxAccessibility(swift::Accessibility, swift::Accessibility): Assertion `!hasDefaultAccessibility() && "default accessibility already set"' failed.
9  swift-ide-test  0x000000000098ef3b swift::TypeChecker::computeDefaultAccessibility(swift::ExtensionDecl*) + 843
10 swift-ide-test  0x000000000098f4a0 swift::TypeChecker::computeAccessibility(swift::ValueDecl*) + 688
11 swift-ide-test  0x000000000098f81c swift::TypeChecker::validateAccessibility(swift::ValueDecl*) + 76
12 swift-ide-test  0x000000000098cd92 swift::TypeChecker::validateDecl(swift::ValueDecl*, bool) + 66
16 swift-ide-test  0x00000000009936e6 swift::TypeChecker::typeCheckDecl(swift::Decl*, bool) + 150
17 swift-ide-test  0x00000000009b9172 swift::performTypeChecking(swift::SourceFile&, swift::TopLevelContext&, swift::OptionSet<swift::TypeCheckingFlags, unsigned int>, unsigned int, unsigned int) + 1026
18 swift-ide-test  0x00000000007abc69 swift::CompilerInstance::performSema() + 3289
19 swift-ide-test  0x000000000074d981 main + 36401
Stack dump:
0.	Program arguments: swift-ide-test -code-completion -code-completion-token=A -source-filename=<INPUT-FILE>
1.	While type-checking 'A' at <INPUT-FILE>:3:1
```
2016-09-16 16:28:23 +02:00
practicalswift
b19481f887 [gardening] Fix 67 recently introduced typos 2016-09-16 11:16:07 +02:00
Dmitri Gribenko
aa384c66c5 Merge pull request #4812 from apple/stdlib-tests-for-repeated
stdlib: Improve tests for Repeated<Element>
2016-09-15 16:16:17 -07:00
Dmitri Gribenko
f06c34398a stdlib: Improve tests for Repeated<Element> 2016-09-15 13:34:20 -07:00
practicalswift
c2218e3e00 [swiftc (70 vs. 5162)] Add crasher in swift::Lowering::emitConditionalCheckedCast(...)
Add test case for crash triggered in `swift::Lowering::emitConditionalCheckedCast(...)`.

Current number of unresolved compiler crashers: 70 (5162 resolved)

Assertion failure in [`lib/SILGen/SILGenDynamicCast.cpp (line 131)`](https://github.com/apple/swift/blob/master/lib/SILGen/SILGenDynamicCast.cpp#L131):

```
Assertion `operand.getType().isAddress()' failed.

When executing: void (anonymous namespace)::CheckedCastEmitter::emitConditional(swift::Lowering::ManagedValue, swift::CastConsumptionKind, swift::Lowering::SGFContext, const std::function<void (ManagedValue)> &, const std::function<void ()> &)
```

Assertion context:

```

      // Emit the branch.
      SILValue scalarOperandValue;
      SILValue resultBuffer;
      if (Strategy == CastStrategy::Address) {
        assert(operand.getType().isAddress());
        resultBuffer =
          createAbstractResultBuffer(hasAbstraction, origTargetTL, ctx);
        SGF.B.createCheckedCastAddrBranch(Loc, consumption,
                                          operand.forward(SGF), SourceType,
                                          resultBuffer, TargetType,
```
Stack trace:

```
swift: /path/to/swift/lib/SILGen/SILGenDynamicCast.cpp:131: void (anonymous namespace)::CheckedCastEmitter::emitConditional(swift::Lowering::ManagedValue, swift::CastConsumptionKind, swift::Lowering::SGFContext, const std::function<void (ManagedValue)> &, const std::function<void ()> &): Assertion `operand.getType().isAddress()' failed.
9  swift           0x000000000099297c swift::Lowering::emitConditionalCheckedCast(swift::Lowering::SILGenFunction&, swift::SILLocation, swift::Lowering::ManagedValue, swift::Type, swift::Type, swift::CheckedCastKind, swift::Lowering::SGFContext) + 2012
21 swift           0x0000000000944aa2 swift::SILModule::constructSIL(swift::ModuleDecl*, swift::SILOptions&, swift::FileUnit*, llvm::Optional<unsigned int>, bool, bool) + 498
22 swift           0x0000000000945016 swift::performSILGeneration(swift::FileUnit&, swift::SILOptions&, llvm::Optional<unsigned int>, bool) + 118
24 swift           0x00000000007e0947 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 2887
25 swift           0x00000000007a8e08 main + 2984
Stack dump:
0.	Program arguments: /path/to/swift/bin/swift -frontend -c -primary-file validation-test/compiler_crashers/28420-swift-lowering-emitconditionalcheckedcast.swift -target x86_64-unknown-linux-gnu -disable-objc-interop -module-name main -o /tmp/28420-swift-lowering-emitconditionalcheckedcast-0c2422.o
1.	While emitting SIL for 'b' at validation-test/compiler_crashers/28420-swift-lowering-emitconditionalcheckedcast.swift:14:1
<unknown>:0: error: unable to execute command: Aborted
<unknown>:0: error: compile command failed due to signal (use -v to see invocation)
```
2016-09-15 21:57:06 +02:00
swift-ci
d224450389 Merge pull request #4807 from practicalswift/swiftc-28419-swift-silmodule-constructsil 2016-09-15 12:56:03 -07:00
Dmitri Gribenko
2a21011d31 Merge pull request #4802 from apple/stdlib-test-fixes
stdlib: test fixes
2016-09-15 12:40:12 -07:00
practicalswift
427c861477 [swiftc (69 vs. 5162)] Add crasher in swift::SILModule::constructSIL(...)
Add test case for crash triggered in `swift::SILModule::constructSIL(...)`.

Current number of unresolved compiler crashers: 69 (5162 resolved)

Assertion failure in [`lib/SILGen/ManagedValue.h (line 112)`](https://github.com/apple/swift/blob/master/lib/SILGen/ManagedValue.h#L112):

```
Assertion `isLValue() && "This isn't an lvalue"' failed.

When executing: swift::SILValue swift::Lowering::ManagedValue::getLValueAddress() const
```

Assertion context:

```
    // either +0 or trivial (in which case +0 vs +1 doesn't matter).
    return !hasCleanup();
  }

  SILValue getLValueAddress() const {
    assert(isLValue() && "This isn't an lvalue");
    return getValue();
  }

  SILValue getUnmanagedValue() const {
    assert(!hasCleanup());
```
Stack trace:

```
swift: /path/to/swift/lib/SILGen/ManagedValue.h:112: swift::SILValue swift::Lowering::ManagedValue::getLValueAddress() const: Assertion `isLValue() && "This isn't an lvalue"' failed.
14 swift           0x0000000000944dba swift::SILModule::constructSIL(swift::ModuleDecl*, swift::SILOptions&, swift::FileUnit*, llvm::Optional<unsigned int>, bool, bool) + 1290
15 swift           0x0000000000945016 swift::performSILGeneration(swift::FileUnit&, swift::SILOptions&, llvm::Optional<unsigned int>, bool) + 118
17 swift           0x00000000007e0947 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 2887
18 swift           0x00000000007a8e08 main + 2984
Stack dump:
0.	Program arguments: /path/to/swift/bin/swift -frontend -c -primary-file validation-test/compiler_crashers/28419-swift-silmodule-constructsil.swift -target x86_64-unknown-linux-gnu -disable-objc-interop -module-name main -o /tmp/28419-swift-silmodule-constructsil-a782d2.o
<unknown>:0: error: unable to execute command: Aborted
<unknown>:0: error: compile command failed due to signal (use -v to see invocation)
```
2016-09-15 21:23:45 +02:00
practicalswift
1c21516e86 [SourceKit] Add test case for crash triggered in swift::IterativeTypeChecker::satisfy(swift::TypeCheckRequest)
Stack trace:

```
found code completion token A at offset 126
swift-ide-test: /path/to/swift/lib/Sema/IterativeTypeChecker.cpp:103: void swift::IterativeTypeChecker::satisfy(swift::TypeCheckRequest): Assertion `isSatisfied(request)' failed.
9  swift-ide-test  0x0000000000a859d9 swift::IterativeTypeChecker::satisfy(swift::TypeCheckRequest) + 889
12 swift-ide-test  0x000000000098da92 swift::TypeChecker::validateDecl(swift::ValueDecl*, bool) + 3394
15 swift-ide-test  0x00000000009936e6 swift::TypeChecker::typeCheckDecl(swift::Decl*, bool) + 150
16 swift-ide-test  0x00000000009b9172 swift::performTypeChecking(swift::SourceFile&, swift::TopLevelContext&, swift::OptionSet<swift::TypeCheckingFlags, unsigned int>, unsigned int, unsigned int) + 1026
17 swift-ide-test  0x00000000007abc69 swift::CompilerInstance::performSema() + 3289
18 swift-ide-test  0x000000000074d981 main + 36401
Stack dump:
0.	Program arguments: swift-ide-test -code-completion -code-completion-token=A -source-filename=<INPUT-FILE>
1.	While type-checking 'B' at <INPUT-FILE>:4:1
2.	While type-checking 'B' at <INPUT-FILE>:4:1
```
2016-09-15 21:02:28 +02:00
Dmitri Gribenko
39a3a1fb43 Eliminate boilerplate from stdlib tests 2016-09-15 10:20:09 -07:00