Re: [swift-users] Assertion Failure When Using the swift-DEVELOPMENT-SNAPSHOT-2016-08-04-a Xcode Toolchain

2016-08-04 Thread Mark Lacey via swift-users

> On Aug 4, 2016, at 8:51 PM, Saagar Jha via swift-users 
>  wrote:
> 
> Hello Swift Users,
> 
> This afternoon I updated my Xcode to Xcode 8 beta 4, and tried to compile one 
> of my previously migrated Swift 3 projects. Along with a couple of renames, 
> the compiler kept crashing due to a segmentation fault. Since the issue 
> appeared to be similar to SR-2227, which was supposedly fixed with a pull 
> request a couple days ago, I downloaded today’s snapshot toolchain. The new 
> toolchain throws an assertion:
> 
> Assertion failed: (value != OpenExistentials.end() && "didn't see this OVE in 
> a containing OpenExistentialExpr?"), function walkToExprPre, file 
> /Users/buildnode/jenkins/workspace/oss-swift-package-osx/swift/lib/Sema/CSDiag.cpp,
>  line 3082.
> 0  swift0x00010a932ebb 
> llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 43
> 1  swift0x00010a932106 llvm::sys::RunSignalHandlers() 
> + 70
> 2  swift0x00010a93360f SignalHandler(int) + 383
> 3  libsystem_platform.dylib 0x7fffa6122d7a _sigtramp + 26
> 4  libsystem_platform.dylib 0x00010001 _sigtramp + 1508758177
> 5  swift0x00010a93335e abort + 14
> 6  swift0x00010a933341 __assert_rtn + 81
> 7  swift0x000108431879 
> eraseOpenedExistentials(swift::Expr*&)::ExistentialEraser::walkToExprPre(swift::Expr*)
>  + 361
> 8  swift0x0001085b8ea5 (anonymous 
> namespace)::Traversal::visit(swift::Expr*) + 4981
> 9  swift0x0001085b6f75 
> swift::Expr::walk(swift::ASTWalker&) + 53
> 10 swift0x00010842e375 (anonymous 
> namespace)::FailureDiagnosis::typeCheckChildIndependently(swift::Expr*, 
> swift::Type, swift::ContextualTypePurpose, swift::OptionSet unsigned int>, swift::ExprTypeCheckListener*) + 1221
> 11 swift0x000108434ea3 (anonymous 
> namespace)::FailureDiagnosis::typeCheckArgumentChildIndependently(swift::Expr*,
>  swift::Type, (anonymous namespace)::CalleeCandidateInfo const&, 
> swift::OptionSet) + 1987
> 12 swift0x00010843e9a1 (anonymous 
> namespace)::FailureDiagnosis::visitApplyExpr(swift::ApplyExpr*) + 913
> 13 swift0x000108428f6a swift::ASTVisitor<(anonymous 
> namespace)::FailureDiagnosis, bool, void, void, void, void, 
> void>::visit(swift::Expr*) + 170
> 14 swift0x000108422888 
> swift::constraints::ConstraintSystem::diagnoseFailureForExpr(swift::Expr*) + 
> 104
> 15 swift0x0001084289a8 
> swift::constraints::ConstraintSystem::salvage(llvm::SmallVectorImpl&,
>  swift::Expr*) + 4056
> 16 swift0x0001084ab665 
> swift::TypeChecker::solveForExpression(swift::Expr*&, swift::DeclContext*, 
> swift::Type, swift::FreeTypeVariableBinding, swift::ExprTypeCheckListener*, 
> swift::constraints::ConstraintSystem&, 
> llvm::SmallVectorImpl&, 
> swift::OptionSet) + 917
> 17 swift0x0001084b17d1 
> swift::TypeChecker::typeCheckExpression(swift::Expr*&, swift::DeclContext*, 
> swift::TypeLoc, swift::ContextualTypePurpose, 
> swift::OptionSet, 
> swift::ExprTypeCheckListener*, swift::constraints::ConstraintSystem*) + 625
> 18 swift0x00010852c061 swift::ASTVisitor<(anonymous 
> namespace)::StmtChecker, void, swift::Stmt*, void, void, void, 
> void>::visit(swift::Stmt*) + 545
> 19 swift0x00010852c543 swift::ASTVisitor<(anonymous 
> namespace)::StmtChecker, void, swift::Stmt*, void, void, void, 
> void>::visit(swift::Stmt*) + 1795
> 20 swift0x00010852bf8e swift::ASTVisitor<(anonymous 
> namespace)::StmtChecker, void, swift::Stmt*, void, void, void, 
> void>::visit(swift::Stmt*) + 334
> 21 swift0x00010852b369 (anonymous 
> namespace)::StmtChecker::typeCheckBody(swift::BraceStmt*&) + 25
> 22 swift0x00010852a63f 
> swift::TypeChecker::typeCheckFunctionBodyUntil(swift::FuncDecl*, 
> swift::SourceLoc) + 383
> 23 swift0x00010852a463 
> swift::TypeChecker::typeCheckAbstractFunctionBodyUntil(swift::AbstractFunctionDecl*,
>  swift::SourceLoc) + 35
> 24 swift0x00010852afe4 
> swift::TypeChecker::typeCheckAbstractFunctionBody(swift::AbstractFunctionDecl*)
>  + 180
> 25 swift0x0001084e5c56 
> typeCheckFunctionsAndExternalDecls(swift::TypeChecker&) + 166
> 26 swift0x0001084e68f0 
> swift::performTypeChecking(swift::SourceFile&, swift::TopLevelContext&, 
> swift::OptionSet, unsigned int, 
> unsigned int) + 1568
> 27 swift0x00010818798c 
> 

[swift-users] Assertion Failure When Using the swift-DEVELOPMENT-SNAPSHOT-2016-08-04-a Xcode Toolchain

2016-08-04 Thread Saagar Jha via swift-users
Hello Swift Users,

This afternoon I updated my Xcode to Xcode 8 beta 4, and tried to compile one 
of my previously migrated Swift 3 projects. Along with a couple of renames, the 
compiler kept crashing due to a segmentation fault. Since the issue appeared to 
be similar to SR-2227, which was supposedly fixed with a pull request a couple 
days ago, I downloaded today’s snapshot toolchain. The new toolchain throws an 
assertion:

Assertion failed: (value != OpenExistentials.end() && "didn't see this OVE in a 
containing OpenExistentialExpr?"), function walkToExprPre, file 
/Users/buildnode/jenkins/workspace/oss-swift-package-osx/swift/lib/Sema/CSDiag.cpp,
 line 3082.
0  swift0x00010a932ebb 
llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 43
1  swift0x00010a932106 llvm::sys::RunSignalHandlers() + 
70
2  swift0x00010a93360f SignalHandler(int) + 383
3  libsystem_platform.dylib 0x7fffa6122d7a _sigtramp + 26
4  libsystem_platform.dylib 0x00010001 _sigtramp + 1508758177
5  swift0x00010a93335e abort + 14
6  swift0x00010a933341 __assert_rtn + 81
7  swift0x000108431879 
eraseOpenedExistentials(swift::Expr*&)::ExistentialEraser::walkToExprPre(swift::Expr*)
 + 361
8  swift0x0001085b8ea5 (anonymous 
namespace)::Traversal::visit(swift::Expr*) + 4981
9  swift0x0001085b6f75 
swift::Expr::walk(swift::ASTWalker&) + 53
10 swift0x00010842e375 (anonymous 
namespace)::FailureDiagnosis::typeCheckChildIndependently(swift::Expr*, 
swift::Type, swift::ContextualTypePurpose, swift::OptionSet, swift::ExprTypeCheckListener*) + 1221
11 swift0x000108434ea3 (anonymous 
namespace)::FailureDiagnosis::typeCheckArgumentChildIndependently(swift::Expr*, 
swift::Type, (anonymous namespace)::CalleeCandidateInfo const&, 
swift::OptionSet) + 1987
12 swift0x00010843e9a1 (anonymous 
namespace)::FailureDiagnosis::visitApplyExpr(swift::ApplyExpr*) + 913
13 swift0x000108428f6a swift::ASTVisitor<(anonymous 
namespace)::FailureDiagnosis, bool, void, void, void, void, 
void>::visit(swift::Expr*) + 170
14 swift0x000108422888 
swift::constraints::ConstraintSystem::diagnoseFailureForExpr(swift::Expr*) + 104
15 swift0x0001084289a8 
swift::constraints::ConstraintSystem::salvage(llvm::SmallVectorImpl&,
 swift::Expr*) + 4056
16 swift0x0001084ab665 
swift::TypeChecker::solveForExpression(swift::Expr*&, swift::DeclContext*, 
swift::Type, swift::FreeTypeVariableBinding, swift::ExprTypeCheckListener*, 
swift::constraints::ConstraintSystem&, 
llvm::SmallVectorImpl&, 
swift::OptionSet) + 917
17 swift0x0001084b17d1 
swift::TypeChecker::typeCheckExpression(swift::Expr*&, swift::DeclContext*, 
swift::TypeLoc, swift::ContextualTypePurpose, 
swift::OptionSet, 
swift::ExprTypeCheckListener*, swift::constraints::ConstraintSystem*) + 625
18 swift0x00010852c061 swift::ASTVisitor<(anonymous 
namespace)::StmtChecker, void, swift::Stmt*, void, void, void, 
void>::visit(swift::Stmt*) + 545
19 swift0x00010852c543 swift::ASTVisitor<(anonymous 
namespace)::StmtChecker, void, swift::Stmt*, void, void, void, 
void>::visit(swift::Stmt*) + 1795
20 swift0x00010852bf8e swift::ASTVisitor<(anonymous 
namespace)::StmtChecker, void, swift::Stmt*, void, void, void, 
void>::visit(swift::Stmt*) + 334
21 swift0x00010852b369 (anonymous 
namespace)::StmtChecker::typeCheckBody(swift::BraceStmt*&) + 25
22 swift0x00010852a63f 
swift::TypeChecker::typeCheckFunctionBodyUntil(swift::FuncDecl*, 
swift::SourceLoc) + 383
23 swift0x00010852a463 
swift::TypeChecker::typeCheckAbstractFunctionBodyUntil(swift::AbstractFunctionDecl*,
 swift::SourceLoc) + 35
24 swift0x00010852afe4 
swift::TypeChecker::typeCheckAbstractFunctionBody(swift::AbstractFunctionDecl*) 
+ 180
25 swift0x0001084e5c56 
typeCheckFunctionsAndExternalDecls(swift::TypeChecker&) + 166
26 swift0x0001084e68f0 
swift::performTypeChecking(swift::SourceFile&, swift::TopLevelContext&, 
swift::OptionSet, unsigned int, 
unsigned int) + 1568
27 swift0x00010818798c 
swift::CompilerInstance::performSema() + 3916
28 swift0x000107c82ad1 
performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, 
llvm::ArrayRef, int&, swift::FrontendObserver*) + 449
29 swift0x000107c8163f 
swift::performFrontend(llvm::ArrayRef, 

Re: [swift-users] Cleaner way than if let initialization?

2016-08-04 Thread Zhao Xin via swift-users
Thank you. I think this is the best I saw today.

Zhaoxin

On Fri, Aug 5, 2016 at 5:24 AM, Erica Sadun via swift-users <
swift-users@swift.org> wrote:

> And Greg from Omni Group has an even better solution for you.  Since
> DateFormatter inherits from Formatter, you can use its `string(for:)` which
> accepts optionals:
>
> let dobString3 = serverDateFormatter.string(for:dob) ?? ""
>
> -- E
>
> On Aug 4, 2016, at 3:17 PM, Erica Sadun via swift-users <
> swift-users@swift.org> wrote:
>
>
> On Aug 4, 2016, at 1:41 PM, Tim Vermeulen via swift-users <
> swift-users@swift.org> wrote:
>
> You want `flatMap`:
>
> let dobString = dob.flatMap(serverDateFormatter.stringFromDate)
>
> Or if you want `dobString` to be non-optional:
>
> let dobString = dob.flatMap(serverDateFormatter.stringFromDate) ?? “"
>
>
> You can just use map here too, right?
>
> let dobString2: String = dob.map(serverDateFormatter.string) ?? ""
>
> I was a little surprised that this didn't need the rest of the selector
> signature but that's because parameter stripping and type matching, isn't
> it?
>
>
> Currently I do stuff like this:
>
> letdobString:String
> ifletdob = dob {
> dobString =serverDateFormatter.stringFromDate(dob)
> }
> else{
> dobString =""
> }
>
> Is there a better, more idiomatic, way to do this sort of thing?
>
>
>
>
> ___
> swift-users mailing list
> swift-users@swift.org
> https://lists.swift.org/mailman/listinfo/swift-users
>
>
> ___
> swift-users mailing list
> swift-users@swift.org
> https://lists.swift.org/mailman/listinfo/swift-users
>
>
>
> ___
> swift-users mailing list
> swift-users@swift.org
> https://lists.swift.org/mailman/listinfo/swift-users
>
>
___
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users


Re: [swift-users] 2016-08-04-a-osx snapshot corrupt?

2016-08-04 Thread Jose Cheyo Jimenez via swift-users
A nice person at apple told me a work around. 

Just quit Xcode and it will work. :)



> On Aug 4, 2016, at 5:47 PM, Jose Cheyo Jimenez  wrote:
> 
> swift-DEVELOPMENT-SNAPSHOT-2016-08-04-a-osx
> 
> What is going on here? Why is the image not signed? Anybody having the same 
> issues?
> 
> I’ve download it multiple times. 
> 
> Aug  4 14:32:14 MacBook Installer[1580]: Error parsing distribution script 
> from data
> Aug  4 14:32:14 MacBook xmllint[1586]: -:1: parser error : Document is empty
> Aug  4 14:32:14 MacBook Installer[1580]: Invalid Distribution File/Package
> 
> https://cloud.githubusercontent.com/assets/6539412/17422882/07e38762-5a6b-11e6-8845-af0b110a2039.png
>  
> 
___
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users


[swift-users] 2016-08-04-a-osx snapshot corrupt?

2016-08-04 Thread Jose Cheyo Jimenez via swift-users
swift-DEVELOPMENT-SNAPSHOT-2016-08-04-a-osx

What is going on here? Why is the image not signed? Anybody having the same 
issues?

I’ve download it multiple times. 

Aug  4 14:32:14 MacBook Installer[1580]: Error parsing distribution script from 
data
Aug  4 14:32:14 MacBook xmllint[1586]: -:1: parser error : Document is empty
Aug  4 14:32:14 MacBook Installer[1580]: Invalid Distribution File/Package

https://cloud.githubusercontent.com/assets/6539412/17422882/07e38762-5a6b-11e6-8845-af0b110a2039.png
 
___
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users


Re: [swift-users] build-toolchain failing

2016-08-04 Thread David Liu via swift-users
Thanks Mishal!

My fault I did not install the latests Xcode, thanks again for the help!
Everything is building fine now.

I do have another question was wondering if you had any tips.
I am currently debugging the toolchain via REPL, creating a test function
and setting a break point
1> func test(){
2>   Array.myFunc()
3> }
e.g (:b 2) and then stepping in to the std lib functions.
The problem I am facing is that i am not able to figure out how to set a
break point on a std lib function that i have modified with out stepping in
from the test function. I would like to be able to set a break point  :b
Array.swift.gyb:809 with out having to step in from the test function in
the REPL. When i try i get no locations.
4> :b Array.swift.gyb:800
Breakpoint 1: no locations (pending)

Any help is much appreciated, this would help speed up debugging time
significantly.

Cheers

Dave





On Thu, Aug 4, 2016 at 10:45 AM, Mishal Shah  wrote:

> Hi David,
>
> Which version of Xcode are you using? We now require Xcode 8 Beta 4 to be
> able to build swift. Also, please provide full error message.
>
> Thanks,
> Mishal Shah
>
> On Aug 4, 2016, at 2:00 AM, David Liu via swift-users <
> swift-users@swift.org> wrote:
>
> I am getting errors compiling the toolchain from the tip of master.
> Specifically inside of stdlib/SDK/.., it has some syntax issue which leads
> to compilation failure.
> I did a swift/utils/update-checkout then swift/utils/build-toolchain.
> I see the CI builds are green, am I out of sync some where?  Any help
> would be much appreciated.
>
> Thanks
>
> Dave
> ___
> swift-users mailing list
> swift-users@swift.org
> https://lists.swift.org/mailman/listinfo/swift-users
>
>
>
___
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users


Re: [swift-users] Cleaner way than if let initialization?

2016-08-04 Thread Erica Sadun via swift-users

> On Aug 4, 2016, at 1:41 PM, Tim Vermeulen via swift-users 
>  wrote:
> 
> You want `flatMap`:
> 
> let dobString = dob.flatMap(serverDateFormatter.stringFromDate)
> 
> Or if you want `dobString` to be non-optional:
> 
> let dobString = dob.flatMap(serverDateFormatter.stringFromDate) ?? “"

You can just use map here too, right?

let dobString2: String = dob.map(serverDateFormatter.string) ?? ""

I was a little surprised that this didn't need the rest of the selector 
signature but that's because parameter stripping and type matching, isn't it?

> 
>> Currently I do stuff like this:
>> 
>> letdobString:String
>> ifletdob = dob {
>> dobString =serverDateFormatter.stringFromDate(dob)
>> }
>> else{
>> dobString =""
>> }
>> 
>> Is there a better, more idiomatic, way to do this sort of thing?
>> 
>> 
>> 
>> 
> ___
> swift-users mailing list
> swift-users@swift.org
> https://lists.swift.org/mailman/listinfo/swift-users

___
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users


Re: [swift-users] Cleaner way than if let initialization?

2016-08-04 Thread Erica Sadun via swift-users

> On Aug 4, 2016, at 11:32 AM, Daniel Tartaglia via swift-users 
>  wrote:
> 
> Currently I do stuff like this:
> 
> let dobString: String
> if let dob = dob {
>   dobString = serverDateFormatter.stringFromDate(dob)
> }
> else {
>   dobString = ""
> }
> 
> Is there a better, more idiomatic, way to do this sort of thing?

So if I understand this correctly `dob` is an optional date, and `dobString` is 
a non-optional String. Right? 

If that's what you're dealing with, then you  basically to do a double 
conditional: dob is optional, and stringFromDate returns optional, right? I'd 
do it like this:

let dobString: String = {
guard
let dob = dob,
let dobString = serverDateFormatter.stringFromDate(dob)
else { return "" }
return dobString
}()

But if serverDateFormatter is actually a NSDateFormatter instance, which does 
not return optionals, then you'd want to go with:

let dobString: String = {
guard let dob = dob else { return "" }
return serverDateFormatter.string(from:dob)
}()

-- E___
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users


Re: [swift-users] Cleaner way than if let initialization?

2016-08-04 Thread Daniel Tartaglia via swift-users
Thanks Tim!

> On Aug 4, 2016, at 3:41 PM, Tim Vermeulen  wrote:
> 
> You want `flatMap`:
> 
> let dobString = dob.flatMap(serverDateFormatter.stringFromDate)
> 
> Or if you want `dobString` to be non-optional:
> 
> let dobString = dob.flatMap(serverDateFormatter.stringFromDate) ?? “"
> 
>> Currently I do stuff like this:
>> 
>> letdobString:String
>> ifletdob = dob {
>> dobString =serverDateFormatter.stringFromDate(dob)
>> }
>> else{
>> dobString =""
>> }
>> 
>> Is there a better, more idiomatic, way to do this sort of thing?
>> 
>> 
>> 

___
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users


Re: [swift-users] Cleaner way than if let initialization?

2016-08-04 Thread Saagar Jha via swift-users
Oh, wait, I can’t read. Ignore that; then there’s no easy way to do it.

Saagar Jha



> On Aug 4, 2016, at 12:42, Saagar Jha  wrote:
> 
> Ahh…then optional chaining is the way to go: `let dobString = 
> serverDateFormatter?.stringFromDate(dob) ?? ""`
> 
> Saagar Jha
> 
> 
> 
>> On Aug 4, 2016, at 12:41, Daniel Tartaglia > > wrote:
>> 
>> That’s not possible. stringFromDate requires an NSDate, but dob is an 
>> optional
>> 
>>> On Aug 4, 2016, at 2:59 PM, Saagar Jha >> > wrote:
>>> 
>>> As such, there shouldn’t be a need for an if; `let dobString = 
>>> serverDateFormatter.stringFromDate(dob)` should be sufficient.
>>> 
>>> Saagar Jha
>>> 
>>> 
>>> 
 On Aug 4, 2016, at 11:55, Zhao Xin via swift-users > wrote:
 
 It can't be done by ?? as stringFromDate(Date) returns String instead of 
 String?
 
 Zhaoxin
 
 
 On Fri, Aug 5, 2016 at 1:42 AM, Jeff Kelley via swift-users 
 > wrote:
 That’s where I would use the ?? operator:
 
 let dobString = serverDateFormatter.stringFromDate(dob) ?? ""
 
 
 Jeff Kelley
 
 slauncha...@gmail.com  | @SlaunchaMan 
  | jeffkelley.org 
> On Aug 4, 2016, at 1:32 PM, Daniel Tartaglia via swift-users 
> > wrote:
> 
> Currently I do stuff like this:
> 
> let dobString: String
> if let dob = dob {
>   dobString = serverDateFormatter.stringFromDate(dob)
> }
> else {
>   dobString = ""
> }
> 
> Is there a better, more idiomatic, way to do this sort of thing?
> 
> ___
> swift-users mailing list
> swift-users@swift.org 
> https://lists.swift.org/mailman/listinfo/swift-users 
> 
 
 
 ___
 swift-users mailing list
 swift-users@swift.org 
 https://lists.swift.org/mailman/listinfo/swift-users 
 
 
 
 ___
 swift-users mailing list
 swift-users@swift.org 
 https://lists.swift.org/mailman/listinfo/swift-users 
 
>>> 
>> 
> 

___
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users


[swift-users] Cleaner way than if let initialization?

2016-08-04 Thread Tim Vermeulen via swift-users
You want `flatMap`:

let dobString = dob.flatMap(serverDateFormatter.stringFromDate)

Or if you want `dobString` to be non-optional:

let dobString = dob.flatMap(serverDateFormatter.stringFromDate) ?? “"

> Currently I do stuff like this:
> 
> letdobString:String
> ifletdob = dob {
> dobString =serverDateFormatter.stringFromDate(dob)
> }
> else{
> dobString =""
> }
> 
> Is there a better, more idiomatic, way to do this sort of thing?
> 
> 
> 
> 
___
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users


Re: [swift-users] Cleaner way than if let initialization?

2016-08-04 Thread Daniel Tartaglia via swift-users
That’s not possible. stringFromDate requires an NSDate, but dob is an 
optional

> On Aug 4, 2016, at 2:59 PM, Saagar Jha  wrote:
> 
> As such, there shouldn’t be a need for an if; `let dobString = 
> serverDateFormatter.stringFromDate(dob)` should be sufficient.
> 
> Saagar Jha
> 
> 
> 
>> On Aug 4, 2016, at 11:55, Zhao Xin via swift-users > > wrote:
>> 
>> It can't be done by ?? as stringFromDate(Date) returns String instead of 
>> String?
>> 
>> Zhaoxin
>> 
>> 
>> On Fri, Aug 5, 2016 at 1:42 AM, Jeff Kelley via swift-users 
>> > wrote:
>> That’s where I would use the ?? operator:
>> 
>> let dobString = serverDateFormatter.stringFromDate(dob) ?? ""
>> 
>> 
>> Jeff Kelley
>> 
>> slauncha...@gmail.com  | @SlaunchaMan 
>>  | jeffkelley.org 
>>> On Aug 4, 2016, at 1:32 PM, Daniel Tartaglia via swift-users 
>>> > wrote:
>>> 
>>> Currently I do stuff like this:
>>> 
>>> let dobString: String
>>> if let dob = dob {
>>> dobString = serverDateFormatter.stringFromDate(dob)
>>> }
>>> else {
>>> dobString = ""
>>> }
>>> 
>>> Is there a better, more idiomatic, way to do this sort of thing?
>>> 
>>> ___
>>> swift-users mailing list
>>> swift-users@swift.org 
>>> https://lists.swift.org/mailman/listinfo/swift-users 
>>> 
>> 
>> 
>> ___
>> swift-users mailing list
>> swift-users@swift.org 
>> https://lists.swift.org/mailman/listinfo/swift-users 
>> 
>> 
>> 
>> ___
>> swift-users mailing list
>> swift-users@swift.org 
>> https://lists.swift.org/mailman/listinfo/swift-users
> 

___
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users


Re: [swift-users] Cleaner way than if let initialization?

2016-08-04 Thread Saagar Jha via swift-users
As such, there shouldn’t be a need for an if; `let dobString = 
serverDateFormatter.stringFromDate(dob)` should be sufficient.

Saagar Jha



> On Aug 4, 2016, at 11:55, Zhao Xin via swift-users  
> wrote:
> 
> It can't be done by ?? as stringFromDate(Date) returns String instead of 
> String?
> 
> Zhaoxin
> 
> 
> On Fri, Aug 5, 2016 at 1:42 AM, Jeff Kelley via swift-users 
> > wrote:
> That’s where I would use the ?? operator:
> 
> let dobString = serverDateFormatter.stringFromDate(dob) ?? ""
> 
> 
> Jeff Kelley
> 
> slauncha...@gmail.com  | @SlaunchaMan 
>  | jeffkelley.org 
>> On Aug 4, 2016, at 1:32 PM, Daniel Tartaglia via swift-users 
>> > wrote:
>> 
>> Currently I do stuff like this:
>> 
>> let dobString: String
>> if let dob = dob {
>>  dobString = serverDateFormatter.stringFromDate(dob)
>> }
>> else {
>>  dobString = ""
>> }
>> 
>> Is there a better, more idiomatic, way to do this sort of thing?
>> 
>> ___
>> swift-users mailing list
>> swift-users@swift.org 
>> https://lists.swift.org/mailman/listinfo/swift-users 
>> 
> 
> 
> ___
> swift-users mailing list
> swift-users@swift.org 
> https://lists.swift.org/mailman/listinfo/swift-users 
> 
> 
> 
> ___
> swift-users mailing list
> swift-users@swift.org
> https://lists.swift.org/mailman/listinfo/swift-users

___
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users


Re: [swift-users] Cleaner way than if let initialization?

2016-08-04 Thread Zhao Xin via swift-users
It can't be done by ?? as stringFromDate(Date) returns String instead of
String?

Zhaoxin


On Fri, Aug 5, 2016 at 1:42 AM, Jeff Kelley via swift-users <
swift-users@swift.org> wrote:

> That’s where I would use the ?? operator:
>
> let dobString = serverDateFormatter.stringFromDate(dob) ?? ""
>
>
> Jeff Kelley
>
> slauncha...@gmail.com | @SlaunchaMan  |
> jeffkelley.org
>
> On Aug 4, 2016, at 1:32 PM, Daniel Tartaglia via swift-users <
> swift-users@swift.org> wrote:
>
> Currently I do stuff like this:
>
> let dobString: String
> if let dob = dob {
> dobString = serverDateFormatter.stringFromDate(dob)
> }
> else {
> dobString = ""
> }
>
> Is there a better, more idiomatic, way to do this sort of thing?
>
> ___
> swift-users mailing list
> swift-users@swift.org
> https://lists.swift.org/mailman/listinfo/swift-users
>
>
>
> ___
> swift-users mailing list
> swift-users@swift.org
> https://lists.swift.org/mailman/listinfo/swift-users
>
>
___
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users


Re: [swift-users] Cleaner way than if let initialization?

2016-08-04 Thread Jeff Kelley via swift-users
That’s where I would use the ?? operator:

let dobString = serverDateFormatter.stringFromDate(dob) ?? ""


Jeff Kelley

slauncha...@gmail.com | @SlaunchaMan  | 
jeffkelley.org 
> On Aug 4, 2016, at 1:32 PM, Daniel Tartaglia via swift-users 
>  wrote:
> 
> Currently I do stuff like this:
> 
> let dobString: String
> if let dob = dob {
>   dobString = serverDateFormatter.stringFromDate(dob)
> }
> else {
>   dobString = ""
> }
> 
> Is there a better, more idiomatic, way to do this sort of thing?
> 
> ___
> swift-users mailing list
> swift-users@swift.org
> https://lists.swift.org/mailman/listinfo/swift-users

___
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users


[swift-users] Cleaner way than if let initialization?

2016-08-04 Thread Daniel Tartaglia via swift-users
Currently I do stuff like this:

let dobString: String
if let dob = dob {
dobString = serverDateFormatter.stringFromDate(dob)
}
else {
dobString = ""
}

Is there a better, more idiomatic, way to do this sort of thing?

___
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users


[swift-users] build-toolchain failing

2016-08-04 Thread David Liu via swift-users
I am getting errors compiling the toolchain from the tip of master.
Specifically inside of stdlib/SDK/.., it has some syntax issue which leads
to compilation failure.
I did a swift/utils/update-checkout then swift/utils/build-toolchain.
I see the CI builds are green, am I out of sync some where?  Any help would
be much appreciated.

Thanks

Dave
___
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users


Re: [swift-users] generic function called recursively not compiling

2016-08-04 Thread Kevin Nattinger via swift-users
Looks like a bug in the type inference system to me, but I’ll let someone with 
a better knowledge of the compiler confirm. Meanwhile, you can work around by 
explicitly casting any of the pieces of the return statement to `[Element]` or 
using a temporary for one or more of them.

let middle = [pivot]
return quickSort(left) + middle + quickSort(right)

return quickSort(left) as [Element] + [pivot] + quickSort(right)

return quickSort(left) + ([pivot] as [Element]) + quickSort(right)


> On Aug 4, 2016, at 9:02 AM, Ray Fix via swift-users  
> wrote:
> 
> 
> I filed rdar://27700622  and attached a playground.  Any 
> workaround magic I can do here?
> 
> func quickSort(_ input: [Element]) -> [Element] {
> if input.count < 2 {
> return input
> }
> let pivot = input.first!
> let left = input.dropFirst().filter { $0 <= pivot }
> let right = input.dropFirst().filter { $0 > pivot }
> 
> // Does not compile with (Swift 3pre) Xcode 8 b1,2,3,4
> // Does compile with (Swift 2.2) Xcode 7.3
> return quickSort(left) + [pivot] + quickSort(right)
> }
> 
> quickSort([3,5,1,2])
> 
> Error:
> //Playground execution failed: error: quicksort.playground:11:22: error: 
> cannot convert value of type '[Element]' to expected argument type '[_]'
> //return quickSort(left) + [pivot] + quickSort(right)
> // ^~~~
> 
> 
> ___
> swift-users mailing list
> swift-users@swift.org
> https://lists.swift.org/mailman/listinfo/swift-users

___
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users


[swift-users] generic function called recursively not compiling

2016-08-04 Thread Ray Fix via swift-users

I filed rdar://27700622  and attached a playground.  Any 
workaround magic I can do here?

func quickSort(_ input: [Element]) -> [Element] {
if input.count < 2 {
return input
}
let pivot = input.first!
let left = input.dropFirst().filter { $0 <= pivot }
let right = input.dropFirst().filter { $0 > pivot }

// Does not compile with (Swift 3pre) Xcode 8 b1,2,3,4
// Does compile with (Swift 2.2) Xcode 7.3
return quickSort(left) + [pivot] + quickSort(right)
}

quickSort([3,5,1,2])

Error:
//Playground execution failed: error: quicksort.playground:11:22: error: cannot 
convert value of type '[Element]' to expected argument type '[_]'
//return quickSort(left) + [pivot] + quickSort(right)
// ^~~~


___
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users


[swift-users] try? priority

2016-08-04 Thread J.E. Schotsman via swift-users
I was surprised when I got a compiler error for this code:

if try? MyThrowingFunction() != nil {…} (MyThrowingFunction does not return 
an optional value)

This compiles:

if (try? MyThrowingFunction) != nil {…} (Xcode 7.3.1)

Shouldn’t try? have higher priority than != here?

Please disregard if this is changed in Swift 3

Jan E.
___
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users


Re: [swift-users] non-mutating func that still mutates a struct, compiler not aware

2016-08-04 Thread Brent Royal-Gordon via swift-users
> On Aug 4, 2016, at 1:25 AM, Raphael Sebbe via swift-users 
>  wrote:
> 
> My understanding is that the compiler doesn't make a real copy in the acopy = 
>  self instruction, and then provides that contents to the mx_gels_ function 
> which modifies the memory contents.
> 
> 
> public func solve(rhs b: Matrix) -> Matrix? {
>   // ...
>   var acopy = self
>   // ...
> 
>   T.mx_gels_(, , , , 
> UnsafeMutablePointer(acopy.values), , 
> UnsafeMutablePointer(x.values), , UnsafeMutablePointer(workspace), 
> , );
>   
>   // ...
>   }
> 
> 
> Is this expected? I mean, I can force a real copy of course, but value 
> semantics would suggest the code above is correct and wouldn't need that. 
> Shouldn't the cast trigger the copy somehow? Or is there a better way of 
> expressing this operation? Thx.

The `acopy = self` line only copies the reference to the internal buffer. 
However, converting the array into a pointer will—or at least, if done 
properly, *should*—force the array to create and switch to using a unique copy 
of its buffer in preparation for writes through the UnsafeMutablePointer. I 
believe that happens here: 


(I say "should" because I'm not sure you're actually creating those pointers 
correctly. I believe you ought to be able to just say `` and 
``, and that should be a more reliable way to do it.)

-- 
Brent Royal-Gordon
Architechies

___
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users