Closed aelnaiem closed 7 years ago
Does mathjs not return a parse error when it sees nthRoot( )
?
it doesn't :(
I believe it's 'cause it parses it as a FunctionNode and those don't have to have arguments. This only becomes an error when you try to evaluate the FunctionNode and it treats it specifically as a root function
@josdejong thoughts?
also a fix here could be in hasUnsupportedNodes.js
, make sure that nthroot
nodes have exactly 1 or 2 arguments
Thinking about this some more – not returning a parse error makes sense b/c how many arguments nthRoot
requires is a semantic issue. We could do some kind of semantic sanity check on the parse tree. It might also make sense to also check if the argument(s) produces a result within the reals, e.g. nthroot(-1,2)
.
Sounds good! This should all go in hasUnsupportedNodes
I think :)
(and this would make a great first PR ^^)
done! thanks @shirleymiao
We should check that a node exists when using nthRoot otherwise
Cannot read property 'type' of undefined
will result from a nonsense query such asx = nthRoot( )
, rather than identifying that the query doesn't make sense.This might be worth discussing with mathjs as a root of nothing might not be something would want to parse as part of a valid math tree.