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
Weird issue in Ubuntu QML apps #15
Comments
No, but I will look into it. |
Thanks! What I did was
|
The easiest way to reproduce this bug on Ubuntu:
|
Thanks. I'll have a look later this week. |
I found the cause of this issue, it's in the Decimal constructor: https://github.com/MikeMcl/decimal.js/blob/master/decimal.js#L3598-L3600 // This goes wrong in the QML app
for ( b -= LOGBASE; i < b; ) {
x['c'].push( +n.slice( i, i += LOGBASE ) );
}
// This works fine in the QML app
for ( b -= LOGBASE; i < b; ) {
var next = i + LOGBASE;
x['c'].push( +n.slice( i, next ) );
i = next;
} So it looks like the the JS engine of QML builds up the arguments for the slice function call after evaluating |
So to sumarize the issue: var i = 2;
console.log(i, i += 2);
// output in Chrome, Firefox: 2, 4
// output in QML app: 4, 4 (WRONG?) @Gang65 do you know where we should report this issue? |
I've created a bug report here: https://bugreports.qt.io/browse/QTCREATORBUG-14367 |
There is some nice discussion on Google+, about that issue: According to that discussion, it is not a bug in ECMAscript engine. |
Ah, so this behavior is not standardized. That's interesting... |
That discussion is interesting - thanks for the link - but I don't want to start making changes based upon that alone. And one of the later posts links to stackoverflow, which gives a more convincing assertion that the order of evaluation of function arguments is left to right - as is true of every other JS engine I have come across. I think it will be accepted as a bug, and fixed in due course. Anyway, I will do some research myself... |
Good find @MikeMcl , so it turns out it is defined in the specs... |
Its amusing to see the code proposals that have been added at that Google+ link, but I think I'll be leaving it as it is for now. I will be reviewing/tidying up the code at some point soon anyway - among other things, I want to get rid of the square bracket notation for object properties. I also added an answer on stackoverflow which clearly shows that the left to right evaluation order has been in JavaScript from the beginning. |
MikeMcl/decimal.js#15. Fixes: https://bugs.launchpad.net/bugs/1450172. Approved by Ubuntu Phone Apps Jenkins Bot, Riccardo Padovani.
A user of math.js reported some weird behavior when using big numbers (powered by decimal.js). When using decimal.js in an Ubuntu HTML5 app (QML), for some inputs there are digits lost. Here is some example output:
I'm not familiar with QML myself, but installed the SDK and verified this behavior. I'm not sure what JavaScript engine is used but I thought it was Chromium. When loading decimal.js into the QML app, I got a warning that decimal.js could not be loaded as UTF8, but I don't think that is related. I also verified that the problem is in constructing a Decimal, it's not in the
toString
method (I just looked at the digits in the.c
array).Do you have any clue what could cause this issue?
The text was updated successfully, but these errors were encountered: