math-expressions icon indicating copy to clipboard operation
math-expressions copied to clipboard

Variable name with a combination of characters and numbers causes an error

Open misskter opened this issue 4 years ago • 4 comments

Thank you for providing this plug-in, but when I set the variable to a combination of letters and numbers, I get an error. Is this a plug-in problem?

My code looks like this:

void test() {
  Parser p = Parser();
  Expression exp = p.parse('\$s2*5');
  ContextModel cm = ContextModel();
  Variable x = Variable('\$s2');
  cm.bindVariable(x, Number(0.5));
  var evaluate = exp.evaluate(EvaluationType.REAL, cm);
  print(evaluate.toString());
}

The plug-in version currently in use is: 2.0.1

E/flutter (10407): [ERROR:flutter/lib/ui/ui_dart_state.cc(177)] Unhandled Exception: FormatException: The input String is not a correct expression
E/flutter (10407): #0      Parser.parse (package:math_expressions/src/parser.dart:130:7)
E/flutter (10407): #1      test (package:test_demo/test_function3.dart:21:22)
E/flutter (10407): #2      main (package:test_demo/test_function3.dart:12:3)
E/flutter (10407): #3      _runMainZoned.<anonymous closure>.<anonymous closure> (dart:ui/hooks.dart:231:25)
E/flutter (10407): #4      _rootRun (dart:async/zone.dart:1190:13)
E/flutter (10407): #5      _CustomZone.run (dart:async/zone.dart:1093:19)
E/flutter (10407): #6      _runZoned (dart:async/zone.dart:1630:10)
E/flutter (10407): #7      runZonedGuarded (dart:async/zone.dart:1618:12)
E/flutter (10407): #8      _runMainZoned.<anonymous closure> (dart:ui/hooks.dart:223:5)
E/flutter (10407): #9      _startIsolate.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:301:19)
E/flutter (10407): #10     _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:168:12)
E/flutter (10407): 

misskter avatar Oct 26 '20 08:10 misskter

Thanks for the report!

This is similar to the second issue reported in #31. Variable naming is pretty restrictive at the moment, and the resulting parser errors not great.

fkleon avatar Oct 27 '20 00:10 fkleon

@fkleon any news on this?

I am currently having problems with variables that contain any number, like a1, a2 etc.

WieFel avatar Jan 12 '22 15:01 WieFel

@WieFel There are no updates yet, I'm currently not working on this issue. It could be picked up by somebody else though.

fkleon avatar Jan 17 '22 06:01 fkleon

Any news on this?

WieFel avatar Sep 21 '22 08:09 WieFel