Bug 420671 - KmPlot recognizes no syntax error, but draws another function, when the expression ends with a binary operator
Summary: KmPlot recognizes no syntax error, but draws another function, when the expre...
Status: CONFIRMED
Alias: None
Product: kmplot
Classification: Applications
Component: general (other bugs)
Version First Reported In: 1.3.0
Platform: Other Linux
: NOR normal
Target Milestone: ---
Assignee: Christoph Feck
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2020-04-27 15:34 UTC by Laura David Hurka
Modified: 2020-05-05 07:10 UTC (History)
1 user (show)

See Also:
Latest Commit:
Version Fixed/Implemented In:
Sentry Crash Report:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Laura David Hurka 2020-04-27 15:34:18 UTC
SUMMARY
When you draw a cartesian plot with a function which ends with a binary operator, KmPlot recognizes no syntax error, but draws a different function instead. Example: “f(x) = x” works fine, but “g(x) = x +” draws another function. See screenshot. https://imgur.com/jQmhl26.png

STEPS TO REPRODUCE
1. Enter “f(x) = x” and “g(x) = x +”

OBSERVED RESULT
Two different graphs. Every time you try this, you get another second graph; appears to be random.

EXPECTED RESULT
One graph and one syntax error

SOFTWARE/OS VERSIONS
Linux/KDE Plasma: Xfce desktop, don’t know how to look up version, sorry.
KDE Frameworks Version: 5.68
Qt Version: 5.14.1

ADDITIONAL INFORMATION
I consider this as a bug. + as unary operator has no common meaning known to me, and in the KmPlot function reference it is defined as binary operator. If there is a purpose, I am curious which.

This appears to affect all binary operators, not just +.
Comment 1 Christoph Feck 2020-04-27 15:48:08 UTC
There is no purpose, it is a bug.

"x+" is evaluated as "x+pi".
Comment 2 Laura David Hurka 2020-04-27 20:55:11 UTC
So we need to fix it! :) Where can I go to fix it? (When I have my development system back, which will take some weeks. :( )
Comment 3 Laura David Hurka 2020-04-28 18:23:04 UTC
I did some more tests, and can say that x+ is usually not x+pi.

It appears that binary operators at the end just affect the last evaluated expression, ignoring any precedence.

Examples:
x+ is x+a, where a appears to be the last evaluated expression of the previous function, or pi for the first function.
x²+ and (x²) are x²+2
(x³)+ is x³+3
e²+ is e²+2
x³/ is x³/3
0²+ is 2
etc.
Comment 4 Yuri Chornoivan 2020-05-04 11:59:12 UTC
That's not Mathematica that can translate any possible gibberish, imho. Anyway, should be relatively easy to fix in parser.cpp.
Comment 5 Yuri Chornoivan 2020-05-05 07:10:17 UTC
For the future triagers, the reporter wants a complete parser, not a workaround in fixExpression (parser.cpp) function:

https://phabricator.kde.org/D29418