google / google/codeworld

List comprehension blocks don't preserve the order of vars and guards

Open
#1,148 1 comment 0 reactions 0 assignees View on GitHub
bug funblocks
Dominant language
Haskell
Stars
1.3k
Forks
201
PR merge metrics
No merged PRs in 30d

Description

**Shared Program**:

https://code.world/blocks#PYNCRqCIpHdD-Jh0PQZKMxw
https://code.world/#PLG3J8mHD49-0P8xn8qIiYA

**Description**

In list comprehension blocks, there's an assumption that guards must appear after all variables are declared. As shown in the first shared program, when you add a guard before another local variable declaration, it puts the guard at the end in the code portion. Also, if you open the mutator afterwards, it switches the order of the inputs so the guards are after the variables.

This assumption doesn't work for shadowed variables in list comprehensions which are perfectly valid. An example of this is the second shared program. Note the difference in the left and right picture based on the positioning of the guard

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.