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

BUG: Undefined operator '.' ParseException when letter 'e' is after dot '.' #360

Closed
atomiechen opened this issue Mar 15, 2023 · 2 comments · Fixed by #362
Closed

BUG: Undefined operator '.' ParseException when letter 'e' is after dot '.' #360

atomiechen opened this issue Mar 15, 2023 · 2 comments · Fixed by #362
Assignees
Labels

Comments

@atomiechen
Copy link

atomiechen commented Mar 15, 2023

A weired issue. When I tried the official example (both in document and README link), and changed the field name id to environment_id, I encountered ParseException of Undefined operator '.'.

Environment:

  • macOS Monterey 12.5.1 (21G83)
  • Android Studio Dolphin | 2021.3.1 Patch 1
  • junit test
  • dependency implementation 'com.ezylang:EvalEx:3.0.2'

Code:

public class EvalExTest {
    @Test
    public void test() throws EvaluationException, ParseException {
        Map<String, Object> order = new HashMap<>();
        order.put("environment_id", 12345);
        
        Expression expression = new Expression("order.environment_id")
                .with("order", order);
        
        BigDecimal result = expression.evaluate().getNumberValue();  // ParseException: Undefined operator '.'
        
        System.out.println(result);
    }
}

Result:

Undefined operator '.'
ParseException(super=BaseException(startPosition=6, endPosition=6, tokenString=., message=Undefined operator '.'))
	at app//com.ezylang.evalex.parser.Tokenizer.parseOperator(Tokenizer.java:253)
	at app//com.ezylang.evalex.parser.Tokenizer.getNextToken(Tokenizer.java:165)
	at app//com.ezylang.evalex.parser.Tokenizer.parse(Tokenizer.java:84)
	at app//com.ezylang.evalex.Expression.getAbstractSyntaxTree(Expression.java:235)
	at app//com.ezylang.evalex.Expression.evaluate(Expression.java:85)
...

So far I found that any field name that follows the dot '.' and starts with 'e' will make this error, with a few exceptions:

  • failed examples: order.e, context.e, context.environment_id, var.e, variabl.e, variablew.e, etc.
  • exceptionally passed examples: variable as the structure name will not issue this exception, like variable.e, variable.environment_id, etc.
  • normal passed examples: from order.a to order.z except order.e; from variable.a to variable.z
@atomiechen atomiechen changed the title Bug: Undefined operator '.' ParseException when letter 'e' is after dot '.' BUG: Undefined operator '.' ParseException when letter 'e' is after dot '.' Mar 15, 2023
@uklimaschewski uklimaschewski self-assigned this Mar 19, 2023
@uklimaschewski
Copy link
Collaborator

Thank you very much for the bug report. Version 3.0.3 of EvalEx has been released and fixes this bug.

@atomiechen
Copy link
Author

That is really quick! Thank you!

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

Successfully merging a pull request may close this issue.

2 participants