aboutsummaryrefslogtreecommitdiff
path: root/parse.c
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2024-07-04 18:45:04 -0400
committerBruce Hill <bruce@bruce-hill.com>2024-07-04 18:45:04 -0400
commit4d3ea3f73e5f040c1de020d0075a87c006c2ad67 (patch)
tree5ff8815de9360cd91cb0b59d0ceadcba9e98303e /parse.c
parentf4dee58f03774d033c55d890356cd93c3e2462fb (diff)
Check for newline between statements in blocks
Diffstat (limited to 'parse.c')
-rw-r--r--parse.c11
1 files changed, 10 insertions, 1 deletions
diff --git a/parse.c b/parse.c
index 6f3de7d9..13c37862 100644
--- a/parse.c
+++ b/parse.c
@@ -1619,7 +1619,16 @@ PARSER(parse_block) {
break;
}
statements = new(ast_list_t, .ast=stmt, .next=statements);
- whitespace(&pos); // TODO: check for newline
+ whitespace(&pos);
+
+ // Guard against having two valid statements on the same line, separated by spaces (but no newlines):
+ if (!memchr(stmt->end, '\n', (size_t)(pos - stmt->end))) {
+ if (*pos)
+ parser_err(ctx, pos, strchrnul(pos, '\n'), "I don't know how to parse the rest of this line");
+ pos = stmt->end;
+ break;
+ }
+
if (get_indent(ctx, pos) != block_indent) {
pos = stmt->end; // backtrack
break;