tinysun212 / swift-windows

Swift compiler for Cygwin, MSVC, MinGW. Full development environment can be downloaded from the Swift for Windows.
http://SwiftForWindows.github.io
Apache License 2.0
331 stars 30 forks source link

[MinGW] Does not work exceptions throws/catches #5

Closed GunGraveKoga closed 7 years ago

GunGraveKoga commented 7 years ago

Simple example:

import Swift

enum TestErrors: Error {
    case MyError
}

func test() throws -> String {
    throw TestErrors.MyError 
}

print("Start execution")

let str:String?

do {
    str = try test()
} catch {
    print("Error")
}

print("End execution")

Output:

$ swift ./main.swift
Start execution
#0 0x000000006c3b8ab3 swift_slowAlloc (C:\msys64\swift\lib\swift\mingw\libswiftCore.dll+0x238ab3)
#1 0x000000006c3b8af3 _swift_allocObject_ (C:\msys64\swift\lib\swift\mingw\libswiftCore.dll+0x238af3)
#2 0x000000006c3b8862 swift_allocError (C:\msys64\swift\lib\swift\mingw\libswiftCore.dll+0x238862)
#3 0x00000000003f045d
#4 0x000000006c3f169d (C:\msys64\swift\lib\swift\mingw\libswiftCore.dll+0x27169d)
#5 0x0000000000000001
tinysun212 commented 7 years ago

Thanks for your report.

Latest update-with-windows branch for Cygwin passes your test code.

$ swift issue_5.swift
Start execution
Error
End execution

I'll update MinGW version after releasing Cygwin binary in the near future.

GunGraveKoga commented 7 years ago

With latest swift compiler for MinGW-W64 all works fine

tinysun212 commented 7 years ago

Thanks for your test.