mirror of
https://github.com/vlang/v.git
synced 2023-08-10 21:13:21 +03:00
parser: force {} blocks on new lines
This commit is contained in:
parent
02c29624d8
commit
6982f4a5a2
@ -148,6 +148,7 @@ git clone --depth=1 https://github.com/ubawurinna/freetype-windows-binaries [pat
|
||||
|
||||
glfw dependency will be removed soon.
|
||||
|
||||
<!---
|
||||
## JavaScript backend
|
||||
|
||||
[examples/hello_v_js.v](examples/hello_v_js.v):
|
||||
@ -166,6 +167,7 @@ Hello from V.js
|
||||
Hello from V.js
|
||||
Hello from V.js
|
||||
```
|
||||
-->
|
||||
|
||||
## Troubleshooting:
|
||||
|
||||
|
@ -1307,6 +1307,12 @@ fn (p mut Parser) statement(add_semi bool) string {
|
||||
p.return_st()
|
||||
}
|
||||
.lcbr {// {} block
|
||||
// Do not allow {} block to start on the same line
|
||||
// to avoid e.g. `foo() {` instead of `if foo() {`
|
||||
if p.prev_token().line_nr == p.scanner.line_nr {
|
||||
p.genln('')
|
||||
p.error('{} block has to start on a new line')
|
||||
}
|
||||
p.check(.lcbr)
|
||||
if p.tok == .rcbr {
|
||||
p.error('empty statements block')
|
||||
|
Loading…
Reference in New Issue
Block a user