Re: [Interest] QJSEngine won't evaluate octal literal

2021-08-03 Thread Fabrice Mousset | GEOCEPT GmbH
I don't know why (perhaps the "strict mode" is always active with Qt?), but you 
to use 0o11 to force octal encoding to avoid confusion with binary encoding 
(0b11).

QJSEngine eng;
auto jsv = eng.evaluate("(function(){return 0o11;})()");
qDebug() << jsv.isError() << jsv.toString() << jsv.toVariant();

Regards

Fabrice Mousset

> -Ursprüngliche Nachricht-
> Von: Interest  Im Auftrag von Hamish
> Moffatt via Interest
> Gesendet: Dienstag, 3. August 2021 08:36
> An: Qt Interest 
> Betreff: [Interest] QJSEngine won't evaluate octal literal
> 
> I have the following test code to evaluate an octal literal which I'm running 
> on
> Qt 5.12 and 5.15;
> 
>              QJSEngine eng;
>              auto jsv = eng.evaluate("(function(){return 011;})()");
>              qDebug() << jsv.isError() << jsv.toString() << jsv.toVariant();
> 
> This outputs:
> 
> true "SyntaxError: Expected token `;'" QVariant(QVariantMap, QMap())
> 
> 
> It works if I use hex literals, and the octal code works in node.js. Why 
> doesn't
> it work in QJSEngine?
> 
> 
> Hamish
> 
> ___
> Interest mailing list
> Interest@qt-project.org
> https://lists.qt-project.org/listinfo/interest
___
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest


[Interest] QJSEngine won't evaluate octal literal

2021-08-03 Thread Hamish Moffatt via Interest
I have the following test code to evaluate an octal literal which I'm 
running on Qt 5.12 and 5.15;


            QJSEngine eng;
            auto jsv = eng.evaluate("(function(){return 011;})()");
            qDebug() << jsv.isError() << jsv.toString() << jsv.toVariant();

This outputs:

true "SyntaxError: Expected token `;'" QVariant(QVariantMap, QMap())


It works if I use hex literals, and the octal code works in node.js. Why 
doesn't it work in QJSEngine?



Hamish

___
Interest mailing list
Interest@qt-project.org
https://lists.qt-project.org/listinfo/interest