diff --git a/mesonbuild/mparser.py b/mesonbuild/mparser.py index 75985c319..8400a1ac9 100644 --- a/mesonbuild/mparser.py +++ b/mesonbuild/mparser.py @@ -475,12 +475,18 @@ class Parser: def e2(self): left = self.e3() while self.accept('or'): + if isinstance(left, EmptyNode): + raise ParseException('Invalid or clause.', + self.getline(), left.lineno, left.colno) left = OrNode(left, self.e3()) return left def e3(self): left = self.e4() while self.accept('and'): + if isinstance(left, EmptyNode): + raise ParseException('Invalid and clause.', + self.getline(), left.lineno, left.colno) left = AndNode(left, self.e4()) return left @@ -633,6 +639,7 @@ class Parser: def ifblock(self): condition = self.statement() clause = IfClauseNode(condition.lineno, condition.colno) + self.expect('eol') block = self.codeblock() clause.ifs.append(IfNode(clause.lineno, clause.colno, condition, block)) self.elseifblock(clause) diff --git a/test cases/failing/57 or on new line/meson.build b/test cases/failing/57 or on new line/meson.build new file mode 100644 index 000000000..12f27058d --- /dev/null +++ b/test cases/failing/57 or on new line/meson.build @@ -0,0 +1,7 @@ +project('silent_or', 'c') + +if get_option('foo') == 'true' + or get_option('foo') == 'auto' +else + message('If this message is printed then something is wrong. The or above should give a syntax error.') +endif diff --git a/test cases/failing/57 or on new line/meson_options.txt b/test cases/failing/57 or on new line/meson_options.txt new file mode 100644 index 000000000..3302cf4ec --- /dev/null +++ b/test cases/failing/57 or on new line/meson_options.txt @@ -0,0 +1 @@ +option('foo', type: 'combo', choices: ['true', 'false', 'auto'], value: 'auto')