Skip to content
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

Some orders in generators incorrect #4353

Open
2 of 9 tasks
moniika opened this issue Oct 6, 2020 · 1 comment
Open
2 of 9 tasks

Some orders in generators incorrect #4353

moniika opened this issue Oct 6, 2020 · 1 comment
Labels
component: generators help wanted External contributions actively solicited issue: bug Describes why the code or behaviour is wrong

Comments

@moniika
Copy link
Contributor

moniika commented Oct 6, 2020

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:

  • When calling valueToCode to get the value of an input (strongest operator that could split the returned code)
  • When returning generated code for a value block (weakest operator that the final block of code could split at)

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:

  • if using an order for an operator stronger than the actual one for max strength (passed to valueToCode)
  • if returning an order for an operator weaker than the actual one for min strength (for generator return)
  • Certain swaps of orders don't cause issues because of how close they are in order (ex: commonly mixed up ORDER_MEMBER and ORDER_FUNCTION_CALL don't cause any side effects)

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:

  • There should be no syntax errors in code generated from Blockly blocks.
  • In the case where the mistakes don't cause syntax errors, mistakes in order are detrimental to others' understanding of generators and make the code unsuitable as example code.

Current progress

Generator code reviewed/fixed (for all languages):

  • colour
  • list
  • logic
  • loops
  • math
  • procedures
  • text
  • variables
  • variables_dynamic

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 moniika added issue: bug Describes why the code or behaviour is wrong component: generators issue: triage Issues awaiting triage by a Blockly team member labels Oct 6, 2020
@moniika moniika removed the issue: triage Issues awaiting triage by a Blockly team member label Oct 6, 2020
@moniika moniika self-assigned this Oct 6, 2020
@moniika moniika added this to the Bug Bash Backlog milestone Oct 6, 2020
@rachel-fenichel rachel-fenichel added the help wanted External contributions actively solicited label Dec 3, 2020
@moniika
Copy link
Contributor Author

moniika commented Dec 10, 2020

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: generators help wanted External contributions actively solicited issue: bug Describes why the code or behaviour is wrong
Projects
None yet
Development

No branches or pull requests

2 participants