Commit Graph

3633 Commits

Author SHA1 Message Date
practicalswift
0a27c393b5 [SourceKit] Add test case for crash triggered in swift::ArchetypeBuilder::PotentialArchetype::getType(swift::ArchetypeBuilder&)
Stack trace:

```
found code completion token A at offset 174
4  swift-ide-test  0x0000000000b3b23c swift::ArchetypeBuilder::PotentialArchetype::getType(swift::ArchetypeBuilder&) + 28
6  swift-ide-test  0x0000000000c78e43 swift::Type::transform(llvm::function_ref<swift::Type (swift::Type)>) const + 35
7  swift-ide-test  0x0000000000c790de swift::Type::transform(llvm::function_ref<swift::Type (swift::Type)>) const + 702
8  swift-ide-test  0x0000000000b3b4ba swift::ArchetypeBuilder::PotentialArchetype::getType(swift::ArchetypeBuilder&) + 666
9  swift-ide-test  0x0000000000b40715 swift::ArchetypeBuilder::getArchetype(swift::GenericTypeParamDecl*) + 53
10 swift-ide-test  0x00000000009c174f swift::TypeChecker::finalizeGenericParamList(swift::ArchetypeBuilder&, swift::GenericParamList*, swift::DeclContext*) + 191
13 swift-ide-test  0x0000000000981713 swift::TypeChecker::validateDecl(swift::ValueDecl*, bool) + 947
18 swift-ide-test  0x0000000000c3e2d5 swift::lookupVisibleDecls(swift::VisibleDeclConsumer&, swift::DeclContext const*, swift::LazyResolver*, bool, swift::SourceLoc) + 1189
19 swift-ide-test  0x00000000009c5442 swift::TypeChecker::performTypoCorrection(swift::DeclContext*, swift::DeclRefKind, swift::Type, swift::DeclName, swift::SourceLoc, swift::OptionSet<swift::NameLookupFlags, unsigned int>, swift::LookupResult&, unsigned int) + 290
20 swift-ide-test  0x000000000096db59 swift::TypeChecker::resolveDeclRefExpr(swift::UnresolvedDeclRefExpr*, swift::DeclContext*) + 3865
22 swift-ide-test  0x0000000000bba3ab swift::Expr::walk(swift::ASTWalker&) + 27
23 swift-ide-test  0x000000000096e3e0 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>) + 224
24 swift-ide-test  0x000000000097570c swift::TypeChecker::getTypeOfExpressionWithoutApplying(swift::Expr*&, swift::DeclContext*, swift::ConcreteDeclRef&, swift::FreeTypeVariableBinding, swift::ExprTypeCheckListener*) + 316
26 swift-ide-test  0x00000000009ac125 swift::getTypeOfCompletionContextExpr(swift::ASTContext&, swift::DeclContext*, swift::CompletionTypeCheckKind, swift::Expr*&, swift::ConcreteDeclRef&) + 693
38 swift-ide-test  0x0000000000bba7f4 swift::Decl::walk(swift::ASTWalker&) + 20
39 swift-ide-test  0x0000000000c52b0e swift::SourceFile::walk(swift::ASTWalker&) + 174
40 swift-ide-test  0x0000000000c51c4f swift::ModuleDecl::walk(swift::ASTWalker&) + 79
41 swift-ide-test  0x0000000000c28e2b swift::DeclContext::walkContext(swift::ASTWalker&) + 187
42 swift-ide-test  0x00000000008ee9f8 swift::performDelayedParsing(swift::DeclContext*, swift::PersistentParserState&, swift::CodeCompletionCallbacksFactory*) + 136
43 swift-ide-test  0x00000000007a6e9d swift::CompilerInstance::performSema() + 3597
44 swift-ide-test  0x000000000074a001 main + 34609
Stack dump:
0.	Program arguments: swift-ide-test -code-completion -code-completion-token=A -source-filename=<INPUT-FILE>
1.	While walking into decl declaration 0x4ebffb0 at <INPUT-FILE>:3:1
2.	While type-checking expression at [<INPUT-FILE>:3:47 - line:3:47] RangeText="t"
3.	While type-checking 'a' at <INPUT-FILE>:3:30
```
2016-07-23 00:26:59 +02:00
practicalswift
e0603225ac Merge pull request #3688 from practicalswift/swiftc-28374-swift-typechecker-resolvewitness
[swiftc (70 vs. 5114)] Add crasher in swift::TypeChecker::resolveWitness(...)
2016-07-23 00:26:28 +02:00
swift-ci
f06092192c Merge pull request #3687 from practicalswift/sourcekit-076-swift-typechecker-checkinheritanceclause 2016-07-22 15:22:48 -07:00
Slava Pestov
ddc51c5917 AST: Implement SE-0102, introducing new semantics for Never alongside @noreturn
No migrator support yet, and the code for @noreturn is still in
place.
2016-07-22 14:56:39 -07:00
practicalswift
2b10fdcc69 Merge pull request #3681 from practicalswift/sourcekit-075-swift-printoptions-setarchetypeselftransform
[SourceKit] Add test case for crash triggered in swift::PrintOptions::setArchetypeSelfTransform(…)
2016-07-22 23:03:08 +02:00
practicalswift
8b52544365 [swiftc (70 vs. 5114)] Add crasher in swift::TypeChecker::resolveWitness(...)
Add test case for crash triggered in `swift::TypeChecker::resolveWitness(...)`.

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

Assertion failure in [`lib/Sema/TypeCheckProtocol.cpp (line 1813)`](https://github.com/apple/swift/blob/master/lib/Sema/TypeCheckProtocol.cpp#L1813):

```
Assertion `(archetype != nullptr || isError) && "Should have built archetypes already"' failed.

When executing: swift::Substitution getArchetypeSubstitution(swift::TypeChecker &, swift::DeclContext *, swift::ArchetypeType *, swift::Type)
```

Assertion context:

```
  assert(!resultReplacement->isTypeParameter() && "Can't be dependent");
  SmallVector<ProtocolConformanceRef, 4> conformances;

  bool isError = replacement->is<ErrorType>();
  assert((archetype != nullptr || isError) &&
         "Should have built archetypes already");

  // FIXME: Turn the nullptr check into an assertion
  if (archetype != nullptr) {
    for (auto proto : archetype->getConformsTo()) {
      ProtocolConformance *conformance = nullptr;
```
Stack trace:

```
swift: /path/to/swift/lib/Sema/TypeCheckProtocol.cpp:1813: swift::Substitution getArchetypeSubstitution(swift::TypeChecker &, swift::DeclContext *, swift::ArchetypeType *, swift::Type): Assertion `(archetype != nullptr || isError) && "Should have built archetypes already"' failed.
11 swift           0x0000000000f13609 swift::TypeChecker::resolveWitness(swift::NormalProtocolConformance const*, swift::ValueDecl*) + 569
12 swift           0x000000000113001b swift::NormalProtocolConformance::getWitness(swift::ValueDecl*, swift::LazyResolver*) const + 171
14 swift           0x0000000000f05d24 swift::TypeChecker::lookupUnqualified(swift::DeclContext*, swift::DeclName, swift::SourceLoc, swift::OptionSet<swift::NameLookupFlags, unsigned int>) + 404
15 swift           0x0000000000eaf03c swift::TypeChecker::resolveDeclRefExpr(swift::UnresolvedDeclRefExpr*, swift::DeclContext*) + 108
17 swift           0x000000000108188b swift::Expr::walk(swift::ASTWalker&) + 27
18 swift           0x0000000000eb0770 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>) + 224
19 swift           0x0000000000eb75ad swift::TypeChecker::typeCheckExpression(swift::Expr*&, swift::DeclContext*, swift::TypeLoc, swift::ContextualTypePurpose, swift::OptionSet<swift::TypeCheckExprFlags, unsigned int>, swift::ExprTypeCheckListener*, swift::constraints::ConstraintSystem*) + 621
20 swift           0x0000000000eb8760 swift::TypeChecker::typeCheckBinding(swift::Pattern*&, swift::Expr*&, swift::DeclContext*) + 352
21 swift           0x0000000000eb897b swift::TypeChecker::typeCheckPatternBinding(swift::PatternBindingDecl*, unsigned int) + 267
23 swift           0x0000000000ec4d1d swift::TypeChecker::validateDecl(swift::ValueDecl*, bool) + 3853
29 swift           0x0000000000ec95b6 swift::TypeChecker::typeCheckDecl(swift::Decl*, bool) + 150
30 swift           0x0000000000eebde2 swift::performTypeChecking(swift::SourceFile&, swift::TopLevelContext&, swift::OptionSet<swift::TypeCheckingFlags, unsigned int>, unsigned int, unsigned int) + 1026
31 swift           0x0000000000c735c9 swift::CompilerInstance::performSema() + 3289
33 swift           0x00000000007d9277 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 2887
34 swift           0x00000000007a5278 main + 2872
Stack dump:
0.	Program arguments: /path/to/swift/bin/swift -frontend -c -primary-file validation-test/compiler_crashers/28374-swift-typechecker-resolvewitness.swift -target x86_64-unknown-linux-gnu -disable-objc-interop -module-name main -o /tmp/28374-swift-typechecker-resolvewitness-9c17ae.o
1.	While type-checking 'a' at validation-test/compiler_crashers/28374-swift-typechecker-resolvewitness.swift:10:1
2.	While type-checking expression at [validation-test/compiler_crashers/28374-swift-typechecker-resolvewitness.swift:15:7 - line:15:7] RangeText="B"
<unknown>:0: error: unable to execute command: Aborted
<unknown>:0: error: compile command failed due to signal (use -v to see invocation)
```
2016-07-22 23:01:02 +02:00
practicalswift
2f68b69676 [SourceKit] Add test case for crash triggered in swift::TypeChecker::checkInheritanceClause(swift::Decl*, swift::GenericTypeResolver*)
Stack trace:

```
found code completion token A at offset 163
swift-ide-test: /path/to/swift/lib/AST/ArchetypeBuilder.cpp:2103: static swift::Type swift::ArchetypeBuilder::mapTypeOutOfContext(swift::ModuleDecl *, swift::GenericParamList *, swift::Type): Assertion `!type->hasArchetype() && "not fully substituted"' failed.
9  swift-ide-test  0x000000000097ff7f swift::TypeChecker::checkInheritanceClause(swift::Decl*, swift::GenericTypeResolver*) + 5471
10 swift-ide-test  0x00000000009814d8 swift::TypeChecker::validateDecl(swift::ValueDecl*, bool) + 376
13 swift-ide-test  0x0000000000986d16 swift::TypeChecker::typeCheckDecl(swift::Decl*, bool) + 150
16 swift-ide-test  0x00000000009effe4 swift::TypeChecker::typeCheckClosureBody(swift::ClosureExpr*) + 244
17 swift-ide-test  0x0000000000a268cc swift::constraints::ConstraintSystem::applySolution(swift::constraints::Solution&, swift::Expr*, swift::Type, bool, bool, bool) + 876
18 swift-ide-test  0x00000000009752ba swift::TypeChecker::typeCheckExpression(swift::Expr*&, swift::DeclContext*, swift::TypeLoc, swift::ContextualTypePurpose, swift::OptionSet<swift::TypeCheckExprFlags, unsigned int>, swift::ExprTypeCheckListener*, swift::constraints::ConstraintSystem*) + 778
21 swift-ide-test  0x00000000009eec5a swift::TypeChecker::typeCheckFunctionBodyUntil(swift::FuncDecl*, swift::SourceLoc) + 346
22 swift-ide-test  0x00000000009eeabe swift::TypeChecker::typeCheckAbstractFunctionBodyUntil(swift::AbstractFunctionDecl*, swift::SourceLoc) + 46
23 swift-ide-test  0x00000000009acb6f swift::typeCheckAbstractFunctionBodyUntil(swift::AbstractFunctionDecl*, swift::SourceLoc) + 655
25 swift-ide-test  0x00000000008eeaa1 swift::performDelayedParsing(swift::DeclContext*, swift::PersistentParserState&, swift::CodeCompletionCallbacksFactory*) + 305
26 swift-ide-test  0x00000000007a6e9d swift::CompilerInstance::performSema() + 3597
27 swift-ide-test  0x000000000074a001 main + 34609
Stack dump:
0.	Program arguments: swift-ide-test -code-completion -code-completion-token=A -source-filename=<INPUT-FILE>
1.	While type-checking expression at [<INPUT-FILE>:3:28 - line:3:38] RangeText="{enum a:e)"
2.	While type-checking 'a' at <INPUT-FILE>:3:29
```
2016-07-22 23:00:24 +02:00
practicalswift
0c5156da43 [swiftc (69 vs. 5114)] Add crasher in swift::PrintOptions::setArchetypeSelfTransform(...)
Add test case for crash triggered in `swift::PrintOptions::setArchetypeSelfTransform(...)`.

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

Assertion failure in [`lib/AST/ASTPrinter.cpp (line 68)`](https://github.com/apple/swift/blob/master/lib/AST/ASTPrinter.cpp#L68):

```
Assertion `ParamDecls.size() == Args.size()' failed.

When executing: std::unique_ptr<llvm::DenseMap<StringRef, Type> > swift::collectNameTypeMap(swift::Type)
```

Assertion context:

```
    if (!D || !D->getGenericParams())
      continue;
    SmallVector<Type, 3> Scrach;
    auto Args = BaseTy->getAllGenericArgs(Scrach);
    const auto ParamDecls = D->getGenericParams()->getParams();
    assert(ParamDecls.size() == Args.size());

    // Map type parameter names with their instantiating arguments.
    for (unsigned I = 0, N = ParamDecls.size(); I < N; I++) {
      (*IdMap)[ParamDecls[I]->getName().str()] = Args[I];
    }
```
Stack trace:

```
swift: /path/to/swift/lib/AST/ASTPrinter.cpp:68: std::unique_ptr<llvm::DenseMap<StringRef, Type> > swift::collectNameTypeMap(swift::Type): Assertion `ParamDecls.size() == Args.size()' failed.
9  swift           0x000000000104a240 swift::PrintOptions::setArchetypeSelfTransform(swift::Type, swift::DeclContext*) + 144
13 swift           0x0000000000f10f97 swift::TypeChecker::checkConformance(swift::NormalProtocolConformance*) + 2423
15 swift           0x0000000000eebee1 swift::performTypeChecking(swift::SourceFile&, swift::TopLevelContext&, swift::OptionSet<swift::TypeCheckingFlags, unsigned int>, unsigned int, unsigned int) + 1281
16 swift           0x0000000000c735c9 swift::CompilerInstance::performSema() + 3289
18 swift           0x00000000007d9277 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 2887
19 swift           0x00000000007a5278 main + 2872
Stack dump:
0.	Program arguments: /path/to/swift/bin/swift -frontend -c -primary-file validation-test/compiler_crashers/28373-swift-printoptions-setarchetypeselftransform.swift -target x86_64-unknown-linux-gnu -disable-objc-interop -module-name main -o /tmp/28373-swift-printoptions-setarchetypeselftransform-d50673.o
<unknown>:0: error: unable to execute command: Aborted
<unknown>:0: error: compile command failed due to signal (use -v to see invocation)
```
2016-07-22 19:38:38 +02:00
practicalswift
dd6c5306c1 [SourceKit] Add test case for crash triggered in swift::PrintOptions::setArchetypeSelfTransform(swift::Type, swift::DeclContext*)
Stack trace:

```
found code completion token A at offset 152
swift-ide-test: /path/to/swift/lib/AST/ASTPrinter.cpp:68: std::unique_ptr<llvm::DenseMap<StringRef, Type> > swift::collectNameTypeMap(swift::Type): Assertion `ParamDecls.size() == Args.size()' failed.
9  swift-ide-test  0x0000000000b82c80 swift::PrintOptions::setArchetypeSelfTransform(swift::Type, swift::DeclContext*) + 144
14 swift-ide-test  0x00000000008eeaa1 swift::performDelayedParsing(swift::DeclContext*, swift::PersistentParserState&, swift::CodeCompletionCallbacksFactory*) + 305
15 swift-ide-test  0x00000000007a6e9d swift::CompilerInstance::performSema() + 3597
16 swift-ide-test  0x000000000074a001 main + 34609
Stack dump:
0.	Program arguments: swift-ide-test -code-completion -code-completion-token=A -source-filename=<INPUT-FILE>
```
2016-07-22 19:38:20 +02:00
practicalswift
3d7047e3bf Merge pull request #3669 from practicalswift/swiftc-28372-swift-printoptions-setarchetypeanddynamicselftransform
[swiftc (72 vs. 5110)] Add crasher in swift::PrintOptions::setArchetypeAndDynamicSelfTransform(...)
2016-07-22 17:40:15 +02:00
practicalswift
c6158911cf Merge pull request #3668 from practicalswift/sourcekit-074-swift-valuedecl-geteffectiveaccess
[SourceKit] Add test case for crash triggered in swift::ValueDecl::getEffectiveAccess()
2016-07-22 17:40:00 +02:00
Dmitri Gribenko
f318fe853d Merge pull request #3651 from abl/empty-suffix-prefix
[stdlib/core] hasPrefix/hasSuffix consider the empty string a prefix/suffix of all strings.
2016-07-21 22:33:30 -07:00
Xin Tong
bbf86865d6 Change unicodescalar to failable
We were using a precondition which crashes the program when invalid input is
provided. We want to provide a way to gracefully check and handle invalid input
or shutdown the program if necessary.

SR-1930
2016-07-21 15:27:13 -07:00
practicalswift
2de82e5b8f [swiftc (72 vs. 5110)] Add crasher in swift::PrintOptions::setArchetypeAndDynamicSelfTransform(...)
Add test case for crash triggered in `swift::PrintOptions::setArchetypeAndDynamicSelfTransform(...)`.

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

Assertion failure in [`lib/AST/ASTPrinter.cpp (line 68)`](https://github.com/apple/swift/blob/master/lib/AST/ASTPrinter.cpp#L68):

```
Assertion `ParamDecls.size() == Args.size()' failed.

When executing: std::unique_ptr<llvm::DenseMap<StringRef, Type> > swift::collectNameTypeMap(swift::Type)
```

Assertion context:

```
    if (!D || !D->getGenericParams())
      continue;
    SmallVector<Type, 3> Scrach;
    auto Args = BaseTy->getAllGenericArgs(Scrach);
    const auto ParamDecls = D->getGenericParams()->getParams();
    assert(ParamDecls.size() == Args.size());

    // Map type parameter names with their instantiating arguments.
    for (unsigned I = 0, N = ParamDecls.size(); I < N; I++) {
      (*IdMap)[ParamDecls[I]->getName().str()] = Args[I];
    }
```
Stack trace:

```
swift: /path/to/swift/lib/AST/ASTPrinter.cpp:68: std::unique_ptr<llvm::DenseMap<StringRef, Type> > swift::collectNameTypeMap(swift::Type): Assertion `ParamDecls.size() == Args.size()' failed.
9  swift           0x000000000104b5d2 swift::PrintOptions::setArchetypeAndDynamicSelfTransform(swift::Type, swift::DeclContext*) + 130
13 swift           0x0000000000f11a57 swift::TypeChecker::checkConformance(swift::NormalProtocolConformance*) + 2423
14 swift           0x0000000000f11ec7 swift::TypeChecker::checkConformancesInContext(swift::DeclContext*, swift::IterableDeclContext*) + 471
19 swift           0x0000000000ec9ab6 swift::TypeChecker::typeCheckDecl(swift::Decl*, bool) + 150
22 swift           0x0000000000f32a64 swift::TypeChecker::typeCheckClosureBody(swift::ClosureExpr*) + 244
23 swift           0x0000000000f5e7ac swift::constraints::ConstraintSystem::applySolution(swift::constraints::Solution&, swift::Expr*, swift::Type, bool, bool, bool) + 876
24 swift           0x0000000000eb7b41 swift::TypeChecker::typeCheckExpression(swift::Expr*&, swift::DeclContext*, swift::TypeLoc, swift::ContextualTypePurpose, swift::OptionSet<swift::TypeCheckExprFlags, unsigned int>, swift::ExprTypeCheckListener*) + 769
26 swift           0x0000000000f32ba6 swift::TypeChecker::typeCheckTopLevelCodeDecl(swift::TopLevelCodeDecl*) + 134
27 swift           0x0000000000eec48d swift::performTypeChecking(swift::SourceFile&, swift::TopLevelContext&, swift::OptionSet<swift::TypeCheckingFlags, unsigned int>, unsigned int, unsigned int) + 1133
28 swift           0x0000000000c73849 swift::CompilerInstance::performSema() + 3289
30 swift           0x00000000007d95c7 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 2887
31 swift           0x00000000007a55c8 main + 2872
Stack dump:
0.	Program arguments: /path/to/swift/bin/swift -frontend -c -primary-file validation-test/compiler_crashers/28372-swift-printoptions-setarchetypeanddynamicselftransform.swift -target x86_64-unknown-linux-gnu -disable-objc-interop -module-name main -o /tmp/28372-swift-printoptions-setarchetypeanddynamicselftransform-7809a8.o
1.	While type-checking expression at [validation-test/compiler_crashers/28372-swift-printoptions-setarchetypeanddynamicselftransform.swift:10:1 - line:12:11] RangeText="{protocol a{
2.	While type-checking 'a' at validation-test/compiler_crashers/28372-swift-printoptions-setarchetypeanddynamicselftransform.swift:10:2
<unknown>:0: error: unable to execute command: Aborted
<unknown>:0: error: compile command failed due to signal (use -v to see invocation)
```
2016-07-22 00:03:34 +02:00
practicalswift
1d8d049a9d [SourceKit] Add test case for crash triggered in swift::ValueDecl::getEffectiveAccess() const
Stack trace:

```
found code completion token A at offset 139
swift-ide-test: /path/to/swift/include/swift/AST/Decl.h:2176: swift::Accessibility swift::ValueDecl::getFormalAccess() const: Assertion `hasAccessibility() && "accessibility not computed yet"' failed.
8  swift-ide-test  0x0000000000c1bbae swift::ValueDecl::getEffectiveAccess() const + 606
9  swift-ide-test  0x0000000000c2953d swift::DeclContext::getResilienceExpansion() const + 125
10 swift-ide-test  0x0000000000c1b1b2 swift::ValueDecl::getAccessSemanticsFromContext(swift::DeclContext const*) const + 18
11 swift-ide-test  0x00000000009bcd2d swift::TypeChecker::buildRefExpr(llvm::ArrayRef<swift::ValueDecl*>, swift::DeclContext*, swift::DeclNameLoc, bool, bool) + 125
12 swift-ide-test  0x000000000096e2bd swift::TypeChecker::resolveDeclRefExpr(swift::UnresolvedDeclRefExpr*, swift::DeclContext*) + 3437
14 swift-ide-test  0x0000000000bbadfb swift::Expr::walk(swift::ASTWalker&) + 27
15 swift-ide-test  0x000000000096ed30 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>) + 224
16 swift-ide-test  0x0000000000975b62 swift::TypeChecker::typeCheckExpression(swift::Expr*&, swift::DeclContext*, swift::TypeLoc, swift::ContextualTypePurpose, swift::OptionSet<swift::TypeCheckExprFlags, unsigned int>, swift::ExprTypeCheckListener*) + 610
19 swift-ide-test  0x00000000009efbca swift::TypeChecker::typeCheckFunctionBodyUntil(swift::FuncDecl*, swift::SourceLoc) + 346
20 swift-ide-test  0x00000000009efa2e swift::TypeChecker::typeCheckAbstractFunctionBodyUntil(swift::AbstractFunctionDecl*, swift::SourceLoc) + 46
21 swift-ide-test  0x00000000009ad5ff swift::typeCheckAbstractFunctionBodyUntil(swift::AbstractFunctionDecl*, swift::SourceLoc) + 655
25 swift-ide-test  0x0000000000bbb244 swift::Decl::walk(swift::ASTWalker&) + 20
26 swift-ide-test  0x0000000000c53dbe swift::SourceFile::walk(swift::ASTWalker&) + 174
27 swift-ide-test  0x0000000000c52eff swift::ModuleDecl::walk(swift::ASTWalker&) + 79
28 swift-ide-test  0x0000000000c298eb swift::DeclContext::walkContext(swift::ASTWalker&) + 187
29 swift-ide-test  0x00000000008eed68 swift::performDelayedParsing(swift::DeclContext*, swift::PersistentParserState&, swift::CodeCompletionCallbacksFactory*) + 136
30 swift-ide-test  0x00000000007a71ed swift::CompilerInstance::performSema() + 3597
31 swift-ide-test  0x000000000074a351 main + 34593
Stack dump:
0.	Program arguments: swift-ide-test -code-completion -code-completion-token=A -source-filename=<INPUT-FILE>
1.	While walking into decl 'init' at <INPUT-FILE>:3:1
2.	While type-checking expression at [<INPUT-FILE>:3:12 - line:3:12] RangeText="a"
```
2016-07-22 00:02:36 +02:00
Jordan Rose
758cf64283 Rework access checking in terms of "access scopes".
(in preparation for the private/fileprivate split)

An "access scope" is the outermost DeclContext where a particular
declaration may be referenced: for a 'fileprivate' declaration it's
the enclosing file, and for an 'internal' declaration it's the module.
'public' corresponds to a scope of "everything", represented by a null
DeclContext.

This model extends naturally to the (not-yet-implemented) SE-0025
notion of 'private', where the access scope is a declaration's
immediately enclosing DeclContext.

Complicating this model is the revised rules that allow, e.g., a public
declaration to be declared within an internal type. The access scope
for this declaration is still just the module, not "everything".

This commit reworks formal access control checking in terms of this
model, including tightening up some of the handling for '@testable'.
This implements the rule that you must be able to access a declaration's
type everywhere you can reference the declaration.

This was not intended to change compiler behavior, but in practice it
has made cross-file dependency tracking a bit more conservative
(unnecessarily), caught a mistake in diagnosing access violations,
and fixed a fuzzer-based crasher (see test changes).

Progress on SE-0025 ('private' and 'fileprivate')
2016-07-21 14:54:48 -07:00
Doug Gregor
c56f96d237 [Type checker] Synthesize member operator '==' for Equatable enums.
Rather than synthesizing a global operator '==' for Equatable enums,
synthesize a member operator, which is more idiomatic and much
cleaner.

To make sure that these synthesized operators can actually be found,
start considering operator requirements in protocols
more generally in the type checker, so that, e.g., "myEnum == myEnum"
will type-check against Equatable.== and, on successful type-check,
will call the (newly-synthesized) witness for '=='. This both makes it
easier to make sure we find the operators in, e.g., complex multi-file
and lazy-type checking scenarios, and is a step toward the
type-checking improvements described in SE-0091.
2016-07-21 12:54:27 -07:00
swift-ci
a766e6f2d7 Merge pull request #2843 from ahoppen/SR-1236-errors 2016-07-21 10:53:11 -07:00
Nate Cook
29bbff221b [stdlib] Update partition tests with feedback 2016-07-21 10:18:20 -05:00
Nate Cook
1d037800b9 [stdlib] Update tests for new partition APIs
Special thanks to @aschwaighofer for help with these tests and fix-its!
2016-07-21 10:18:20 -05:00
Alexander Lash
9a4caf6c4b [core] hasPrefix/hasSuffix consider the empty string a prefix/suffix of all strings. 2016-07-20 17:46:47 -07:00
practicalswift
17611af7e3 Merge pull request #3646 from practicalswift/swiftc-28371-swift-genericparamlist-getsubstitutionmap
[swiftc (72 vs. 5109)] Add crasher in swift::GenericParamList::getSubstitutionMap(...)
2016-07-21 01:49:33 +02:00
practicalswift
79d43954f7 Merge pull request #3645 from practicalswift/sourcekit-073-swift-archetypebuilder-enumeraterequirements
[SourceKit] Add test case for crash triggered in swift::ArchetypeBuilder::enumerateRequirements(…)
2016-07-21 01:49:19 +02:00
practicalswift
a820296cfc [swiftc (72 vs. 5109)] Add crasher in swift::GenericParamList::getSubstitutionMap(...)
Add test case for crash triggered in `swift::GenericParamList::getSubstitutionMap(...)`.

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

Assertion failure in `llvm/include/llvm/ADT/ArrayRef.h (line 139)`:

```
Assertion `!empty()' failed.

When executing: const T &llvm::ArrayRef<swift::Substitution>::front() const [T = swift::Substitution]
```

Assertion context:

```
    /// size - Get the array size.
    size_t size() const { return Length; }

    /// front - Get the first element.
    const T &front() const {
      assert(!empty());
      return Data[0];
    }

    /// back - Get the last element.
    const T &back() const {
```
Stack trace:

```
swift: /path/to/llvm/include/llvm/ADT/ArrayRef.h:139: const T &llvm::ArrayRef<swift::Substitution>::front() const [T = swift::Substitution]: Assertion `!empty()' failed.
8  swift           0x0000000001136748 swift::GenericParamList::getSubstitutionMap(llvm::ArrayRef<swift::Substitution>) const + 1080
9  swift           0x0000000001127b57 swift::SpecializedProtocolConformance::getTypeWitnessSubstAndDecl(swift::AssociatedTypeDecl*, swift::LazyResolver*) const + 215
10 swift           0x0000000001127862 swift::ProtocolConformance::getTypeWitnessSubstAndDecl(swift::AssociatedTypeDecl*, swift::LazyResolver*) const + 18
11 swift           0x0000000001128046 swift::ProtocolConformance::getTypeWitness(swift::AssociatedTypeDecl*, swift::LazyResolver*) const + 6
12 swift           0x0000000000f32531 swift::TypeChecker::resolveTypeInContext(swift::TypeDecl*, swift::DeclContext*, swift::OptionSet<swift::TypeResolutionFlags, unsigned int>, bool, swift::GenericTypeResolver*, llvm::function_ref<bool (swift::TypeCheckRequest)>*) + 2401
16 swift           0x0000000000f3362e swift::TypeChecker::resolveIdentifierType(swift::DeclContext*, swift::IdentTypeRepr*, swift::OptionSet<swift::TypeResolutionFlags, unsigned int>, bool, swift::GenericTypeResolver*, llvm::function_ref<bool (swift::TypeCheckRequest)>*) + 158
18 swift           0x0000000000f34584 swift::TypeChecker::resolveType(swift::TypeRepr*, swift::DeclContext*, swift::OptionSet<swift::TypeResolutionFlags, unsigned int>, swift::GenericTypeResolver*, llvm::function_ref<bool (swift::TypeCheckRequest)>*) + 164
19 swift           0x0000000000f33520 swift::TypeChecker::validateType(swift::TypeLoc&, swift::DeclContext*, swift::OptionSet<swift::TypeResolutionFlags, unsigned int>, swift::GenericTypeResolver*, llvm::function_ref<bool (swift::TypeCheckRequest)>*) + 192
21 swift           0x0000000000efd7be swift::TypeChecker::validateGenericFuncSignature(swift::AbstractFunctionDecl*) + 94
28 swift           0x0000000000ec55e6 swift::TypeChecker::typeCheckDecl(swift::Decl*, bool) + 150
31 swift           0x0000000000f2d5e4 swift::TypeChecker::typeCheckClosureBody(swift::ClosureExpr*) + 244
32 swift           0x0000000000f593ac swift::constraints::ConstraintSystem::applySolution(swift::constraints::Solution&, swift::Expr*, swift::Type, bool, bool, bool) + 876
33 swift           0x0000000000eb3c81 swift::TypeChecker::typeCheckExpression(swift::Expr*&, swift::DeclContext*, swift::TypeLoc, swift::ContextualTypePurpose, swift::OptionSet<swift::TypeCheckExprFlags, unsigned int>, swift::ExprTypeCheckListener*) + 769
35 swift           0x0000000000f2d726 swift::TypeChecker::typeCheckTopLevelCodeDecl(swift::TopLevelCodeDecl*) + 134
36 swift           0x0000000000ee77cd swift::performTypeChecking(swift::SourceFile&, swift::TopLevelContext&, swift::OptionSet<swift::TypeCheckingFlags, unsigned int>, unsigned int, unsigned int) + 1133
37 swift           0x0000000000c71a09 swift::CompilerInstance::performSema() + 3289
39 swift           0x00000000007d91c9 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 2857
40 swift           0x00000000007a51e8 main + 2872
Stack dump:
0.	Program arguments: /path/to/swift/bin/swift -frontend -c -primary-file validation-test/compiler_crashers/28371-swift-genericparamlist-getsubstitutionmap.swift -target x86_64-unknown-linux-gnu -disable-objc-interop -module-name main -o /tmp/28371-swift-genericparamlist-getsubstitutionmap-a3baf5.o
1.	While type-checking expression at [validation-test/compiler_crashers/28371-swift-genericparamlist-getsubstitutionmap.swift:10:1 - line:10:58] RangeText="{protocol a{protocol b>class B<g:b>:a{func d:e}typealias e"
2.	While type-checking 'a' at validation-test/compiler_crashers/28371-swift-genericparamlist-getsubstitutionmap.swift:10:2
3.	While resolving type e at [validation-test/compiler_crashers/28371-swift-genericparamlist-getsubstitutionmap.swift:10:46 - line:10:46] RangeText="e"
<unknown>:0: error: unable to execute command: Aborted
<unknown>:0: error: compile command failed due to signal (use -v to see invocation)
```
2016-07-21 00:03:06 +02:00
Maxim Moiseev
c2e3369968 Photos overlay (#3613) 2016-07-20 15:01:46 -07:00
practicalswift
57ae3554f3 [SourceKit] Add test case for crash triggered in swift::ArchetypeBuilder::enumerateRequirements(llvm::function_ref<void (swift::RequirementKind, swift::ArchetypeBuilder::PotentialArchetype*, llvm::PointerUnion<swift::Type, swift::ArchetypeBuilder::PotentialArchetype*>, swift::RequirementSource)>)
Stack trace:

```
found code completion token A at offset 160
swift-ide-test: /path/to/swift/lib/AST/GenericSignature.cpp:283: auto swift::GenericSignature::getCanonicalManglingSignature(swift::ModuleDecl &)::(anonymous class)::operator()(swift::RequirementKind, ArchetypeBuilder::PotentialArchetype *, llvm::PointerUnion<Type, ArchetypeBuilder::PotentialArchetype *>, swift::RequirementSource) const: Assertion `constraintType->isExistentialType()' failed.
10 swift-ide-test  0x0000000000b3bf09 swift::ArchetypeBuilder::enumerateRequirements(llvm::function_ref<void (swift::RequirementKind, swift::ArchetypeBuilder::PotentialArchetype*, llvm::PointerUnion<swift::Type, swift::ArchetypeBuilder::PotentialArchetype*>, swift::RequirementSource)>) + 185
11 swift-ide-test  0x0000000000c313e5 swift::GenericSignature::getCanonicalManglingSignature(swift::ModuleDecl&) const + 405
12 swift-ide-test  0x0000000000c3c335 swift::Mangle::Mangler::bindGenericParameters(swift::DeclContext const*) + 53
13 swift-ide-test  0x0000000000c7d7aa swift::ide::printDeclUSR(swift::ValueDecl const*, llvm::raw_ostream&) + 762
15 swift-ide-test  0x00000000007aef68 copyAssociatedUSRs(llvm::BumpPtrAllocatorImpl<llvm::MallocAllocator, 4096ul, 4096ul>&, swift::Decl const*) + 104
16 swift-ide-test  0x00000000007afdec swift::ide::CodeCompletionResultBuilder::takeResult() + 1676
20 swift-ide-test  0x0000000000c362c0 swift::lookupVisibleDecls(swift::VisibleDeclConsumer&, swift::DeclContext const*, swift::LazyResolver*, bool, swift::SourceLoc) + 256
23 swift-ide-test  0x00000000008eccf1 swift::performDelayedParsing(swift::DeclContext*, swift::PersistentParserState&, swift::CodeCompletionCallbacksFactory*) + 305
24 swift-ide-test  0x00000000007a67dd swift::CompilerInstance::performSema() + 3597
25 swift-ide-test  0x0000000000749dd0 main + 34176
Stack dump:
0.	Program arguments: swift-ide-test -code-completion -code-completion-token=A -source-filename=<INPUT-FILE>
```
2016-07-21 00:00:01 +02:00
Dmitri Gribenko
169f43bf33 Merge pull request #3630 from rintaro/SE-0095-remaining
[SE-0095] Migrate remaining use of protocol<...> syntax
2016-07-20 14:38:00 -07:00
Nate Cook
7e6a1055b7 stdlib: underscore AnyCollectionProtocol 2016-07-20 15:52:10 -05:00
Alex Hoppen
095a68b195 [Sema] Disallow accessing enum elements as instance members
This implements SE-0036.
2016-07-20 19:13:58 +02:00
practicalswift
82af6ffc80 [swiftc (71 vs. 5109)] Add crasher in swift::decomposeParamType(...)
Add test case for crash triggered in `swift::decomposeParamType(...)`.

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

Assertion failure in `llvm/include/llvm/ADT/ArrayRef.h (line 186)`:

```
Assertion `Index < Length && "Invalid index!"' failed.

When executing: const T &llvm::ArrayRef<swift::ParamDecl *>::operator[](size_t) const [T = swift::ParamDecl *]
```

Assertion context:

```

    /// @}
    /// @name Operator Overloads
    /// @{
    const T &operator[](size_t Index) const {
      assert(Index < Length && "Invalid index!");
      return Data[Index];
    }

    /// @}
    /// @name Expensive Operations
```
Stack trace:

```
swift: /path/to/llvm/include/llvm/ADT/ArrayRef.h:186: const T &llvm::ArrayRef<swift::ParamDecl *>::operator[](size_t) const [T = swift::ParamDecl *]: Assertion `Index < Length && "Invalid index!"' failed.
8  swift           0x0000000001131544 swift::decomposeParamType(swift::Type, swift::ValueDecl const*, unsigned int) + 708
12 swift           0x0000000000f75433 swift::constraints::ConstraintSystem::diagnoseFailureForExpr(swift::Expr*) + 99
13 swift           0x0000000000f7aabe swift::constraints::ConstraintSystem::salvage(llvm::SmallVectorImpl<swift::constraints::Solution>&, swift::Expr*) + 3998
14 swift           0x0000000000ead422 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>) + 850
15 swift           0x0000000000eb3be2 swift::TypeChecker::typeCheckExpression(swift::Expr*&, swift::DeclContext*, swift::TypeLoc, swift::ContextualTypePurpose, swift::OptionSet<swift::TypeCheckExprFlags, unsigned int>, swift::ExprTypeCheckListener*) + 610
18 swift           0x0000000000f2c25a swift::TypeChecker::typeCheckFunctionBodyUntil(swift::FuncDecl*, swift::SourceLoc) + 346
19 swift           0x0000000000f2c0be swift::TypeChecker::typeCheckAbstractFunctionBodyUntil(swift::AbstractFunctionDecl*, swift::SourceLoc) + 46
20 swift           0x0000000000f2cc83 swift::TypeChecker::typeCheckAbstractFunctionBody(swift::AbstractFunctionDecl*) + 179
22 swift           0x0000000000ee7861 swift::performTypeChecking(swift::SourceFile&, swift::TopLevelContext&, swift::OptionSet<swift::TypeCheckingFlags, unsigned int>, unsigned int, unsigned int) + 1281
23 swift           0x0000000000c71a09 swift::CompilerInstance::performSema() + 3289
25 swift           0x00000000007d91c9 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 2857
26 swift           0x00000000007a51e8 main + 2872
Stack dump:
0.	Program arguments: /path/to/swift/bin/swift -frontend -c -primary-file validation-test/compiler_crashers/28370-swift-decomposeparamtype.swift -target x86_64-unknown-linux-gnu -disable-objc-interop -module-name main -o /tmp/28370-swift-decomposeparamtype-654b39.o
1.	While type-checking 'c' at validation-test/compiler_crashers/28370-swift-decomposeparamtype.swift:11:1
2.	While type-checking expression at [validation-test/compiler_crashers/28370-swift-decomposeparamtype.swift:11:10 - line:11:11] RangeText="c("
<unknown>:0: error: unable to execute command: Aborted
<unknown>:0: error: compile command failed due to signal (use -v to see invocation)
```
2016-07-20 18:08:11 +02:00
practicalswift
d10ea6ef75 Merge pull request #3588 from practicalswift/28369-swift-decl-walk.swift
[swiftc] Add non-fuzzing crash case submitted by @kiliankoe
2016-07-20 18:01:34 +02:00
practicalswift
fcee5faa47 Merge pull request #3578 from practicalswift/sourcekit-072-swift-constraints-constraintsystem-opengeneric
[SourceKit] Add test case for crash triggered in swift::constraints::ConstraintSystem::openGeneric(…)
2016-07-20 18:01:20 +02:00
Nate Cook
34b9b98988 [stdlib] Convert existential collection === operator to method 2016-07-20 10:01:39 -05:00
Rintaro Ishizaki
0a40f10bb4 [SE-0095] Migrate remaining use of protocol<> syntax 2016-07-20 19:18:46 +09:00
practicalswift
2cc72da9a0 Further reduction thanks to @jtbandes 2016-07-20 00:47:41 +02:00
Luke Larson
74e0498015 Revert "Update master to build with Xcode 8 beta 3, OS X 10.12, iOS 10, tvOS 10, and watchOS 3 SDKs."
This reverts commit 62d1fa760c.
2016-07-19 15:18:17 -07:00
Tony Parker
fe932663a8 Merge pull request #3598 from parkera/se86_rename_process
Rename Process to CommandLine
2016-07-19 13:45:23 -07:00
Tony Parker
3cb4a76fed Merge pull request #3576 from parkera/se86_outputstream
Rename OutputStream to OutputStreamable [SE-0086]
2016-07-19 13:45:01 -07:00
Mishal Shah
62d1fa760c Update master to build with Xcode 8 beta 3, OS X 10.12, iOS 10, tvOS 10, and watchOS 3 SDKs. 2016-07-19 22:31:34 +02:00
Andrew Trick
5a8271c621 Rename UnsafePointer allocate & deallocate. (#3608)
As proposed in SE-0107: UnsafeRawPointer:
Rename 'init(allocatingCapacity:)' to 'UnsafeMutablePointer.allocate(capacity:)'
Rename 'deallocateCapacity' to 'deallocate(capacity:)'

`allocate` should not be an initializer. It's primary function is to allocate
memory, not initialize a pointer.
2016-07-19 11:48:18 -07:00
Michael Gottesman
aa708ea138 [lit] Rename config.targets_to_build => config.llvm_code_generators and allow it to actually take on a value.
Previously this variable was always just "". Now using the recent cmake changes
that I made, we can just grab the proper values from LLVMConfig.cmake.

I need this so that we can REQUIRES tests based on the code generators that
LLVM was compiled with.

To make it easy to show the dependency in the requires line, the requires
pattern to use is:

REQUIRES: CODEGENERATOR=...
2016-07-19 10:45:45 -07:00
Dave Abrahams
a68f648fab encode(_:output:) => encode(_:into processCodeUnit:) 2016-07-19 07:13:00 -06:00
Dave Abrahams
5a5f19aa45 first/contains(predicate) => first/contains(where: predicate) 2016-07-19 07:12:59 -06:00
Dave Abrahams
dcbfdb5339 _ includeElement/whereElementsSatisfy predicate => _ isIncluded 2016-07-19 07:05:54 -06:00
Dave Abrahams
014b6972cf isOrderedBefore: => by areInIncreasingOrder: 2016-07-19 07:05:54 -06:00
Doug Gregor
eb27bb65a7 Merge pull request #3602 from DougGregor/se-0091-operators-in-types
Implement SE-0091: Operators in types
2016-07-19 00:14:04 -07:00
Andrew Trick
73106dd7c3 Rename initialize(with:count:) to initialize(to:count:). (#3601)
As proposed in SE-0107: UnsafeRawPointer.

"with" is considered a vacuous preposition. "to" implies direction.
2016-07-18 23:37:45 -07:00
Doug Gregor
80f0852504 [SE-0091] Allow 'static' operators to be declared within types and extensions thereof.
Allow 'static' (or, in classes, final 'class') operators to be
declared within types and extensions thereof. Within protocols,
require operators to be marked 'static'. Use a warning with a Fix-It
to stage this in, so we don't break the world's code.

Protocol conformance checking already seems to work, so add some tests
for that. Update a pile of tests and the standard library to include
the required 'static' keywords.

There is an amusing name-mangling change here. Global operators were
getting marked as 'static' (for silly reasons), so their mangled names
had the 'Z' modifier for static methods, even though this doesn't make
sense. Now, operators within types and extensions need to be 'static'
as written.
2016-07-18 23:18:57 -07:00
Tony Parker
f65c1390cb Rename Process to CommandLine
Rename Process to CommandLine [SE-0086].
2016-07-18 17:02:02 -07:00
Tony Parker
2a4e916296 Rename OutputStream to TextOutputStream [SE-0086] 2016-07-18 16:47:23 -07:00