On Thu, 5 Jan 2017, at 18:13, Ankit Agarwal wrote:

> Using swift module in REPL:



[...]



> $ swift build

> $ swift -I .build/debug -L .build/debug -lResult -I
> /usr/lib/clang/3.8/include
> Welcome to Swift version 3.1-dev (LLVM 217eb6c2b6, Clang 34a98ce92e,
> Swift 1eb5648c46). Type :help for assistance.
>   1> import Result

>   2> let a = Result<String, AnyError>("a")

> a: Result.Result<String, Result.AnyError> = success {

>   success = "a"

> }



Oh wait, this works for me! It was the specific thing I was trying to
do (wrapping an NSError instance in an AnyError) that breaks  which
was leading me to think importing the Result library into the REPL
wasn't working:


$ swift -I.build/debug -L.build/debug -lResult
Welcome to Swift version 3.0.2 (swift-3.0.2-RELEASE). Type :help for
assistance.
  1> import Foundation

  2> import Result

  3> let r = Result<String, AnyError>("a")

r: Result.Result<String, Result.AnyError> = success {

  success = "a"

}

  4> let nse = NSError(domain: "Foo", code: 42, userInfo: nil)

nse: Foundation.NSError = {

  Foundation.NSObject = {}

  _domain = "Foo"

  _code = 42

  _userInfo = nil

}

  5> let ae = AnyError(nse)

ae: Result.AnyError = {

  error = <extracting data from value failed>



}

Execution interrupted. Enter code to recover and continue.

Enter LLDB commands to investigate (type :help for assistance.)

  6>  



So it looks like I have a Foundation on Linux bug? I will do what the
REPL suggests and see if I can figure out what's going on.


Thanks, Robert.
_______________________________________________
swift-users mailing list
swift-users@swift.org
https://lists.swift.org/mailman/listinfo/swift-users

Reply via email to