After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 775789 - Taking the zeroth root of a number freezes GNOME Calculator
Taking the zeroth root of a number freezes GNOME Calculator
Status: RESOLVED FIXED
Product: gnome-calculator
Classification: Core
Component: general
3.22.x
Other Linux
: Normal minor
: ---
Assigned To: PioneerAxon
gcalctool maintainers
Depends on:
Blocks:
 
 
Reported: 2016-12-08 06:57 UTC by Victor Tran
Modified: 2017-02-13 16:48 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Highlight the 0th root token when 0th root is calculated. (5.25 KB, patch)
2017-01-04 15:50 UTC, PioneerAxon
none Details | Review
Highlight 0th root error token when 0th root is calculated. (6.08 KB, patch)
2017-02-13 16:24 UTC, PioneerAxon
committed Details | Review

Description Victor Tran 2016-12-08 06:57:08 UTC
Entering ₀√2 into the calculator results in a freeze. This is probably because GNOME Calculator isn't trapping a division by zero somewhere because ₀√2 = 2^(1/0).

GNOME Calculator really should print out an error like "Division by zero is undefined," or better yet, "The zeroth root of a number is undefined." :)
Comment 1 Robert Roth 2017-01-03 23:27:37 UTC
This problem has been fixed in the unstable development version. The fix will be available in the next major software release. You may need to upgrade your Linux distribution to obtain that newer version.
Comment 2 PioneerAxon 2017-01-04 15:50:51 UTC
Created attachment 342865 [details] [review]
Highlight the 0th root token when 0th root is calculated.

This patch adds code that highlights the part of equation representing 0th root of the calculation.
Comment 3 PioneerAxon 2017-02-13 15:19:39 UTC
Hi Robert,

I know that this bug is closed. But can we get the fix above checked in? It's important to highlight the correct part of the input for an error.

Right now, it highlights "2" in ₀√2 while complaining about "0th root". The patch above fixes this and highlights "₀" instead.

The patch also is a generic improvement over the previous code, as it allows detection of 0th root from parsed Node rather than relying on the error from MPFR wrapper.
Comment 4 Robert Roth 2017-02-13 16:22:05 UTC
Comment on attachment 342865 [details] [review]
Highlight the 0th root token when 0th root is calculated.

Thanks, I'm not sure how I missed the patch. I have tested it, and indeed, it improves the situation.
Highlight should be on the 0 when we are complaining about the zeroth root. Pushing.
Comment 5 PioneerAxon 2017-02-13 16:24:19 UTC
Created attachment 345645 [details] [review]
Highlight 0th root error token when 0th root is calculated.

Highlight 0th root error token when 0th root is calculated.

    This also prevents overwriting errors when perser object has error code
    set. As a side-effect of this, now we return correct error (Unknown
    variable) when a function is invoked with invalid variable as argument.

e.g. f(x) = x + 2
     f(x) will result in "Unknown variable x", instead of generic "Malformed expression" error.
Comment 6 PioneerAxon 2017-02-13 16:26:48 UTC
The new patch is supposed to fix the unit test breakage.
I just noticed that you already pushed the previous patch.

Since it's one line change, it's okay if you just create local fix and push that instead of whole revert-apply-push cycle.
Comment 7 Robert Roth 2017-02-13 16:48:37 UTC
Attachment 345645 [details] pushed as 9cea9c1 - Highlight 0th root error token when 0th root is calculated.