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

csc.exe crashes with exit code -2146232797 #21811

Closed
wldevries opened this issue Aug 30, 2017 · 5 comments
Closed

csc.exe crashes with exit code -2146232797 #21811

wldevries opened this issue Aug 30, 2017 · 5 comments
Assignees
Milestone

Comments

@wldevries
Copy link

Version Used:

Roslyn included in VS 2017 15.3.3

Steps to Reproduce:

Compile the following code:

    class Program
    {
        static void Main(string[] args)
        {
            var history = new Queue<long>();
            Enumerable.Range(0, 5)
                .Select(i =>
                {
                    history.Enqueue(i);
                    return Test(i);

                    bool Test(int v)
                    {
                        history.Dequeue();
                        return Square(v) > 5;
                    }

                    int Square(int w)
                    {
                        return w * w;
                    }
                });
        }
    }

Expected Behavior:

Since this is valid C# syntax the code should compile

Actual Behavior:

csc.exe crashes with exit code -2146232797

@svick
Copy link
Contributor

svick commented Aug 30, 2017

I think this is a duplicate of #19033, which is already fixed in master (but the fix is not in VS 15.3).

And indeed, your code causes the compiler to throw an exception in the released version, but it works fine on master.

@jcouv
Copy link
Member

jcouv commented Aug 31, 2017

@agocke to confirm and close. Thanks

@jcouv jcouv added this to the 15.5 milestone Aug 31, 2017
@JiriZidek
Copy link

Looks like related to or duplicate of #21543

@jnm2
Copy link
Contributor

jnm2 commented Sep 7, 2017

Trying to find my code which is causing -2146232797. So what I'm looking for to get a workaround is something related to local functions and lambdas? I'm positive I'm not putting a local function inside a lambda but the tree of linked issues here seems to cover various issues relating to local functions and lambdas?

Too bad there's no "Find local functions" feature.

@jnm2
Copy link
Contributor

jnm2 commented Sep 7, 2017

Found it! Broken in the current release, fixed in master.

class C
{
    void M(object parameter)
    {
        {
            var necessary = parameter;
            void AlsoNecessary() => LocalFunction();
            void LocalFunction() => _ = parameter;
        }
    }
}

So: my workaround is to move the local functions out of the scope they're in to the very end of the enclosing method. 👍

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

No branches or pull requests

6 participants