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

Operation tree contains no nodes for local functions #19902

Closed
mavasani opened this issue May 31, 2017 · 10 comments
Closed

Operation tree contains no nodes for local functions #19902

mavasani opened this issue May 31, 2017 · 10 comments
Assignees
Milestone

Comments

@mavasani
Copy link
Contributor

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp2
{
    class Program
    {
        static IEnumerable<T> F<T>(IEnumerable<T> source, Func<T, bool> predicate)
        {
            IEnumerable<T> Iterator()
            {
                foreach (var element in source)
                    if (predicate(element))
                        yield return element;
            }

            return Iterator();
        }
    }
}

Operation tree for BoundLocalFunctionStatement has no child nodes.

We seemed to have added an OperationKind.LocalFunctionStatement, but added no IOperation interface for it, causing us to miss this bug when we added IOperationWithChildren.

@mavasani mavasani added this to the 15.3 milestone May 31, 2017
@mavasani mavasani self-assigned this May 31, 2017
@mavasani
Copy link
Contributor Author

Tagging @dotnet/analyzer-ioperation - I believe we should fix this for 15.3

@mavasani
Copy link
Contributor Author

To be clear on the example above, remove unused parameters analyzer will report both source and predicate as unused parameters.

@333fred
Copy link
Member

333fred commented May 31, 2017

@jinujoseph, should we bring this to the meeting today?

@jinujoseph
Copy link
Contributor

This is just a bug which needs to be fixed,and manish already knows what needs to be done here. @mavasani do you have any concern from design perspective ?

@mavasani
Copy link
Contributor Author

I presume Fred meant discuss the new IOperation API that must be introduced in 15.later, correct? I will work on the workaround for 15.3 meanwhile.

@jinujoseph
Copy link
Contributor

Ah sure , can you put the proposed API shape for discussion today

@333fred
Copy link
Member

333fred commented May 31, 2017

I was assuming that you had an API shape. If not, it doesn't matter for now.

@mavasani
Copy link
Contributor Author

I am assuming we want to expose the body and the local function symbol, so the API should be pretty trivial:

    public interface ILocalFunctionStatement : IOperation
    {
        IBlockStatement Body { get; }

        IMethodSymbol LocalFunctionSymbol { get; }
    }

@mavasani
Copy link
Contributor Author

We probably want to share a common sub-type with ILambdaExpression though: http://source.roslyn.io/#Microsoft.CodeAnalysis/Operations/ILambdaExpression.cs,14

@mavasani
Copy link
Contributor Author

Fixed with #20177

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

3 participants