rubysolo/dentaku

What is the state of SQRT function?

Epigene opened this issue · 4 comments

I'm upgrading the version of Dentaku we're using and I noticed that SQRT function works since 2.0.6 till 3.4.(2) unchanged, but then at one point it no longer raises argument error if called without any argument.

Two questions:

  1. Why is the function undocumented in README?
  2. Why the change in the behavior (I'd recommend returning the argument check for less gotchas)

Hi, thanks for reporting this. Can you paste a code snippet that shows how you are calling the function? The sqrt function is delegated to the ruby Math module, so we don't explicitly call out all of those functions in the README (but maybe we should).

If I had to guess, you probably need to use evaluate! instead of evaluate so that Dentaku errors are not swallowed. (Like in the 6th code block in the Example section of the readme)

We're calling Dentaku::Calculator.new.solve(a: "sqrt()")

Do you mean that it no longer raises any exception, or that it raises a different exception? It should raise a Dentaku::ParseError (since ~ v3.4.0) instead of a Ruby ArgumentError.

Closing this for now, please reopen if there's still an issue.