Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#expect(try ...) from inside a closure causes "errors thrown from here are not handled" error #78395

Open
gwynne opened this issue Dec 31, 2024 · 2 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior.

Comments

@gwynne
Copy link
Contributor

gwynne commented Dec 31, 2024

Description

When the expression passed to #expect() contains try, and the #expect() call occurs inside a throwing closure, the compiler emits an "errors thrown from here are not handled" error.

Verified using Xcode 16.2, release/6.1 dev snapshot (2024-12-21), and main dev snapshot (2024-12-22).

Expected behavior

The try keyword should be usable inside the #expect() macro, as it is under non-closure conditions.

Actual behavior

The compiler refuses to compile the expression.

Steps to reproduce

See attached reproducer: TestPackage.zip

swift-testing version/commit hash

6.0.3

Swift & OS version (output of swift --version ; uname -a)

swift-driver version: 1.115.1 Apple Swift version 6.0.3 (swiftlang-6.0.3.1.10 clang-1600.0.30.1)
Target: arm64-apple-macosx15.0
Darwin MacBookPro 24.2.0 Darwin Kernel Version 24.2.0: Fri Dec  6 19:01:59 PST 2024; root:xnu-11215.61.5~2/RELEASE_ARM64_T6000 arm64
@gwynne gwynne added the bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. label Dec 31, 2024
@grynspan
Copy link
Contributor

Gwynne also reproed with:

$ TOOLCHAINS=$(plutil -extract CFBundleIdentifier raw /Library/Developer/Toolchains/swift-6.1-DEVELOPMENT-SNAPSHOT-2024-12-21-a.xctoolchain/Info.plist) swift --version
Apple Swift version 6.1-dev (LLVM dd0f3b29e584617, Swift 12fb6cb92508551)
Target: arm64-apple-macosx15.0

And:

$ TOOLCHAINS=$(plutil -extract CFBundleIdentifier raw /Library/Developer/Toolchains/swift-DEVELOPMENT-SNAPSHOT-2024-12-22-a.xctoolchain/Info.plist) swift --version
Apple Swift version 6.2-dev (LLVM 9f6c3d784782c34, Swift 55189bae8e55169)
Target: arm64-apple-macosx15.0

And with the experimental swift-testing branch at swiftlang/swift-testing#840 which produces completely different macro expansions.

Looks like a type-checking issue to me, so sending this along to swift.

@grynspan grynspan transferred this issue from swiftlang/swift-testing Dec 31, 2024
@grynspan
Copy link
Contributor

I suspect this is a duplicate of #75256.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior.
Projects
None yet
Development

No branches or pull requests

2 participants