swiftlang / swift Goto Github PK
View Code? Open in Web Editor NEWThe Swift Programming Language
Home Page: https://swift.org
License: Apache License 2.0
The Swift Programming Language
Home Page: https://swift.org
License: Apache License 2.0
Previous ID | SR-10 |
Radar | rdar://problem/22164428 |
Original Reporter | @jopamer |
Type | Bug |
Status | Resolved |
Resolution | Done |
Votes | 0 |
Component/s | Compiler |
Labels | Bug |
Assignee | @jopamer |
Priority | Medium |
md5: 0de69f21021d970867b18eeb66152a02
Issue Description:
The following mangled string crashes the demangler:
_TtFQQQq_FSs5splitu0_Rq_Ss14CollectionTypeq0_Ss11BooleanType_FTq_8maxSplitSi16allowEmptySlicesSb11isSeparatorFqqq_S_9GeneratorSs13GeneratorType7Elementq0__GSaqq_S_11SubSequence_9Generator7ElementQq0_FSs5splitu0_Rq_Ss14CollectionTypeq0_Ss11BooleanType_FTq_8maxSplitSi16allowEmptySlicesSb11isSeparatorFqqq_S1_9GeneratorSs13GeneratorType7Elementq0__GSaqq_S1_11SubSequence_
Previous ID | SR-41 |
Radar | rdar://23011851 |
Original Reporter | nikita (JIRA User) |
Type | Bug |
Attachment: Download
Xcode 7.1.1 (7B1005)
Votes | 0 |
Component/s | Compiler |
Labels | Bug |
Assignee | None |
Priority | Medium |
md5: 1344eed40e3fc0135966b4277a47f007
relates to:
Issue Description:
Swift 2.2 covariance unable to resolve functions covariance with variadic arguments.
Steps to Reproduce:
Attached a playground that shows the problem, as well as screenshot with errors. Here is a copy & paste of the code for your convenience:
func giveMeVoid(callback: (Void)->Void) {
}
func giveMeInt(callback: (Int)->Void) {
}
func any(values:Any?...) {
}
any()
any(5)
giveMeVoid(any) //This line will fail
giveMeInt(any) //This line will fail
Expected Results:
It is expected that `any` will be accepted by both giveMeVoid and giveMeInt functions, as they can work as `Void` and `Int` functions when they called directly.
Actual Results:
Non of functions accept 'any'. Following errors are thrown:
error: cannot convert value of type '(Any?...) -> ()' to expected argument type '(Void) -> Void'
error: cannot convert value of type '(Any?...) -> ()' to expected argument type '(Int) -> Void'
Previous ID | SR-5 |
Radar | rdar://problem/20985232 |
Original Reporter | @jopamer |
Type | Bug |
Status | Closed |
Resolution | Done |
Votes | 0 |
Component/s | Compiler |
Labels | Bug |
Assignee | @slavapestov |
Priority | Medium |
md5: e8b560bec251784192ee46b1939df9f3
Issue Description:
The following code fragment crashes the compiler:
protocol P {
typealias A = B
typealias B = A
func f(a: A) -> B
func f(b: B) -> A
}
extension P {
func f(a: A) -> B { repeat {} while true }
func f(a: B) -> A { repeat {} while true }
}
Previous ID | SR-36 |
Radar | None |
Original Reporter | anidotnet (JIRA User) |
Type | Bug |
OS - Ubuntu 15.10
Arch - Intel x86_64 (core i7)
Votes | 0 |
Component/s | Compiler |
Labels | Bug |
Assignee | None |
Priority | Medium |
md5: 449d27fb86d12376c53d9aba3cace98a
Issue Description:
While compiling swift from Github source in Ubuntu 15.10, I am getting below test failure when the source files are placed inside a NTFS partition.
lit.py: lit.cfg:759: note: Using platform module dir: /media/anindya/Misc/codebase/swift/build/Ninja-ReleaseAssert/swift-linux-x86_64/lib/swift/%target-sdk-name/x86_64
FAIL: Swift :: Serialization/write-to-locked-dir.swift (1766 of 2332)
******************** TEST 'Swift :: Serialization/write-to-locked-dir.swift' FAILED ********************
Script:
--
rm -rf /media/anindya/Misc/codebase/swift/build/Ninja-ReleaseAssert/swift-linux-x86_64/test-linux-x86_64/Serialization/Output/write-to-locked-dir.swift.tmp && mkdir /media/anindya/Misc/codebase/swift/build/Ninja-ReleaseAssert/swift-linux-x86_64/test-linux-x86_64/Serialization/Output/write-to-locked-dir.swift.tmp
touch /media/anindya/Misc/codebase/swift/build/Ninja-ReleaseAssert/swift-linux-x86_64/test-linux-x86_64/Serialization/Output/write-to-locked-dir.swift.tmp/main.swiftmodule /media/anindya/Misc/codebase/swift/build/Ninja-ReleaseAssert/swift-linux-x86_64/test-linux-x86_64/Serialization/Output/write-to-locked-dir.swift.tmp/main.swiftdoc
chmod -w /media/anindya/Misc/codebase/swift/build/Ninja-ReleaseAssert/swift-linux-x86_64/test-linux-x86_64/Serialization/Output/write-to-locked-dir.swift.tmp
/media/anindya/Misc/codebase/swift/build/Ninja-ReleaseAssert/swift-linux-x86_64/bin/swift -frontend -target x86_64-unknown-linux-gnu -emit-module -emit-module-doc -parse-stdlib -o /media/anindya/Misc/codebase/swift/build/Ninja-ReleaseAssert/swift-linux-x86_64/test-linux-x86_64/Serialization/Output/write-to-locked-dir.swift.tmp -module-name main /media/anindya/Misc/codebase/swift/swift/test/Serialization/write-to-locked-dir.swift || chmod +w /media/anindya/Misc/codebase/swift/build/Ninja-ReleaseAssert/swift-linux-x86_64/test-linux-x86_64/Serialization/Output/write-to-locked-dir.swift.tmp
chmod +w /media/anindya/Misc/codebase/swift/build/Ninja-ReleaseAssert/swift-linux-x86_64/test-linux-x86_64/Serialization/Output/write-to-locked-dir.swift.tmp
test -s /media/anindya/Misc/codebase/swift/build/Ninja-ReleaseAssert/swift-linux-x86_64/test-linux-x86_64/Serialization/Output/write-to-locked-dir.swift.tmp/main.swiftmodule
test -s /media/anindya/Misc/codebase/swift/build/Ninja-ReleaseAssert/swift-linux-x86_64/test-linux-x86_64/Serialization/Output/write-to-locked-dir.swift.tmp/main.swiftdoc
--
Exit Code: 1
Command Output (stderr):
--
chmod: /media/anindya/Misc/codebase/swift/build/Ninja-ReleaseAssert/swift-linux-x86_64/test-linux-x86_64/Serialization/Output/write-to-locked-dir.swift.tmp: new permissions are r-xrwxrwx, not r-xr-xr-x
--
********************
Testing Time: 66.60s
********************
Failing Tests (1):
Swift :: Serialization/write-to-locked-dir.swift
Expected Passes : 1666
Expected Failures : 92
Unsupported Tests : 573
Unexpected Failures: 1
*** Failed while running tests for swift (check-swift-linux-x86_64)
./swift/utils/build-script: command terminated with a non-zero exit status 1, aborting
Previous ID | SR-27 |
Radar | None |
Original Reporter | nate (JIRA User) |
Type | Bug |
Status | Closed |
Resolution | Done |
El Capitan, late 2013 Retina MacBook Pro
Apple Swift version 2.2-dev (LLVM 46be9ff861, Clang 4deb154edc, Swift 778f829)
Target: x86_64-apple-macosx10.9
Votes | 1 |
Component/s | Compiler |
Labels | Bug |
Assignee | None |
Priority | Medium |
md5: df05c318f165adcec0ebd665df8e3438
relates to:
Issue Description:
If I define a variadic function:
func variadic(integers: Int...) {}
I would expect this to be acceptable anywhere Int -> ()
, (Int, Int) -> ()
, etc. were. For example:
func variadic(integers: Int...) {}
[1].forEach(variadic)
[(1, 2)].forEach(variadic)
However, the compiler crashes with this error:
0 swift 0x00000001043da47b llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 43
1 swift 0x00000001043d9916 llvm::sys::RunSignalHandlers() + 70
2 swift 0x00000001043daaa3 SignalHandler(int) + 243
3 libsystem_platform.dylib 0x00007fff9573052a _sigtramp + 26
4 swift 0x000000010235e6fe swift::Lowering::TypeConverter::find(swift::Lowering::TypeConverter::TypeKey) + 142
5 swift 0x00000001023c0b09 swift::ASTVisitor<(anonymous namespace)::RValueEmitter, swift::Lowering::RValue, void, void, void, void, void, swift::Lowering::SGFContext>::visit(swift::Expr*, swift::Lowering::SGFContext) + 4393
6 swift 0x00000001023bc047 swift::Lowering::SILGenFunction::emitExprInto(swift::Expr*, swift::Lowering::Initialization*) + 279
7 swift 0x000000010239c2ae (anonymous namespace)::ArgEmitter::emit(swift::Lowering::ArgumentSource&&, swift::Lowering::AbstractionPattern) + 1950
8 swift 0x000000010239c835 (anonymous namespace)::ArgEmitter::emitExpanded(swift::Lowering::ArgumentSource&&, swift::Lowering::AbstractionPattern) + 261
9 swift 0x000000010239c689 (anonymous namespace)::ArgEmitter::emit(swift::Lowering::ArgumentSource&&, swift::Lowering::AbstractionPattern) + 2937
10 swift 0x000000010239d7dd (anonymous namespace)::ArgEmitter::emitShuffle(swift::Expr*, swift::Expr*, llvm::ArrayRef<swift::TupleTypeElt>, swift::ConcreteDeclRef, llvm::ArrayRef<swift::Expr*>, llvm::ArrayRef<int>, llvm::ArrayRef<unsigned int>, swift::Type, swift::Lowering::AbstractionPattern) + 2429
11 swift 0x000000010239cdd5 (anonymous namespace)::ArgEmitter::emitExpanded(swift::Lowering::ArgumentSource&&, swift::Lowering::AbstractionPattern) + 1701
12 swift 0x000000010239c689 (anonymous namespace)::ArgEmitter::emit(swift::Lowering::ArgumentSource&&, swift::Lowering::AbstractionPattern) + 2937
13 swift 0x000000010239b55b (anonymous namespace)::CallSite::emit(swift::Lowering::SILGenFunction&, swift::Lowering::AbstractionPattern, (anonymous namespace)::ParamLowering&, llvm::SmallVectorImpl<swift::Lowering::ManagedValue>&, llvm::SmallVectorImpl<std::__1::pair<swift::Lowering::LValue, swift::SILLocation> >&, llvm::Optional<swift::ForeignErrorConvention> const&) && + 315
14 swift 0x00000001023900ba (anonymous namespace)::CallEmission::apply(swift::Lowering::SGFContext) + 2698
15 swift 0x000000010238ee0a swift::Lowering::SILGenFunction::emitApplyExpr(swift::Expr*, swift::Lowering::SGFContext) + 58
16 swift 0x00000001023bfae8 swift::ASTVisitor<(anonymous namespace)::RValueEmitter, swift::Lowering::RValue, void, void, void, void, void, swift::Lowering::SGFContext>::visit(swift::Expr*, swift::Lowering::SGFContext) + 264
17 swift 0x00000001023bfbb9 swift::ASTVisitor<(anonymous namespace)::RValueEmitter, swift::Lowering::RValue, void, void, void, void, void, swift::Lowering::SGFContext>::visit(swift::Expr*, swift::Lowering::SGFContext) + 473
18 swift 0x00000001023bea0f swift::Lowering::SILGenFunction::emitRValueAsSingleValue(swift::Expr*, swift::Lowering::SGFContext) + 47
19 swift 0x000000010237dbd4 swift::Lowering::ArgumentSource::getAsSingleValue(swift::Lowering::SILGenFunction&, swift::Lowering::SGFContext) && + 340
20 swift 0x000000010239c563 (anonymous namespace)::ArgEmitter::emit(swift::Lowering::ArgumentSource&&, swift::Lowering::AbstractionPattern) + 2643
21 swift 0x000000010239b55b (anonymous namespace)::CallSite::emit(swift::Lowering::SILGenFunction&, swift::Lowering::AbstractionPattern, (anonymous namespace)::ParamLowering&, llvm::SmallVectorImpl<swift::Lowering::ManagedValue>&, llvm::SmallVectorImpl<std::__1::pair<swift::Lowering::LValue, swift::SILLocation> >&, llvm::Optional<swift::ForeignErrorConvention> const&) && + 315
22 swift 0x00000001023900ba (anonymous namespace)::CallEmission::apply(swift::Lowering::SGFContext) + 2698
23 swift 0x000000010238ee0a swift::Lowering::SILGenFunction::emitApplyExpr(swift::Expr*, swift::Lowering::SGFContext) + 58
24 swift 0x00000001023bfae8 swift::ASTVisitor<(anonymous namespace)::RValueEmitter, swift::Lowering::RValue, void, void, void, void, void, swift::Lowering::SGFContext>::visit(swift::Expr*, swift::Lowering::SGFContext) + 264
25 swift 0x00000001023bec96 swift::Lowering::SILGenFunction::emitIgnoredExpr(swift::Expr*) + 486
26 swift 0x0000000102387de6 swift::Lowering::SILGenModule::visitTopLevelCodeDecl(swift::TopLevelCodeDecl*) + 182
27 swift 0x000000010238841b swift::Lowering::SILGenModule::emitSourceFile(swift::SourceFile*, unsigned int) + 827
28 swift 0x0000000102388e62 swift::SILModule::constructSIL(swift::ModuleDecl*, swift::SILOptions&, swift::FileUnit*, llvm::Optional<unsigned int>, bool, bool) + 802
29 swift 0x0000000102389216 swift::performSILGeneration(swift::ModuleDecl*, swift::SILOptions&, bool, bool) + 38
30 swift 0x00000001021cb390 performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&) + 11424
31 swift 0x00000001021c84e3 frontend_main(llvm::ArrayRef<char const*>, char const*, void*) + 2691
32 swift 0x00000001021c4285 main + 2821
33 libdyld.dylib 0x00007fff98c265ad start + 1
Stack dump:
0. Program arguments: /Library/Developer/Toolchains/swift-2.2-SNAPSHOT-2015-12-01-a.xctoolchain/usr/bin/swift -frontend -interpret test.swift -target x86_64-apple-macosx10.9 -enable-objc-interop -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk -color-diagnostics -module-name test
fish: Job 1, '/Library/Developer/Toolchains/swift-2.2-SNAPSHOT-2015-12-01-a.xctoolchain/usr/bin/swift test.swift' terminated by signal SIGSEGV (Address boundary error)
If this is not currently intended to permissible in the language, the crash should be fixed and a compiler error should be printed instead. For example:
func variadic(integers: Int...) {}
struct Variadic
{
let function: Int -> ()
}
Variadic(function: variadic)
Prints the error:
test.swift:8:20: error: cannot convert value of type '(Int...) -> ()' to expected argument type 'Int -> ()'
Variadic(function: variadic)
Previous ID | SR-8 |
Radar | rdar://problem/22772999 |
Original Reporter | @jopamer |
Type | Bug |
Status | Closed |
Resolution | Done |
Votes | 0 |
Component/s | Compiler |
Labels | Bug |
Assignee | @jopamer |
Priority | Medium |
md5: 745dccb345b1970eabcd5bf9c431d7e0
Issue Description:
The following fragment of invalid code crashes the compiler:
protocol P {
typealias T
var env: T { get }
func f(a: Int);
}
struct IgnoreInt: P {
typealias T = Int
var env: T
func f(a: Int) { }
}
class IntBox {
var value: Int
init(value: Int) { self.value = value; }
}
struct AssignIntBox: P {
typealias T = IntBox
var env: T
func f(a: Int) { env.value = a }
}
var a: P = IgnoreInt(env: 0)
var b: P = AssignIntBox(env: IntBox(value: 0))
b = a
b.f(1);
Previous ID | SR-7 |
Radar | rdar://problem/22813050 |
Original Reporter | @jopamer |
Type | Bug |
Status | Closed |
Resolution | Done |
Votes | 0 |
Component/s | Compiler |
Labels | Bug |
Assignee | @gregomni |
Priority | Medium |
md5: 706aa076b5d0c32439e4d8e8563b7862
Issue Description:
If you attempt to compile the following program, the compiler crashes:
func f(inout a: Int) {}
let g = { x in f(x) }
Previous ID | SR-75 |
Radar | rdar://21289579 |
Original Reporter | Sephiroth87 (JIRA User) |
Type | Bug |
Status | Resolved |
Resolution | Done |
Attachment: Download
Xcode 7.1.1
Votes | 4 |
Component/s | Compiler |
Labels | Bug, CompilerCrash |
Assignee | @slavapestov |
Priority | Medium |
md5: 85007b8954c0d9c1507fbd1a12838bdf
is duplicated by:
protocol P { func f() }; type(of: P.f)
relates to:
Issue Description:
The following code will crash the compiler
protocol MyProtocol {
func myFunc() -> String
}
let f = MyProtocol.myFunc
Previous ID | SR-67 |
Radar | None |
Original Reporter | ganadist (JIRA User) |
Type | Improvement |
Status | Resolved |
Resolution | Done |
Votes | 0 |
Component/s | Compiler |
Labels | Improvement |
Assignee | ganadist (JIRA) |
Priority | Medium |
md5: 643882fdd62b6ee0f284280ae9954f43
Issue Description:
I'm trying to compile swift on my archlinux box.
And I found that link step of swift compiler binary for debug build need lots of time.
In my case, ld command was running over 3 hours, but it could not complete link. and I could see ld consumed all system memories,
But after switched to gold, link step was completed in 3-4 minutes.
I'm using..
ArchLinux
binutils 2.25.1 (gold 1.11)
System Memory : 16Gb
Swap Memory : 16Gb
Previous ID | SR-47 |
Radar | None |
Original Reporter | mhuusko5 (JIRA User) |
Type | Bug |
Status | Reopened |
Resolution |
Swift 2.1
Votes | 0 |
Component/s | Compiler |
Labels | Bug |
Assignee | None |
Priority | Medium |
md5: 86f7d721dca2d652e7f9808a7c9f03b9
Issue Description:
As seen below, I would like (/think I should be able) to provide default implementations for a protocol, when the type in question satisfies certain internal requirements. I believe this was possible in an earlier beta, but as of 2.1 it certainly isn't.
If this is not a bug, but by design (and the below has been deemed an anti-pattern), I'd be greatly interested in an alternative pattern (other than having the internal requirements actually public, but simply underscored, like the much of the standard library is).
public protocol ControllerType {
func doImportantStuff() -> Bool
}
internal protocol _ControllerType {
func implementationDetail() -> Bool
}
// error: extension cannot be declared public because its generic requirement uses an internal type
public extension ControllerType where Self: _ControllerType {
public func doImportantStuff() -> Bool {
return implementationDetail()
}
}
public struct Con: ControllerType { }
extension Con: _ControllerType {
func implementationDetail() -> Bool {
return true
}
}
let c = Con()
c.doImportantStuff()
Previous ID | SR-55 |
Radar | rdar://problem/21341337 |
Original Reporter | siarhei.barysenka (JIRA User) |
Type | Bug |
Attachment: Download
Votes | 40 |
Component/s | Compiler |
Labels | Bug |
Assignee | @slavapestov |
Priority | Medium |
md5: 4333a622f7ff4546521a5fc9f3702a7d
is duplicated by:
protocol A: class
is not any AnyObject
AnyObject
relates to:
Issue Description:
Summary:
The compiler throws the error
generic parameter 'T' could not be inferred
at the final line of the following code:
protocol MediaProtocol {}
protocol ImageProtocol: MediaProtocol {}
class Image: ImageProtocol {}
func itemToProcess() -> ImageProtocol {
return Image()
}
//func process<T>(item: T) -> T { // Uncomment this line and comment out the following one to remove the compile-time error
func process<T: MediaProtocol>(item: T) -> T {
return item
}
let image = itemToProcess()
let processedImage: ImageProtocol = process(image)
The error is gone when conformance to `MediaProtocol` is removed from the generic type `T` at the `process` method declaration in the given code.
Reproduced on:
Xcode 7.1.1 (7B1005), Swift 2.1, OS X 10.11
Previous ID | SR-73 |
Radar | None |
Original Reporter | @bitjammer |
Type | Bug |
Status | Closed |
Resolution | Done |
Votes | 0 |
Component/s | Compiler |
Labels | Bug |
Assignee | @bitjammer |
Priority | Medium |
md5: ea6e699cb4ddb0db3818658ca2efd713
Issue Description:
**************************************** TEST 'Swift :: SILPasses/inline_recursive.swift' FAILED ********************
Script:
--
/Users/david/repos/github/build/Ninja-RelWithDebInfoAssert/swift-macosx-x86_64/bin/swiftc -frontend -target i386-apple-ios7.0 -module-cache-path '/var/folders/7z/bwnqjmrs60b4bwxq7_4p3h540000gn/T/swift-testsuite-clang-module-cachegpOI9R' -sdk /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator9.1.sdk -primary-file /Users/david/repos/github/swift/test/SILPasses/inline_recursive.swift -parse-as-library -emit-sil -O | FileCheck /Users/david/repos/github/swift/test/SILPasses/inline_recursive.swift
--
Exit Code: 1
Command Output (stderr):
--
/Users/david/repos/github/swift/test/SILPasses/inline_recursive.swift:17:11: error: expected string not found in input
// CHECK: [[BUILTIN_INT:%.*]] = integer_literal $Builtin.Int64, 3
^
<stdin>:43:92: note: scanning from here
%0 = function_ref @_TF16inline_recursiveP33_38E63D320CFF538A1F98BBC31453B1EB7recFuncFSiSi : $@convention(thin) (Int) -> Int // user: %3
^
<stdin>:44:2: note: possible intended match here
%1 = integer_literal $Builtin.Int32, 3 // user: %2
^
--
Looks like dc65f70 to me.
Previous ID | SR-20 |
Radar | rdar://problem/28814419 |
Original Reporter | Beard (JIRA User) |
Type | Bug |
Status | Resolved |
Resolution | Done |
Votes | 0 |
Component/s | |
Labels | Bug |
Assignee | kelhutch17 (JIRA) |
Priority | Medium |
md5: 90d00a5d61e6a0083ac90f27e5a0de5b
is duplicated by:
relates to:
Issue Description:
When you execute swift --help, there should be some text that explains "swift build" to make it more discoverable. "swift build --help" does correctly execute swift-build --help.
Previous ID | SR-23 |
Radar | None |
Original Reporter | manyoso (JIRA User) |
Type | Bug |
Attachment: Download
apple/swift (master)> uname -a
Linux atreat-thinkpad 3.16.0-38-generic #52~14.04.1-Ubuntu SMP Fri May 8 09:43:57 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
Following the instructions on README.md with new clones of all repos...
Votes | 5 |
Component/s | |
Labels | Bug |
Assignee | @bitjammer |
Priority | Medium |
md5: e8eced68282d2665cd7e220f9f5f2b15
is duplicated by:
Issue Description:
apple/swift (master)> uname -a
Linux atreat-thinkpad 3.16.0-38-generic #52~14.04.1-Ubuntu SMP Fri May 8 09:43:57 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
Compiling /home/atreat/dev/personal/apple/build/Ninja-DebugAssert/swift-linux-x86_64/stdlib/public/core/linux/x86_64/Swift.o
...
/home/atreat/dev/personal/apple/swift/stdlib/public/core/ArrayBody.swift:18:8: error: opening import file for module 'SwiftShims': No such file or directory
import SwiftShims
^
ninja: build stopped: subcommand failed.
./utils/build-script: command terminated with a non-zero exit status 1, aborting
I've attached the full compile line and error
Previous ID | SR-9 |
Radar | rdar://problem/20651533 |
Original Reporter | @jopamer |
Type | Bug |
Status | Reopened |
Resolution |
Votes | 1 |
Component/s | Compiler |
Labels | Bug |
Assignee | King (JIRA) |
Priority | Medium |
md5: 18e965d66c831b43c6feca10c1b21c92
Issue Description:
Many of the Swift compiler tests in test/ClangModules that exercise enum import are broken on Linux and currently disabled there.
Previous ID | SR-22 |
Radar | None |
Original Reporter | hwang (JIRA User) |
Type | Bug |
Status | Closed |
Resolution | Done |
1:haohui@dell530n:~/source.swift/Hello[1019] 18:12:18
$ cat /etc/lsb-release
DISTRIB_ID=Ubuntu
DISTRIB_RELEASE=14.04
DISTRIB_CODENAME=trusty
DISTRIB_DESCRIPTION="Ubuntu 14.04.3 LTS"
1:haohui@dell530n:~/source.swift/Hello[1020] 18:14:48
$ ls Sources/
main.swift
1:haohui@dell530n:~/source.swift/Hello[1021] 18:15:45
$ cat Sources/main.swift
print("Hello, world!")
Votes | 0 |
Component/s | |
Labels | Bug |
Assignee | hwang (JIRA) |
Priority | Medium |
md5: 0cdbb920e39a03c96a783f1f4c28fd86
Issue Description:
1:haohui@dell530n:~/source.swift/Hello[1018] 18:12:08
$ swift build
Linking Executable: .build/debug/Hello
<unknown>:0: error: link command failed with exit code 127 (use -v to see invocation)
<unknown>:0: error: build had 1 command failures
swift-build: exit(1): ["/opt/swift-2.2-SNAPSHOT-2015-12-01-b-ubuntu14.04/usr/bin/swift-build-tool", "-f", "/abyss/haohui/source.swift/Hello/.build/debug/Hello.o/llbuild.yaml"]
Previous ID | SR-49 |
Radar | None |
Original Reporter | jpedrosa (JIRA User) |
Type | Bug |
Status | Closed |
Resolution | Invalid |
Attachment: Download
Votes | 0 |
Component/s | |
Labels | Bug |
Assignee | None |
Priority | Medium |
md5: d5358959d25086eb305674fe4790c463
Issue Description:
Hi,
Thanks for Swift.
While testing it on Ubuntu, error messages with white text on my terminal's white background made the text invisible. The word "error" would show up in red, but the other parts would only show up when I selected the text as if I was going to copy/paste it.
Here's a sample run:
$ swift woe.swift
woe.swift:3:7: error: value of type 'String' has no member 'utf4'
print("Hello".utf4)
^~~~~~~ ~~~~
$ cat woe.swift
print("Hello".utf4)
Only the "error:" shows up as red. Surrounding text is white. I will attach the screenshot too.
Previous ID | SR-78 |
Radar | None |
Original Reporter | windoze (JIRA User) |
Type | Bug |
Status | Resolved |
Resolution | Done |
Attachment: Download
Ubuntu 14.04.3 LTS x86_64, Ubuntu 14.04 Swift 2.2 Snapshot
Votes | 0 |
Component/s | Compiler |
Labels | Bug, CompilerCrash |
Assignee | @jckarter |
Priority | Medium |
md5: 4ce09acd58663f0925c8dc1bdf749fe1
Issue Description:
Following piece of code effectively crushes swiftc
struct A<T1, T2> {
var f:B<T1, T2>
var b:B<T2, T1>
var v:T1
}
struct B<T1, T2> {}
Logs attached
Previous ID | SR-2 |
Radar | rdar://problem/18841045 |
Original Reporter | @jopamer |
Type | Improvement |
Status | Closed |
Resolution | Done |
Votes | 5 |
Component/s | Compiler |
Labels | Improvement, Parser |
Assignee | @rintaro |
Priority | Medium |
Watchers: @shahmishal
md5: ac72c1f2b3e90602adfe008ab2456590
relates to:
Issue Description:
This code should be accepted, but it is rejected now:
switch 10 {
case 10:
break
#if FOO
case 20:
break
#endif
}
$ swiftc /tmp/a.swift
/tmp/a.swift:5:3: error: 'case' label can only appear inside a 'switch' statement
case 20:
^
Previous ID | SR-46 |
Radar | None |
Original Reporter | bobblestiltskin (JIRA User) |
Type | Improvement |
Status | Closed |
Resolution | Done |
Votes | 0 |
Component/s | |
Labels | Improvement |
Assignee | mattt (JIRA) |
Priority | Medium |
md5: 8758bb35ea991d740665a2a19d6da0a7
Issue Description:
The Swift Programming Language is the authoritative reference for Swift, offering a guided tour, a comprehensive guide, and a formal reference of the language. You can download the latest version below.
The Swift Programming Language (ePub)
Errr...
Please can we have this in PDF format or even old-skool HTML?? Please :-)
Previous ID | SR-64 |
Radar | None |
Original Reporter | @lilyball |
Type | Improvement |
Status | Resolved |
Resolution | Done |
Votes | 0 |
Component/s | Compiler |
Labels | Improvement, LanguageFeatureRequest |
Assignee | None |
Priority | Medium |
md5: 1ffbbd3dbec72831eafe2d1921c680d6
Issue Description:
It would be really handy if typealiases could take generic parameters, e.g.
typealias Handler<Element> = [Element] -> Void
Previous ID | SR-39 |
Radar | None |
Original Reporter | nitingupta (JIRA User) |
Type | Bug |
Status | Closed |
Resolution | Done |
Linux x86_64:
Ubuntu 15.10
Fedora 23
Votes | 0 |
Component/s | |
Labels | Bug |
Assignee | nitingupta (JIRA) |
Priority | Medium |
md5: fd86c22c281bf15d4abce7ab7c984033
Issue Description:
I build swift from source on both Ubuntu 15.10 and Fedora 23 with:
utils/build-script -R
to get a release build.
But when I try to start REPL from build directory I'm getting following error (on both Linux flavors):
LLVM ERROR: Compiler-internal integrated REPL unimplemented for this platform
However I can run ./swiftc without errors.
Output of tests run with 'build-scripts -R -t':
Testing Time: 46.07s
Expected Passes : 1667
Expected Failures : 92
Unsupported Tests : 573
check-swift-linux-x86_64 finished --
Previous ID | SR-38 |
Radar | None |
Original Reporter | @lilyball |
Type | Bug |
Status | Resolved |
Resolution | Done |
Swift version 2.2-dev (LLVM 46be9ff861, Clang 4deb154edc, Swift e8a15c6)
Target: x86_64-apple-macosx10.9
Compiled with the default build-script settings
Votes | 0 |
Component/s | Compiler |
Labels | Bug, DiagnosticsQoI, TypeChecker |
Assignee | @gregomni |
Priority | Medium |
md5: d13102ac8bfee811237d0ecbc6545377
Issue Description:
The code snippet from SR-8 illustrates a curious bug:
protocol P {
typealias T
var env: T { get }
func f(a: Int);
}
struct IgnoreInt: P {
typealias T = Int
var env: T
func f(a: Int) { }
}
class IntBox {
var value: Int
init(value: Int) { self.value = value; }
}
struct AssignIntBox: P {
typealias T = IntBox
var env: T
func f(a: Int) { env.value = a }
}
var a: P = IgnoreInt(env: 0)
var b: P = AssignIntBox(env: IntBox(value: 0))
b = a
b.f(1);
In Swift 2.1 (swiftlang-700.1.101.6), this correctly emits two errors:
foo.swift:24:8: error: protocol 'P' can only be used as a generic constraint because it has Self or associated type requirements
var a: P = IgnoreInt(env: 0)
^
foo.swift:25:8: error: protocol 'P' can only be used as a generic constraint because it has Self or associated type requirements
var b: P = AssignIntBox(env: IntBox(value: 0))
^
Current tip of master emits each error twice, once for the protocol type, and then again for the variable:
foo.swift:24:8: error: protocol 'P' can only be used as a generic constraint because it has Self or associated type requirements
var a: P = IgnoreInt(env: 0)
^
foo.swift:24:5: error: protocol 'P' can only be used as a generic constraint because it has Self or associated type requirements
var a: P = IgnoreInt(env: 0)
^
foo.swift:25:8: error: protocol 'P' can only be used as a generic constraint because it has Self or associated type requirements
var b: P = AssignIntBox(env: IntBox(value: 0))
^
foo.swift:25:5: error: protocol 'P' can only be used as a generic constraint because it has Self or associated type requirements
var b: P = AssignIntBox(env: IntBox(value: 0))
^
Previous ID | SR-42 |
Radar | rdar://23632146 |
Original Reporter | nikita (JIRA User) |
Type | Bug |
Status | Reopened |
Resolution |
Attachment: Download
Xcode 7.1.1
Votes | 4 |
Component/s | Compiler |
Labels | Bug |
Assignee | None |
Priority | Medium |
md5: 9ec8a5c65eb1dc8d0c6f70183c84515b
Issue Description:
Summary:
It is impossible to unwrap non-optional tuple into a tuple of two implicitly optional variables of the same type. For example, following code will not work:
var first: Int!
var second: Int!
func tuple() -> (Int, Int) {
return (0,0)
}
(first, second) = tuple()
Steps to Reproduce:
Assign tuple of non-optional types to a tuple of variables with an implicitly optional types.
Expected Results:
Variables will be assigned.
Actual Results:
Compiler will provide a error "cannot express tuple conversion '(Int, Int)' to '(Int![](, Int))' (aka '(ImplicitlyUnwrappedOptional<Int>, ImplicitlyUnwrappedOptional<Int>)')"
Previous ID | SR-1 |
Radar | rdar://problem/22724955 |
Original Reporter | @jopamer |
Type | Bug |
Status | Closed |
Resolution | Done |
Votes | 2 |
Component/s | |
Labels | Bug, Linux |
Assignee | None |
Priority | Medium |
md5: 90c6fa571fac13d05c95850bed417233
Issue Description:
Building Swift on Linux currently depends on a linker script to mark protocol conformances. This linker script method is not compatible with the gold linker. We want to support using the gold linker, so come up with another method to achieve this that is compatible with the gold linker.
It seems likely there are at least the following options that seem potentially valid:
We could do some work inside the swift compiler itself as a pre-link step, to collate the protocol conformance data into a single object file. I think we’re ultimately looking for a section of data that we know the size and length of, that contains the conformance data, that can be accessed as a known symbol name at runtime.
Adjust the gold linker to support the symbol collation functionality in ld.bfd that is not in ld.gold. The gold linker is a GPLv3 project.
Previous ID | SR-6 |
Radar | rdar://problem/17858620 |
Original Reporter | @jopamer |
Type | Task |
Status | Reopened |
Resolution |
Votes | 0 |
Component/s | Compiler |
Labels | Task |
Assignee | None |
Priority | Medium |
md5: c8813366828ca436433065a7b8e88402
Issue Description:
We get a lot of bugs that land in backend components because they crash in SILGen, optimization, or IRGen, but are really rooted in type-checker bugs. To help better screen these bugs, and to hopefully catch them sooner, we should put some effort into the AST verifier to make it check more invariants. Currently it misses a lot of basic things, like 'ParenExprs shouldn't change the type of the subexpression' or '*MemberRef should reference a member that's actually reachable from the base type'.
Previous ID | SR-28 |
Radar | None |
Original Reporter | tmandry (JIRA User) |
Type | Bug |
Status | Resolved |
Resolution | Done |
OS X 10.11.1
Swift version 2.2-dev (LLVM 46be9ff861, Clang 4deb154edc, Swift f44f4a5) - built 12/3/15
Votes | 0 |
Component/s | Compiler |
Labels | Bug |
Assignee | None |
Priority | Medium |
md5: d7069ba447e02f44dc0f206de7bc11fb
Issue Description:
The following code causes the compiler to crash with an assertion failure. The compiler seems to be sensitive to the length of MyVeryLongAType. Specifically, renaming that to AType causes the code to compile. Removing the where clause also causes the code to compile.
protocol AProtocol {
}
protocol BProtocol {
typealias MyVeryLongAType: AProtocol
typealias MyOtherAType: AProtocol
}
class MyClass<BType: BProtocol where BType.MyVeryLongAType == BType.MyOtherAType> {
}
Here's the output:
Swift version 2.2-dev (LLVM 46be9ff861, Clang 4deb154edc, Swift f44f4a5a35)
Target: x86_64-apple-macosx10.9
/Users/tyler/code/swift/build/Ninja-DebugAssert/swift-macosx-x86_64/bin/swift -frontend -c -primary-file main.swift -target x86_64-apple-macosx10.9 -enable-objc-interop -color-diagnostics -module-name main -o /var/folders/xl/kvdphsfj6230q3f8_m9h5zhw0000gn/T/main-f13ccf.o
Assertion failed: (NextValue < Values.size()), function claimNext, file /Users/tyler/code/swift/swift/lib/IRGen/Explosion.h, line 129.
0 swift 0x0000000110cfccce llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 46
1 swift 0x0000000110cfd119 PrintStackTraceSignalHandler(void*) + 25
2 swift 0x0000000110cf98b9 llvm::sys::RunSignalHandlers() + 425
3 swift 0x0000000110cfd459 SignalHandler(int) + 345
4 libsystem_platform.dylib 0x00007fff91c5952a _sigtramp + 26
5 swift 0x00000001117a0d3c cmark_strbuf__initbuf + 95547
6 swift 0x0000000110cfd13b raise + 27
7 swift 0x0000000110cfd1f2 abort + 18
8 swift 0x0000000110cfd1d1 __assert_rtn + 129
9 swift 0x000000010b924b31 swift::irgen::Explosion::claimNext() + 129
10 swift 0x000000010b8de81b (anonymous namespace)::EmitPolymorphicParameters::emitWithSourcesBound(swift::irgen::Explosion&) + 683
11 swift 0x000000010b8cdd52 (anonymous namespace)::EmitPolymorphicParameters::emitForGenericValueWitness(llvm::Value*) + 578
12 swift 0x000000010b8cda5f swift::irgen::emitPolymorphicParametersForGenericValueWitness(swift::irgen::IRGenFunction&, swift::NominalTypeDecl*, llvm::Value*) + 95
13 swift 0x000000010b8339cd swift::irgen::emitFieldTypeAccessor(swift::irgen::IRGenModule&, swift::NominalTypeDecl*, llvm::Function*, llvm::ArrayRef<swift::irgen::FieldTypeInfo>) + 1437
14 swift 0x000000010b7e3069 swift::irgen::IRGenModuleDispatcher::emitLazyDefinitions() + 553
15 swift 0x000000010b92e93c performIRGeneration(swift::IRGenOptions&, swift::ModuleDecl*, swift::SILModule*, llvm::StringRef, llvm::LLVMContext&, swift::SourceFile*, unsigned int) + 1388
16 swift 0x000000010b92f0d7 swift::performIRGeneration(swift::IRGenOptions&, swift::SourceFile&, swift::SILModule*, llvm::StringRef, llvm::LLVMContext&, unsigned int) + 167
17 swift 0x000000010b638b48 performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&) + 18728
18 swift 0x000000010b63394c frontend_main(llvm::ArrayRef<char const*>, char const*, void*) + 12812
19 swift 0x000000010b61adad main + 4285
20 libdyld.dylib 0x00007fff8b08f5ad start + 1
Stack dump:
0. Program arguments: /Users/tyler/code/swift/build/Ninja-DebugAssert/swift-macosx-x86_64/bin/swift -frontend -c -primary-file main.swift -target x86_64-apple-macosx10.9 -enable-objc-interop -color-diagnostics -module-name main -o /var/folders/xl/kvdphsfj6230q3f8_m9h5zhw0000gn/T/main-f13ccf.o
<unknown>:0: error: unable to execute command: Illegal instruction: 4
<unknown>:0: error: compile command failed due to signal (use -v to see invocation)
Previous ID | SR-74 |
Radar | None |
Original Reporter | etan (JIRA User) |
Type | Bug |
Attachment: Download
OS X 10.11.1 (15B42)
Xcode Version 7.1.1 (7B1005)
Swift version 2.1 (700.1.101.6 700.1.76)
Votes | 0 |
Component/s | Compiler |
Labels | Bug |
Assignee | None |
Priority | Medium |
md5: 45a7d69794999ab90b93c6c258f5fb14
Issue Description:
To understand this issue, a C API is necessary with two C functions. One to store a function and an info pointer - a second one to call the stored function with the stored pointer as argument.
typedef void (* CFuncCallback)(void * info);
void CFuncStore(CFuncCallback callback, void * info);
void CFuncCall();
static CFuncCallback _callback;
static void * _info;
void CFuncStore(CFuncCallback callback, void * info) {
_callback = callback;
_info = info;
}
void CFuncCall() {
if (_callback) {
_callback(_info);
}
}
A simple info object and C callback function are implemented in Swift to access this C API.
final class Info {
init() { print("Info: init.") }
deinit { print("Info: deinit.") }
}
func cCallback(info: UnsafeMutablePointer<Void>) {
print("Callback from C.")
print(UnsafePointer<Info>(info).memory)
print("Test successful - no crash.")
}
Now, a Swift object is defined.
On init(), an Info instance is created and registered with the C API.
On deinit, invoke CFuncCall is invoked. This should be fine, as the Swift object still holds a reference to the info object while deinit is in progress.
final class SwiftObj {
var info: Info = {
print("SwiftObj: Alloc info.")
return Info()
}()
init() {
print("SwiftObj: init.")
CFuncStore(cCallback, &info);
print("SwiftObj: init done.")
}
deinit {
print("SwiftObj: deinit.")
CFuncCall()
print("SwiftObj: deinit done.")
}
}
An instance of SwiftObj is created and immediately destroyed, producing this log:
Previous ID | SR-62 |
Radar | None |
Original Reporter | patgoley (JIRA User) |
Type | Bug |
Status | Resolved |
Resolution | Done |
Votes | 0 |
Component/s | Compiler |
Labels | Bug, CompilerCrash |
Assignee | cwillmore (JIRA) |
Priority | Medium |
md5: 0a5df40af9435ae8a4d06d5c4a3ae9de
Issue Description:
The following swift program crashes the compiler:
import Foundation
protocol Model {
typealias IdentifierType
var id: IdentifierType {get}
}
protocol Repository {
typealias ModelType: Model
func findById(id: ModelType.IdentifierType) -> (ModelType)
}
extension NSObject: Model {
var id: IdentifierType {
get {
return 5
}
}
}
class ObjectRepository<T where T: NSObject> : Repository {
func findById(id: T.IdentifierType) -> T {
return T()
}
}
It seems like the compiler should be able to recognize that ObjectRepository conforms to Repository because NSObject conforms to Model which ObjectRepository<T> is constrained to.
Previous ID | SR-37 |
Radar | None |
Original Reporter | blach (JIRA User) |
Type | Improvement |
Votes | 1 |
Component/s | |
Labels | Improvement |
Assignee | None |
Priority | Medium |
md5: 821bcb1fe2c1f28e6ac53d7cfb2e0ad6
relates to:
Issue Description:
In many cases it seems most natural to store application level constants in an enum. For instance:
enum Constants {
enum Notifications {
case LoggedIn
case LoggedOut
}
}
As one would expect (and as of Swift 2) you can now
print(Constants.Notifications.LoggedOut) // "LoggedOut"
This is because of the addition of the CustomStringConvertable protocol. However in similar situations where one might want to pass an enum as it's raw representation, it fails:
NSNotificationCenter.defaultCenter().postNotificationName(Constants.Notifications.LoggedOut, object: nil, userInfo: nil) // Can not convert 'Constants.Notifications.LoggedOut' to type 'String'
This seems counter intuitive. Especially in the case of an enum with an explicitly typed raw value (e.g. enum Notifications: String). This has lead to a plethora of work arounds. Here are three:
// 1
extension NSNotificationCenter {
func postNotificationName(name: Constants.Notifications, object anObject: AnyObject?, userInfo aUserInfo: [NSObject : AnyObject]? = nil) {
self.postNotificationName(name.rawValue, object: anObject, userInfo: aUserInfo)
}
}
// 2
extension NSNotificationCenter {
func postNotificationName<T: RawRepresentable where T.RawValue == String>(name: T, object anObject: AnyObject?, userInfo aUserInfo: [NSObject : AnyObject]? = nil) {
self.postNotificationName(name.rawValue, object: anObject, userInfo: aUserInfo)
}
}
// 3
https://gist.github.com/designatednerd/5645d286df0ce939714b
// I really don't get the trouble that this last person went to, because it doesn't yield anything you'd actually want to use, but oh well.
In light of this, RawRepresentable types logically should map to their raw values when passed as arguments of that specified types, such that a simple
Previous ID | SR-56 |
Radar | rdar://problem/22072865 |
Original Reporter | maxs (JIRA User) |
Type | Bug |
Status | Closed |
Resolution | Invalid |
Votes | 1 |
Component/s | Source Tooling |
Labels | Bug |
Assignee | None |
Priority | Medium |
md5: f252571ad84e5a238abce91ad79e5cf6
Issue Description:
Component: SourceKit
dynamicType
is missing from code completion.
To test this, use swift-ide-test
. I.e.
File: cc.swift
String().#\A\#
Run:
swift-ide-test -code-completion -source-filename=cc.swift -code-completion-token=A cc.swift
Note that dynamicType
is missing from the output.
Previous ID | SR-16 |
Radar | None |
Original Reporter | maxs (JIRA User) |
Type | Improvement |
Status | Resolved |
Resolution | Done |
Votes | 0 |
Component/s | Compiler |
Labels | Improvement |
Assignee | add210 (JIRA) |
Priority | Medium |
md5: a841b95419429fa37d43c78e96c6bee6
Issue Description:
If you use debug-time-function-bodies to determine which parts of your code are slow to compile you might notice the numbers don't add up. For me, it only added up to half the amount of time in the profile trace. This is because it rounds to only one decimal place! We should print with two, or even more, decimal places so the time adds up correctly.
Previous ID | SR-48 |
Radar | rdar://22067698 |
Original Reporter | hagi (JIRA User) |
Type | Bug |
Status | Closed |
Resolution | Done |
Attachment: Download
Verified with Apple Swift version 2.1.1 and Apple Swift version 2.2-dev
OS X 10.11.1 (15B42). Requires Foundation framework and ObjC runtime.
Votes | 0 |
Component/s | Compiler |
Labels | Bug |
Assignee | @slavapestov |
Priority | Medium |
md5: 484aa387c639f336a3aed7547f1776b1
is duplicated by:
relates to:
self
doesn't work in initializer of lazy varIssue Description:
Usually, when `self` is missing from a call within a closure, a warning is generated (unless you explicitly capture `self`). This generally holds true for closures used to initialize lazy variables.
However, I've found that some methods (possible `objc`-related) don't require `self` to compile without warnings, but they don't work as expected either, which leads to bugs that are really easy to miss and a pain to find. It would be great to have warnings in these cases.
Steps to Reproduce:
Please see the file attached. On OS X, you can just run `swift lazy_block.swift` in the Terminal (from the respective directory).
Please read the comments in the file, too.
Expected Results:
The naive expectation when I encountered the bug was that `respondsToSelector` (line 16) would be called on the instance and return `true` (but it returns `false`).
The correct expectation should be a warning/error in that line, and possibly a fix-it, leading to what I've written in line 22 (which does return/print `true`).
Actual Results:
No warning/error, but `respondsToSelector` does not return the expected result.
Notes:
This problem does not seem to occur in normal closures (see lines 51 ff). I could only reproduce this in lazy variable initializations.
This has been filed as a radar before, but I think this bug tracker offers a better chance of getting attention from the Swift team or the general community. For reference: rdar://22067698. The example has been updated/simplified, so please prefer this bug report over the radar.
Previous ID | SR-34 |
Radar | None |
Original Reporter | add210 (JIRA User) |
Type | New Feature |
Status | Resolved |
Resolution | Done |
Votes | 11 |
Component/s | |
Labels | New Feature, NewPortRequest, Windows |
Assignee | @compnerd |
Priority | Medium |
md5: f4b64a255a413f9bd9346ba92309927c
relates to:
Issue Description:
Port Swift to Windows. This effectively breaks into a few ports (see linked issues) but the important ones being:
❌ Port to Visual Studio (MSVC)
❌ Port to Cygwin
This is actively being worked on here by tinysun (JIRA User): https://github.com/tinysun212/swift-windows
Previous ID | SR-26 |
Radar | None |
Original Reporter | rongshuxia (JIRA User) |
Type | Improvement |
Votes | 1 |
Component/s | |
Labels | Improvement |
Assignee | None |
Priority | Medium |
md5: 6e0b6622fa7c9a1f2c0d0dbc1d988dc7
Issue Description:
Please add the Chinese language for swift.org
Previous ID | SR-50 |
Radar | None |
Original Reporter | @akyrtzi |
Type | Improvement |
Status | Reopened |
Resolution |
Votes | 0 |
Component/s | Compiler |
Labels | Improvement, TypeChecker |
Assignee | None |
Priority | Medium |
md5: 9004a0727c0e0a404b014393e17c9bce
Issue Description:
With this code:
enum SomeError : ErrorType {
case Error
}
enum SomethingOrError<T> {
case err(SomeError)
case some(T)
}
func doit() -> SomethingOrError<Int> {
return SomethingOrError.some(0)
}
func doit() throws -> Int {
return 0
}
let something = try! doit()
You get:
t.swift:18:22: error: ambiguous use of 'doit()'
let something = try! doit()
^
t.swift:10:6: note: found this candidate
func doit() -> SomethingOrError<Int> {
^
t.swift:14:6: note: found this candidate
func doit() throws -> Int {
^
Consider guiding type inference to resolve the call to the throwing function since the call uses 'try'.
Previous ID | SR-30 |
Radar | rdar://problem/17102392 |
Original Reporter | RuiCarneiro (JIRA User) |
Type | Improvement |
Status | Resolved |
Resolution | Done |
Votes | 6 |
Component/s | |
Labels | Improvement, LanguageFeatureRequest |
Assignee | @CodaFi |
Priority | Medium |
md5: 6f9747e0e0648c9bf5fee84b0f66cd7f
relates to:
Issue Description:
Sometimes, it's convenient to have an allValues property for an enum that automatically generates a collection with all possible elements.
eg:
{{enum Fruits { case Apple, Orange, Peach, Banana }
for fruit in Fruits.allValues {
// ...
}}}
{color:red}On another note, it would be handy to have a reverse function for the rawValue propriety
eg:
{{enum Fruits : Int { case Apple = 0, Orange ... }
let fruit : Fruits? = Fruits.reverseRawValue(1)
// fruit == Fruits.Orange}}{color}
Thanks, Kevin Ballard.
Previous ID | SR-44 |
Radar | None |
Original Reporter | dhogborg (JIRA User) |
Type | Bug |
Status | Resolved |
Resolution | Done |
Attachment: Download
Apple Swift version 2.1 (swiftlang-700.1.101.6 clang-700.1.76)
Target: x86_64-apple-darwin15.0.0
XCode 7.1.1
Votes | 0 |
Component/s | Compiler |
Labels | Bug, IRGen |
Assignee | None |
Priority | Medium |
md5: 21024ad993e0d6972717c96c9ea9af7d
Issue Description:
Xcode and Playgrounds thinks this is valid code. Not until swiftc try to compile it the error is discovered. At that point it's not clear where the error is located as Xcode does not give any more information than the comment below. Playgrounds generates a crash log when communication is interrupted unexpectedly.
Checking protocol adherence of a subclass in a static function is not caught by linter and produces a really unhelpful error message. This should be caught and referenced by line of code where the error is located.
protocol ChildProt : class {
init()
func name() -> String
}
class Parent {
required init() {}
static func queryChildren() -> [ChildProt] {
// don't try to check a protocol adherence of self in a static function
guard let prot = self as? ChildProt else {
preconditionFailure()
}
return [prot.dynamicType.init()]
}
}
class Child : Parent, ChildProt {
var NAME = "John Doe"
required init() {}
func name() -> String {
return self.NAME
}
}
let child = Child.queryChildren().first!
child.name()
After hunting down the offending file, this is the error message produced by swiftc and presented in Xcode.
Command /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swiftc failed with exit code 1
PHI nodes must have at least one entry. If the block is dead, the PHI should be removed!
%50 = phi i8** , !dbg !530
LLVM ERROR: Broken function found, compilation aborted!
Playground with example code attached
Previous ID | SR-17 |
Radar | None |
Original Reporter | krusche (JIRA User) |
Type | New Feature |
Status | Closed |
Resolution | Done |
Votes | 11 |
Component/s | |
Labels | New Feature |
Assignee | @bitjammer |
Priority | Medium |
md5: ce13c69509de60ecfe1aaced5dc7c844
Issue Description:
Swift is a statically typed language and it would be great, if refactoring would be supported!
Previous ID | SR-43 |
Radar | None |
Original Reporter | Sylvain (JIRA User) |
Type | Bug |
Status | Closed |
Resolution | Cannot Reproduce |
Xcode 7.1.1
Votes | 1 |
Component/s | Source Tooling |
Labels | Bug |
Assignee | None |
Priority | Medium |
md5: f0e97f4e0c6ff7487db9062463d7658b
Issue Description:
The code below makes SourceKit crash until you implement get
:
var foo: String {
set {
}
}
Previous ID | SR-51 |
Radar | None |
Original Reporter | alexlew (JIRA User) |
Type | Bug |
Status | Closed |
Resolution | Done |
Mac OS X 10.11, Xcode 7.1
Votes | 0 |
Component/s | Compiler |
Labels | Bug |
Assignee | None |
Priority | Medium |
md5: 2323deb69c58b788d8842a67630d8d33
Issue Description:
In the (incorrect) code below, Swift produces a misleading error message. The error in the code is that we cannot return a Bool from a function that declares no return type. But Swift reports that the error is that the binary operator == cannot be applied to two values of type T.
// gives incorrect error message:
func areEqualValues<T: Equatable>(a: T, b: T) {
return (a == b)
}
If we change the code slightly, we get the correct error message:
// gives correct error message
func areEqualValues<T: Equatable>(a: T, b: T) {
let c = (a == b)
return c
}
Previous ID | SR-31 |
Radar | None |
Original Reporter | tmandry (JIRA User) |
Type | Bug |
Status | Closed |
Resolution | Done |
OS X 10.11.1
swift commit e0e5257
Other output before failure:
--- Running tests for swift ---
--- check-swift-macosx-x86_64 ---
+ cd /Users/tyler/code/swift/build/Ninja-DebugAssert/swift-macosx-x86_64/stdlib/public/SwiftShims
+ /usr/local/Cellar/cmake/3.3.2/bin/cmake -E make_directory /Users/tyler/code/swift/build/Ninja-DebugAssert/swift-macosx-x86_64/./lib/swift
+ /usr/local/Cellar/cmake/3.3.2/bin/cmake -E create_symlink /Users/tyler/code/swift/build/Ninja-DebugAssert/llvm-macosx-x86_64/lib/clang/3.8.0 /Users/tyler/code/swift/build/Ninja-DebugAssert/swift-macosx-x86_64/./lib/swift/clang
+ /usr/local/Cellar/cmake/3.3.2/bin/cmake -E make_directory /Users/tyler/code/swift/build/Ninja-DebugAssert/swift-macosx-x86_64/./lib/swift/install-tmp/install-tmp
+ /usr/local/Cellar/cmake/3.3.2/bin/cmake -E remove /Users/tyler/code/swift/build/Ninja-DebugAssert/swift-macosx-x86_64/./lib/swift/install-tmp/install-tmp/clang
+ /usr/local/Cellar/cmake/3.3.2/bin/cmake -E create_symlink ../clang/3.8.0 /Users/tyler/code/swift/build/Ninja-DebugAssert/swift-macosx-x86_64/./lib/swift/install-tmp/install-tmp/clang
+ cd /Users/tyler/code/swift/build/Ninja-DebugAssert/swift-macosx-x86_64/test
+ /usr/local/Cellar/cmake/3.3.2/bin/cmake -E remove_directory /Users/tyler/code/swift/build/Ninja-DebugAssert/swift-macosx-x86_64/./swift-test-results/x86_64-apple-macosx10.9
+ /usr/local/Cellar/cmake/3.3.2/bin/cmake -E make_directory /Users/tyler/code/swift/build/Ninja-DebugAssert/swift-macosx-x86_64/./swift-test-results/x86_64-apple-macosx10.9
+ /usr/local/bin/python /Users/tyler/code/swift/llvm/utils/lit/lit.py -sv --xunit-xml-output=/Users/tyler/code/swift/build/Ninja-DebugAssert/swift-macosx-x86_64/./swift-test-results/x86_64-apple-macosx10.9/lit-tests.xml /Users/tyler/code/swift/build/Ninja-DebugAssert/swift-macosx-x86_64/test-macosx-x86_64
lit.py: lit.cfg:211: note: using swift: /Users/tyler/code/swift/build/Ninja-DebugAssert/swift-macosx-x86_64/bin/swift
lit.py: lit.cfg:211: note: using swiftc: /Users/tyler/code/swift/build/Ninja-DebugAssert/swift-macosx-x86_64/bin/swiftc
lit.py: lit.cfg:211: note: using swift-autolink-extract: /Users/tyler/code/swift/build/Ninja-DebugAssert/swift-macosx-x86_64/bin/swift-autolink-extract
lit.py: lit.cfg:211: note: using sil-opt: /Users/tyler/code/swift/build/Ninja-DebugAssert/swift-macosx-x86_64/bin/sil-opt
lit.py: lit.cfg:211: note: using sil-extract: /Users/tyler/code/swift/build/Ninja-DebugAssert/swift-macosx-x86_64/bin/sil-extract
lit.py: lit.cfg:211: note: using lldb-moduleimport-test: /Users/tyler/code/swift/build/Ninja-DebugAssert/swift-macosx-x86_64/bin/lldb-moduleimport-test
lit.py: lit.cfg:211: note: using swift-ide-test: /Users/tyler/code/swift/build/Ninja-DebugAssert/swift-macosx-x86_64/bin/swift-ide-test
lit.py: lit.cfg:211: note: using clang: /Users/tyler/code/swift/build/Ninja-DebugAssert/llvm-macosx-x86_64/bin/clang
lit.py: lit.cfg:211: note: using llvm-link: /Users/tyler/code/swift/build/Ninja-DebugAssert/llvm-macosx-x86_64/bin/llvm-link
lit.py: lit.cfg:211: note: using swift-llvm-opt: /Users/tyler/code/swift/build/Ninja-DebugAssert/swift-macosx-x86_64/bin/swift-llvm-opt
lit.py: lit.cfg:255: note: Using resource dir: /Users/tyler/code/swift/build/Ninja-DebugAssert/swift-macosx-x86_64/lib/swift
lit.py: lit.cfg:281: note: Using Clang module cache: /var/folders/xl/kvdphsfj6230q3f8_m9h5zhw0000gn/T/swift-testsuite-clang-module-cacheVDw2y1
lit.py: lit.cfg:285: note: Using code completion cache: /var/folders/xl/kvdphsfj6230q3f8_m9h5zhw0000gn/T/swift-testsuite-completion-cacheyh0RpD
lit.py: lit.cfg:535: note: Testing OS X x86_64-apple-macosx10.9
lit.py: lit.cfg:614: note: Running tests on Mac OS X version 10.11.1 (15B42)
lit.py: lit.cfg:759: note: Using platform module dir: /Users/tyler/code/swift/build/Ninja-DebugAssert/swift-macosx-x86_64/lib/swift/%target-sdk-name/x86_64
lit.py: lit.cfg:211: note: using sourcekitd-test: /Users/tyler/code/swift/build/Ninja-DebugAssert/swift-macosx-x86_64/bin/sourcekitd-test
lit.py: lit.cfg:211: note: using complete-test: /Users/tyler/code/swift/build/Ninja-DebugAssert/swift-macosx-x86_64/bin/complete-test
Votes | 3 |
Component/s | |
Labels | Bug |
Assignee | tmandry (JIRA) |
Priority | Medium |
md5: b4c33156e31acff4d5ce4cbd74d5feb8
Issue Description:
I consistently get the following test failure when building from master (using
Previous ID | SR-58 |
Radar | None |
Original Reporter | dowobeha (JIRA User) |
Type | Bug |
Scientific Linux 7.1
Votes | 0 |
Component/s | Compiler |
Labels | Bug, BuildScript, Linux |
Assignee | smikes (JIRA) |
Priority | Medium |
md5: d176f61f71c26cf8b306c2e254f2e055
Issue Description:
Failure to build when using a bootstrapped ninja.
Steps to reproduce:
On Scientific Linux 7.1, install llvm, llvm-devel, clang, and cmake (version 2.8.11)
Create new directory for swift repos, and in that directory, clone all swift-related repos from github, as per README.md in the swift repo
In that same new directory, also clone ninja
Run ./swift/utils/build-script
See also swift-users mailing list thread titled "Bootstrapping ninja and building from source" started on Fri, 4 Dec 2015.
Results of running ./swift/utils/build-script:
which: no ninja in (/usr/lib64/qt-3.3/bin:/usr/local/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/home/lanes/.local/bin:/home/lanes/bin)
Building the standard library for: swift-stdlib-linux-x86_64
Running Swift tests for: check-swift-linux-x86_64
Previous ID | SR-68 |
Radar | None |
Original Reporter | @lilyball |
Type | Bug |
Swift version 2.2-dev (LLVM 46be9ff861, Clang 4deb154edc, Swift 3dbfefa)
Votes | 1 |
Component/s | Standard Library |
Labels | Bug |
Assignee | None |
Priority | Medium |
md5: d0004a1684c9d205b2caf0b3ae2fa8d3
Issue Description:
Code that uses SequenceType._preprocessingPass
will have the closure executed when the collection is a lazy collection. This is a problem because the closure almost certainly is going to access some property that forces lazy evaluation (for maps, that would be iterating over the elements; for filters, even just accessing the count will evaluate the filter). And this is a bad idea because the overhead of extra evaluations of the lazy computations is probably worse than the performance gain from doing the preprocessing pass.
I've reproduced this with <SequenceType where Generator.Element == String>.joinWithSeparator(String)
on a lazy map. This should apply to other situations as well. The test case for joinWithSeparator
looks like
JoinTestSuite.test("StringCollection.joinWithSeparator()") {
// make sure we only evaluate each element once
func testLazyJoin(separator: String, _ elements: [String]) {
var expectSeen: [Int: Int] = [:]
for i in 0..<elements.count {
expectSeen[i] = 1
}
var seen: [Int: Int] = [:]
// elements needs to be a collection, not a sequence
let elements = Array(elements.enumerate()).lazy.map({ (i, x) -> String in
seen[i] = (seen[i] ?? 0) + 1
return x
})
let _: String = elements.joinWithSeparator(separator)
expectEqual(expectSeen, seen)
}
testLazyJoin("", ["a"])
testLazyJoin("", ["a", "b", "c"])
testLazyJoin("xy", ["ab", "cd", "ef"])
}
I'm unsure what the correct behavior here is. If we make _preprocessingPass
skip the pass for lazy collections, that throws away some potential valid optimizations, such as relying on an exact count
for lazy maps, or optimizing on lazy reverses. But the alternative is to define several classifications of "safe" preprocessing and have separate preprocessing methods for each classification, so e.g. a lazy filter will never preprocess, a lazy map can preprocess for computations involving just the collection indexes, and lazy reverses can do everything. If we do go down this route, we'll have to make sure the lazy collections actually query their underlying base collection too if they think they can handle the pass, because they might be wrapping some other lazy collection that can't.
Previous ID | SR-76 |
Radar | None |
Original Reporter | jjl (JIRA User) |
Type | Bug |
Linux/gentoo
Votes | 0 |
Component/s | Compiler |
Labels | Bug |
Assignee | None |
Priority | Medium |
md5: 843cc2c4cddbb5da8ef07681f244739a
Issue Description:
I can't find any way to use a bridging header without using xcode. Is this feature missing, implemented in xcode or merely undocumented?
Previous ID | SR-15 |
Radar | None |
Original Reporter | @octoploid |
Type | Bug |
Status | Resolved |
Resolution | Done |
Votes | 1 |
Component/s | |
Labels | Bug, Linux |
Assignee | @bitjammer |
Priority | Medium |
md5: d5a5cc8c191684fcb73a1cae75fc477f
Issue Description:
stdlib/public/Glibc/module.map contains hardcoded paths to glibc headers.
On my system all "module sys" paths are wrong, e.g.:
header "/usr/include/x86_64-linux-gnu/sys/ipc.h"
lives in /usr/include/sys/ipc.h on my system.
Previous ID | SR-3 |
Radar | rdar://problem/21292236 |
Original Reporter | @jopamer |
Type | Bug |
Status | Closed |
Resolution | Won't Do |
Votes | 0 |
Component/s | Compiler |
Labels | Bug, StarterBug |
Assignee | None |
Priority | Medium |
md5: b0022cbdfcd07a37c2c13d958c707445
Issue Description:
In recent Swift, #if does not allow newlines in the condition.
% cat test.swift
#if os(OSX) ||
((os(iOS) || os(AppleTVOS)) && (arch(i386) || arch(arm))) ||
(os(watchOS) && arch(i386))
print("foo")
#else
print("bar")
#endif
% xcrun -sdk macosx swiftc test.swift
test.swift:1:5: error: expected '&&' or '||' expression
#if os(OSX) ||
^
Previous ID | SR-4 |
Radar | rdar://problem/18881232 |
Original Reporter | @jopamer |
Type | Bug |
Status | Reopened |
Resolution |
Votes | 1 |
Component/s | Compiler |
Labels | Bug |
Assignee | None |
Priority | Medium |
md5: b127305c866f6c4eaeed6bc743b091bc
Issue Description:
We don’t have a good versioning scheme to use on non-Darwin platforms, so API availability checking always returns false on non-Darwin.
If nothing else, we should consider adding a compile-time warning or error when this language feature is used.
Previous ID | SR-65 |
Radar | None |
Original Reporter | liangz (JIRA User) |
Type | Bug |
Status | Closed |
Resolution | Done |
Macbook Air with OS X Ei Capitan
Votes | 0 |
Component/s | Compiler |
Labels | Bug, BuildScript |
Assignee | None |
Priority | Medium |
md5: da5a5c9c9d5a1fb51b76d97c9f088459
Issue Description:
I am using Macbook Air with OS X EI Capitan, and I am building swift (commit number c959ce2) with the following command.
./build-script --debug-swift --make --build-subdir ../../build
The error is "CMake Error: Could not create named generator Unix".
Then, I copy the generated command and insert quotes for Unix Makefiles.
It builds correctly. I think there are something missing in the build-script for adding the quotes.
Previous ID | SR-69 |
Radar | None |
Original Reporter | @ddunbar |
Type | Bug |
Status | Resolved |
Resolution | Done |
Votes | 0 |
Component/s | Compiler |
Labels | Bug, DiagnosticsQoI |
Assignee | @gregomni |
Priority | Medium |
md5: ec6e593e3561b9b848b6e71011de74ba
Issue Description:
Swift produces a poor diagnostic on this example:
$ cat t.swift
func foo() {
for i in min(1,2) {
}
}
$ swiftc -c t.swift
t.swift:2:14: error: cannot invoke 'min' with an argument list of type '(Int, Int)'
for i in min(1,2) {
^
t.swift:2:14: note: expected an argument list of type '(T, T)'
for i in min(1,2) {
^
It should tell me I forgot to make a range.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.