if-statement optional braces when single statement
This commit is contained in:
@@ -242,8 +242,16 @@
|
||||
c :: b + 3 # c is constrained to `i32`
|
||||
```
|
||||
|
||||
16. for if statements, allow `if (cond) one-line statement` or `if some_func(some_arg) one-line statement` (instead of forcing either `if (cond) { block }` or `if cond { block }`)
|
||||
16. for if statements, allow `if (cond) one-line statement` or `if some_func(some_arg) one-line statement` (instead of forcing either `if (cond) { block }` or `if cond { block }`) (implemented)
|
||||
- if statements without a bracketed body must wrap the condition in parentheses UNLESS it's a function call
|
||||
- brace-less single-statement bodies apply to the then-body, the `else`-body, and the
|
||||
unwrap/guard forms (`if v |x| stmt`); each branch is independent, so braced and
|
||||
brace-less branches mix freely
|
||||
- the parenthesize-or-call rule constrains only the then-branch condition; `else` and the
|
||||
unwrap `|...|` already delimit, so they need no parentheses
|
||||
- the brace-less statement may sit on the line after the condition
|
||||
- parser-only change (`parse_branch_body` in `compiler/parser/parser.odin`): a brace-less
|
||||
body is just a 1-element statement slice, so the checker and codegen are unchanged
|
||||
|
||||
17. add slice-by-range
|
||||
- allow the use of a range in slice expressions:
|
||||
|
||||
Reference in New Issue
Block a user