parser: force {} blocks on new lines
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.
|
glfw dependency will be removed soon.
|
||||||
|
|
||||||
|
<!---
|
||||||
## JavaScript backend
|
## JavaScript backend
|
||||||
|
|
||||||
[examples/hello_v_js.v](examples/hello_v_js.v):
|
[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
|
||||||
Hello from V.js
|
Hello from V.js
|
||||||
```
|
```
|
||||||
|
-->
|
||||||
|
|
||||||
## Troubleshooting:
|
## Troubleshooting:
|
||||||
|
|
||||||
|
|
|
@ -1307,6 +1307,12 @@ fn (p mut Parser) statement(add_semi bool) string {
|
||||||
p.return_st()
|
p.return_st()
|
||||||
}
|
}
|
||||||
.lcbr {// {} block
|
.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)
|
p.check(.lcbr)
|
||||||
if p.tok == .rcbr {
|
if p.tok == .rcbr {
|
||||||
p.error('empty statements block')
|
p.error('empty statements block')
|
||||||
|
|
Loading…
Reference in New Issue