google / blockly

The web-based visual programming editor.
https://developers.google.com/blockly/
Apache License 2.0
12.47k stars 3.71k forks source link

Some orders in generators incorrect #4353

Open moniika opened 4 years ago

moniika commented 4 years ago

Describe the bug

In the generators for library blocks, some of the ORDER enums used are incorrect.

Context

We specify operator precedence (ORDER) in 2 types of places:

Example of issues

In some cases, the mistake in order has no side effects or only causes extra parenthesis. These mistakes are only a problem for when looking at code for examples. This happens in the following instances:

image

In other cases, the mistake in order causes syntax error in specific edge cases. This can be very tricky to catch because there are a lot of valid combinations.

image

Expected behavior

Library blocks should use the correct order:

Current progress

Generator code reviewed/fixed (for all languages):

Additional context

Historically, there has been a lot of confusion with understanding the correct operator precedence to use when writing generator code. Part of what contributes to this confusion is that the value of the ORDER enums is inversely related to the strength (higher order and stronger precedence is a lower value).

moniika commented 3 years ago

Manually reviewed colour generator code and found no errors in ORDER.