Skip to content

Commit

Permalink
Add regression tests for 15.3 closure conversion crashes
Browse files Browse the repository at this point in the history
  • Loading branch information
agocke committed Sep 14, 2017
1 parent 2eba134 commit 37fac77
Showing 1 changed file with 92 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,98 @@ public static IMethodSymbol FindLocalFunction(this CompilationVerifier verifier,
[CompilerTrait(CompilerFeature.LocalFunctions)]
public class CodeGenLocalFunctionTests : CSharpTestBase
{
[Fact]
[WorkItem(21811, "https://github.com/dotnet/roslyn/issues/21811")]
public void Repro21811()
{
var comp = CreateStandardCompilation(@"
using System.Collections.Generic;
using System.Linq;
class Program
{
static void Main(string[] args)
{
var history = new List<long>();
Enumerable.Range(0, 5)
.Select(i =>
{
history.Insert(0, i);
return Test(i);
bool Test(int v)
{
history.Remove(0);
return Square(v) > 5;
}
int Square(int w)
{
return w * w;
}
});
}
}", references: new[] { LinqAssemblyRef });
}

[Fact]
[WorkItem(21645, "https://github.com/dotnet/roslyn/issues/21645")]
public void Repro21645()
{
CompileAndVerify(@"
public class Class1
{
private void Test()
{
bool outside = true;
void Inner() //This can also be a lambda (ie. Action action = () => { ... };)
{
void Bar()
{
}
void Foo()
{
Bar();
bool captured = outside;
}
}
}
}");
}

[Fact]
[WorkItem(21543, "https://github.com/dotnet/roslyn/issues/21543")]
public void Repro21543()
{
CompileAndVerify(@"
using System;
class Program
{
static void Method(Action action) { }
static void Main()
{
int value = 0;
Method(() =>
{
local();
void local()
{
Console.WriteLine(value);
Method(() =>
{
local();
});
}
});
}
}");
}

[Fact]
[WorkItem(472056, "https://devdiv.visualstudio.com/DevDiv/_workitems?id=472056")]
public void Repro472056()
Expand Down

0 comments on commit 37fac77

Please sign in to comment.