CatchTheTornado / CatchTheTornado/askql
Make while, for and if return values
- Dominant language
- TypeScript
- Stars
- 387
- Forks
- 30
- PR merge metrics
- No merged PRs in 30d
Description
`if` is essentially a `while` loop that is executed once at most, however return values for `if` and `while` are inconsistent.
If returns the value of its last statement as its value:
```
🦄 .editor
// Entering editor mode (^D to finish, ^C to cancel)
if(true) {
let b = 4
}
int ask(if(call(get('true')),block(let('b',4)),block()))
4
```
However while always returns null:
```
🦄 .editor
// Entering editor mode (^D to finish, ^C to cancel)
let b = 2
while(b<4) {
b = b+1
}
empty ask(let('b',2),while(call(get('<'),get('b'),4),block(assign('b',call(get('+'),get('b'),1)))))
null
🦄
```
Contributor guide
Research direction
The issue provides editor examples for if and while and names while, for, and if as the affected constructs. Locate the implementations and existing tests for these control-flow forms, then compare their expression results against the examples. Done means the three constructs have consistent, documented return-value behavior and the relevant tests pass.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- typescript
- Domain
- compilers
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100