Minification bug: erroneous fusion of operator symbols #1580
Replies: 8 comments
-
Posted at 2021-11-03 by Robin Tue 2021.11.02
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.
Using parenthesis and modifying as follows:
The above executes as expected as does the mod() example, but with no error(s):
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!
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? |
Beta Was this translation helpful? Give feedback.
-
Posted at 2021-11-03 by stephenPspackman It is obviously not a parsing issue, sensu stricto, both because the distinction between |
Beta Was this translation helpful? Give feedback.
-
Posted at 2021-11-03 by Robin
Maybe we are splitting hairs here, but doesn't a parser read the user command and break up into the individual pieces without spaces that are processed in order to determine the command syntax for execution? As I understand the process of minification reduces each part to it's simplest representation, the examples in post #1 are already minified as best they can be aren't they? Should one remove that whitespace, syntax errors occur and the editor points this out with a red 'Bad assignment' error. When uploaded:
and this syntax without the space is parsed and executes just fine:
In any event, as I don't receive the errors that are indicated in post #1 using the emulator, I'm wondering what the differences are in browser and PC environment by comparison. As an end user like yourself, I've just gotten running and are working through the Advanced Debug documentation and this would be a good sample to use to locate the problematic area. Am willing to put in the time to learn, but haven't grasped how to set up the environment to get started, even after following the 'Gotchas' section. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2021-11-03 by stephenPspackman Terminology: a lexer is responsible for tokenisation of the input—breaking it into words, if you will, like |
Beta Was this translation helpful? Give feedback.
-
Posted at 2021-11-03 by @gfwilliams Sorry @user135362 please don't waste any time answering @robin. For some reason he repeatedly ignores my requests not to post when he has nothing useful to add. @robin I've mentioned this in personal messages, but let's just say it publically: I've never banned anyone from this forum, but I'm fed up reading your toxic, smart-arse comments every day and I've lost track of how many people you've offended or put off. I've repeatedly warned you via PMs and email and I just get ignored. If I feel I ever have to warn you again, you're getting banned. Right. @user135362 - thank you! So as far as I can tell this comes not from the minification in the IDE, but from Espruino's internal minification that it applies when
I've filed an issue for it here: espruino/Espruino#2086 I guess one question is how I actually fix this. I can explicitly keep a space between |
Beta Was this translation helpful? Give feedback.
-
Posted at 2021-11-03 by stephenPspackman @gfwilliams—Oh! Mea culpa. I thought I had ruled out internal minification, but I had neglected to defer execution in my experiments, which rather invalidates them :-}. Sorry! Here are the ones I can think of: Misinterpreting valid and useful code: Wildly misinterpreting technically valid but extremely unlikely code: Incorrectly allowing syntactically invalid code in an especially confusing way: The obscure example I can't think of any other examples because alphanumeric tokens already preserve whitespace and JS has few cases where an operator symbol is at the left edge of an expression. Maybe HTH. |
Beta Was this translation helpful? Give feedback.
-
Posted at 2021-11-04 by @gfwilliams Great - thanks! Wow, I hadn't even considered the regex. I'll get something in for that. I can come up with But yes, '++'/etc are pretokenised. Basically, anything that's more than 1 character but doesn't have a value (eg not string/id/number/etc) is turned into a token. Do you have an example of the error message? Errors should reconstruct everything from the tokens |
Beta Was this translation helpful? Give feedback.
-
Posted at 2021-11-04 by stephenPspackman Here's a example:
My code is indeed incorrect for the reason given, but the source snippet (if reparsed) is about |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Posted at 2021-11-02 by stephenPspackman
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.)
Beta Was this translation helpful? Give feedback.
All reactions