Skip to content
This repository has been archived by the owner on Jul 15, 2023. It is now read-only.

Using capturing precondition in async method in struct lead to invalid IL #168

Closed
SergeyTeplyakov opened this issue Jul 23, 2015 · 3 comments

Comments

@SergeyTeplyakov
Copy link
Contributor

This bug is related to the #157, but not similar.

Consider following code:

struct Foo
{
    public int Limit { get; set; }

    public Foo(int limit) : this()
    {
        Limit = 42;
    }

    public async Task<int> FooAsync()
    {
        Contract.Requires(Limit == 42);

        await Task.Delay(42);

        return 42;
    }
}

Running this code will lead to InvalidProgramException when preconditions are enabled.

CC version: 1.8+. This is not a regression, this stuff never worked properly.

Please note, the if the Contract.Requires will use arguments everything would be fine. Only when precondition is using this the app will fail.

@hubuk
Copy link
Contributor

hubuk commented Jan 19, 2016

@SergeyTeplyakov Are you working on this?

@SergeyTeplyakov
Copy link
Contributor Author

@hubuk At least not right now. I hope to merge pull requrests this week, so you can grab it.

@hubuk
Copy link
Contributor

hubuk commented Jan 20, 2016

Grabbed

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

No branches or pull requests

2 participants