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

CCRewrite fails with NRE on async method with Ensures.ForAll with captured params #69

Closed
SergeyTeplyakov opened this issue Jun 23, 2015 · 2 comments

Comments

@SergeyTeplyakov
Copy link
Contributor

Code contracts repo has a bunch of tests for async methods. Unfortunately, some of them are broken.

For instance, tests for async6.cs to async9.cs will fail because ccrewrite.exe will return -1.

Here is a small repo for the issue:

class TestTaskContracts
{
    public async Task<List<int>> FooAsync(int limit)
    {
        Contract.Ensures(Contract.ForAll(Contract.Result<List<int>>(), i => i < limit));

        await Task.Delay(42);

        return Enumerable.Range(1, 10).ToList();
    }
}

Running ccrewrite on this class will fail with NullReferenceException at System.Compiler.Writer.cs line 1814.

@SergeyTeplyakov SergeyTeplyakov added this to the VS14 Support milestone Jun 23, 2015
SergeyTeplyakov added a commit to SergeyTeplyakov/CodeContracts that referenced this issue Jun 26, 2015
Root cause of the NRE is "local variable name erasure" that happens
during closure cloning.
Fix preserves closure names for async contracts.
Related work items: microsoft#72, microsoft#69
SergeyTeplyakov added a commit to SergeyTeplyakov/CodeContracts that referenced this issue Jul 8, 2015
SergeyTeplyakov added a commit to SergeyTeplyakov/CodeContracts that referenced this issue Jul 8, 2015
@sharwell
Copy link
Member

sharwell commented Jul 8, 2015

@SergeyTeplyakov Label fixed instead of up for grabs?

@SergeyTeplyakov
Copy link
Contributor Author

Done.

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