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

Parse unknown identifiers for lambda expressions #226

Closed
ealeykin opened this issue Feb 3, 2022 · 1 comment · Fixed by #227
Closed

Parse unknown identifiers for lambda expressions #226

ealeykin opened this issue Feb 3, 2022 · 1 comment · Fixed by #227

Comments

@ealeykin
Copy link
Contributor

ealeykin commented Feb 3, 2022

This is a very helpful feature, but when used against expressions with lambdas e.g. list.Any(x => x == null) - x here is an unknown identifier.

So I'm note sure whether this is an expected behaviour, because from expression inputs perspective - yes it's unknown, however it won't raise any compilation errors (since I enabled lambdas) and it's more likely a runtime variable rather than an unknown input identifier.

@metoule
Copy link
Contributor

metoule commented Feb 3, 2022

Repro example:

var target = new Interpreter(InterpreterOptions.Default | InterpreterOptions.LambdaExpressions);
target.SetVariable("list", new List<string>());
target.DetectIdentifiers("list.Any(x => x == null)").Dump();

Results:

{
  "UnknownIdentifiers": [
    "x"
  ],
  "Identifiers": [
    {
      "Name": "list",
      "Expression": {
        "Type": "List<string>",
        "NodeType": "Constant",
        "Value": [],
        "CanReduce": false
      }
    },
    {
      "Name": "null",
      "Expression": {
        "Type": "object",
        "NodeType": "Constant",
        "CanReduce": false
      }
    }
  ],
  "Types": []
}

x is detected as an unknown identifier.

@halamah that's an oversight on my part, I didn't think of that when I implemented the lambda expression support.

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

Successfully merging a pull request may close this issue.

2 participants