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

Parsing of expression with cast fails #19

Closed
nborelli opened this issue Apr 29, 2014 · 2 comments
Closed

Parsing of expression with cast fails #19

nborelli opened this issue Apr 29, 2014 · 2 comments
Labels

Comments

@nborelli
Copy link

Dynamic Expresso Version 0.11.0.0

The following expression parses correctly:

(double) 1

However, this expression does not parse correctly:

((double) 1)

This is a problem if we want to cast an object and then access a member of that object.

For example accessing a property that is IDictionary<string, object>:

((DateTime)Values["key"]).Year

Will throw an exception.

Here is the parsing error I get:

DynamicExpresso.ParseException: ')' or operator expected (at index 12).
at DynamicExpresso.ExpressionParser.ValidateToken(TokenId t, String errorMessage)
at DynamicExpresso.ExpressionParser.ParseParenExpression()
at DynamicExpresso.ExpressionParser.ParsePrimaryStart()
at DynamicExpresso.ExpressionParser.ParsePrimary()
at DynamicExpresso.ExpressionParser.ParseUnary()
at DynamicExpresso.ExpressionParser.ParseMultiplicative()
at DynamicExpresso.ExpressionParser.ParseAdditive()
at DynamicExpresso.ExpressionParser.ParseTypeTesting()
at DynamicExpresso.ExpressionParser.ParseComparison()
at DynamicExpresso.ExpressionParser.ParseLogicalAnd()
at DynamicExpresso.ExpressionParser.ParseLogicalOr()
at DynamicExpresso.ExpressionParser.ParseConditional()
at DynamicExpresso.ExpressionParser.ParseExpressionSegment()
at DynamicExpresso.ExpressionParser.ParseExpressionSegment(Type returnType)
at DynamicExpresso.ExpressionParser.Parse()
at DynamicExpresso.Interpreter.ParseExpression(String expressionText, Type

@davideicardi
Copy link
Member

You are right, it is a bug. I have just fixed it in version 0.11.1.

Thank you for submitting this issue.

@nborelli
Copy link
Author

Thanks for the quick response!

samuelcadieux pushed a commit to samuelcadieux/DynamicExpresso that referenced this issue May 4, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants