-
Tue 2021.11.02
Title: 'Minification bug: erroneous fusion of operator symbols'
I feel this is more of a parsing issue, rather than a minification issue.
Now I find this very interesting. I first tried using a trusted flashed device 2V08.220 and the native app.
On the right hand editor side, in the left hand margin a yellow warning 'Confusing minuses'
When I upload, and execute function x(), I concur with the same error message.
Uncaught Error: Unable to assign value to non-reference Number at line 1 col 8 print(1--1)
Using parenthesis and modifying as follows:
x = () => print(1 - (-1));
The above executes as expected as does the mod() example, but with no error(s):
>x = () => print(1 - (-1)); =function (undefined) { ... } >x() 2 =undefined >x => mod(x- -x, 1) =function (x) { ... } >x() 2 =undefined
When I run the tests using the online IDE indicating the same version and using either emulator, although the original line of code does also display the orange 'Confusing minuses' warning, those upload without errors also!
2v10.187 (c) 2021 G.Williams Found EMSCRIPTEN2, 2v10.187 Connected to Emulator >dump() =undefined >x = () => print(1 - -1); =function (undefined) { ... } >x() 2 =undefined >y = () => print(2 + -1); =function (undefined) { ... } >y() 1 =undefined >z = () => print(2 - -1); =function (undefined) { ... } >z() 3 =undefined >
Wouldn't you agree that adding the parenthesis indicates a parsing issue?No clue why errors don't show in my environment when using the online WebIDE:
Browser Chrome Version 94.0.4606.81 (Official Build) (64-bit) on Windows10 v20H2 19042.1288
Maybe a few more community members can give this a whirl and report in perhaps?
Bangle emulator 2v10.187.
Minimal reproduction:
Upload into the Bangle.js emulator from the editor panel as full file (not snippet), run
x()
:The underlying cause has to do with the accidental fusion of the two
-
tokens. This case:reports a parse error rather than a semantic error.
+
is similarly affected.As ever, it should be stressed that this is a minimal reproduction and the error also occurs with real, useful code. (Why would I ever explicitly subtract a negative number? Because the numbers I'm using come from tables of data plugged into a regular formula.)