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

Exception when define variable Number with character "e" #82

Open
QuangLM75 opened this issue Sep 7, 2023 · 1 comment
Open

Exception when define variable Number with character "e" #82

QuangLM75 opened this issue Sep 7, 2023 · 1 comment
Labels
bug Indicates an unexpected problem or unintended behavior

Comments

@QuangLM75
Copy link

QuangLM75 commented Sep 7, 2023

Having my 'e' variable exception because of same name with exponential operation

void _expression_creation_and_evaluation() { Parser p = Parser(); Expression exp = p.parse('e'); ContextModel cm = ContextModel(); cm.variables = { 'e': Number(5.0), }; double eval = exp.evaluate(EvaluationType.REAL, cm); print('Expression: $exp'); print('Evaluated expression: $eval\n (with context: $cm)'); // = 1 }

The excetion thrown:

Unhandled exception: RangeError (index): Invalid value: Valid value range is empty: -1 #0 List.[] (dart:core-patch/growable_array.dart:264:36) #1 List.removeLast (dart:core-patch/growable_array.dart:336:20) #2 Parser.parse (package:math_expressions/src/parser.dart:78:44) #3 _expression_creation_and_evaluation (package:luklak_id_mobile/ui/pages/authorized/dashboard/gadgets/count_calculate/count.dart:23:22) #4 main (package:luklak_id_mobile/ui/pages/authorized/dashboard/gadgets/count_calculate/count.dart:11:3) #5 _delayEntrypointInvocation.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:297:19) #6 _RawReceivePort._handleMessage (dart:isolate-patch/isolate_patch.dart:192:26)

@fkleon
Copy link
Owner

fkleon commented Oct 27, 2023

Hi @QuangLM75, thanks for your report.

This looks similar to #61 and #35 (including the linked issues there), and mostly stems from limitations of the current parser implementation.

Unfortunately I don't have an easy workaround except creating your expressions programmatically and not using the included parser interface.

@fkleon fkleon added the bug Indicates an unexpected problem or unintended behavior label Oct 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Indicates an unexpected problem or unintended behavior
Projects
None yet
Development

No branches or pull requests

2 participants