Closed ealeykin closed 2 years ago
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.
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.