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

Question: Physical constants with eval? #861

arve0 opened this Issue May 22, 2017 · 2 comments


None yet
2 participants

arve0 commented May 22, 2017

Should one be able to use physical constants with eval?

I'm doing this and it throws:

$ node bin/repl.js 
> math.eval("speedOfLight")
Error: Undefined symbol speedOfLight
    at undef (/Users/arve/git/mathjs/lib/expression/node/SymbolNode.js:111:11)
    at Object.eval (eval at <anonymous> (/Users/arve/git/mathjs/lib/expression/node/Node.js:73:19), <anonymous>:3:443)
    at string (/Users/arve/git/mathjs/lib/expression/function/eval.js:43:36)
    at Object.compile (eval at _typed (/Users/arve/git/mathjs/node_modules/typed-function/typed-function.js:1115:22), <anonymous>:22:14)
    at repl:1:6
    at ContextifyScript.Script.runInThisContext (vm.js:25:33)
    at REPLServer.defaultEval (repl.js:313:29)
    at bound (domain.js:280:14)
    at REPLServer.runBound [as eval] (domain.js:293:12)
    at REPLServer.<anonymous> (repl.js:513:10)

I've also tried:

> math.eval("c = speedOfLight")  // Error: Undefined symbol speedOfLight
> math.eval("c")  // Error: Undefined symbol c

@josdejong josdejong added the bug label May 22, 2017


This comment has been minimized.


josdejong commented May 22, 2017

Thanks for reporting, this is a bug, math.eval('speedOfLight') should just work. This issue has been introduced when securing the expression parser. Shouldn't be too hard to solve.


This comment has been minimized.


josdejong commented May 25, 2017

The issue has been fixed now in develop, awaiting the first next release.

@josdejong josdejong closed this in 64498ed May 26, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment