diff --git a/README.md b/README.md index 7f126bccec..e57c215fad 100644 --- a/README.md +++ b/README.md @@ -148,6 +148,7 @@ git clone --depth=1 https://github.com/ubawurinna/freetype-windows-binaries [pat glfw dependency will be removed soon. + ## Troubleshooting: diff --git a/vlib/compiler/parser.v b/vlib/compiler/parser.v index 8b51196c83..4c299e635d 100644 --- a/vlib/compiler/parser.v +++ b/vlib/compiler/parser.v @@ -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')