diff --git a/src/DynamicExpresso.Core/Parsing/Parser.cs b/src/DynamicExpresso.Core/Parsing/Parser.cs index 1ae3e6fe..ce9a04f4 100644 --- a/src/DynamicExpresso.Core/Parsing/Parser.cs +++ b/src/DynamicExpresso.Core/Parsing/Parser.cs @@ -1230,6 +1230,10 @@ private bool TryParseKnownType(string name, out Type type) // we found a known type identifier, check if it has some modifiers private Type ParseTypeModifiers(Type type) { + // type modifiers require the base type to be known + if (type == null) + return null; + var errorPos = _token.pos; if (_token.id == TokenId.Question) { diff --git a/test/DynamicExpresso.UnitTest/GithubIssues.cs b/test/DynamicExpresso.UnitTest/GithubIssues.cs index 0d590542..ab5626a7 100644 --- a/test/DynamicExpresso.UnitTest/GithubIssues.cs +++ b/test/DynamicExpresso.UnitTest/GithubIssues.cs @@ -347,6 +347,26 @@ public void GitHub_Issue_169_quatro() Assert.AreEqual("56", result); } + [Test] + public void GitHub_Issue_197() + { + var interpreterWithLambdas = new Interpreter(InterpreterOptions.DefaultCaseInsensitive | InterpreterOptions.LambdaExpressions); + var interpreterWithoutLambdas = new Interpreter(InterpreterOptions.DefaultCaseInsensitive); + + var stringExpression = "booleanValue ? someStringValue : \".\""; + var parameters = new List + { + new Parameter($"someStringValue", typeof(string), $"E33"), + new Parameter("booleanValue", typeof(bool), true) + }; + + var expressionWithoutLambdas = interpreterWithoutLambdas.Parse(stringExpression, typeof(void), parameters.ToArray()); + Assert.AreEqual("E33", expressionWithoutLambdas.Invoke(parameters.ToArray())); + + var expressionWithLambdas = interpreterWithLambdas.Parse(stringExpression, typeof(void), parameters.ToArray()); + Assert.AreEqual("E33", expressionWithLambdas.Invoke(parameters.ToArray())); + } + [Test] public void GitHub_Issue_185() {