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

Task never completes #5

Closed
dimazen opened this issue Mar 23, 2016 · 2 comments
Closed

Task never completes #5

dimazen opened this issue Mar 23, 2016 · 2 comments
Assignees
Labels

Comments

@dimazen
Copy link

dimazen commented Mar 23, 2016

When your framework compiled with optimizations (try to install via Carthage) assert is not checked. Therefore this code from the TaskCompletionSource is never executed:

    public func setResult(result: TResult) {
        assert(task.trySetState(.Success(result)), "Can not set the result on a completed task.")
    }

As Apple mentions:

/// Traditional C-style assert with an optional message.
....
/// * In -O builds (the default for Xcode's Release configuration),
///   `condition` is not evaluated, and there are no effects.
@nlutsenko
Copy link
Member

(-‸ლ) You are absolutely correct, we should indeed use a precondition here, so it's not optimized away.

@dimazen
Copy link
Author

dimazen commented Mar 23, 2016

I would suggest to distinguish execution and evaluation, since precondition can be ignored under some settings:

/// * In -Ounchecked builds, `condition` is not evaluated, but the
///   optimizer may assume that it *would* evaluate to `true`. Failure
///   to satisfy that assumption in -Ounchecked builds is a serious
///   programming error.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants