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

Lambda Expressions break type detection after refactor in 2.9.5 #197

Closed
bluba opened this issue Dec 6, 2021 · 2 comments · Fixed by #198
Closed

Lambda Expressions break type detection after refactor in 2.9.5 #197

bluba opened this issue Dec 6, 2021 · 2 comments · Fixed by #198
Assignees

Comments

@bluba
Copy link

bluba commented Dec 6, 2021

Hi, it seems like changes introduced after release of 2.9.4 broke type parsing when lambda expressions are enabled.

        var interpreterWithLambdas = new Interpreter(InterpreterOptions.DefaultCaseInsensitive | InterpreterOptions.LambdaExpressions);
        var interpreterWithoutLambdas = new Interpreter(InterpreterOptions.DefaultCaseInsensitive);

        var stringExpression = "booleanValue ? someStringValue : \".\"";
        var parameters = new List<Parameter>();

        parameters.Add(new Parameter($"someStringValue", typeof(string), $"E33"));
        parameters.Add(new Parameter("booleanValue", typeof(bool), true));


        var expressionWithoutLambdas = interpreterWithoutLambdas.Parse(stringExpression, typeof(void), parameters.ToArray());
        Console.WriteLine(expressionWithoutLambdas.Invoke(parameters.ToArray()));


        var expressionWithLambdas = interpreterWithLambdas.Parse(stringExpression, typeof(void), parameters.ToArray());
        Console.WriteLine(expressionWithLambdas.Invoke(parameters.ToArray()));

In version 2.9.4 both interpreters produce correct result of "E33" but on version 2.9.5 and 2.9.6 Object reference not set to an instance of an object. is thrown from
var expressionWithLambdas = interpreterWithLambdas.Parse(stringExpression, typeof(void), parameters.ToArray());

@metoule
Copy link
Contributor

metoule commented Dec 6, 2021

Thanks for reporting! That was a side effect of PR #178, and was an easy fix.

davideicardi pushed a commit that referenced this issue Dec 6, 2021
@bluba
Copy link
Author

bluba commented Dec 7, 2021

Thanks for your work and quick fix.

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