diff options
| author | Martin Haug <mhaug@live.de> | 2022-01-02 14:46:08 +0100 |
|---|---|---|
| committer | Martin Haug <mhaug@live.de> | 2022-01-02 14:46:08 +0100 |
| commit | 98c96ba1cb8a46e327de313118e4ce1a84795ae9 (patch) | |
| tree | b27b8e5c8e0cc6ed530c67eeeca5019fa0e18986 /src/parse/parser.rs | |
| parent | 5f114e18eb76a1937941b2ea64842b908c9ad89e (diff) | |
Fix parser / space / error bug
Diffstat (limited to 'src/parse/parser.rs')
| -rw-r--r-- | src/parse/parser.rs | 16 |
1 files changed, 2 insertions, 14 deletions
diff --git a/src/parse/parser.rs b/src/parse/parser.rs index b31f69d3..f36155d5 100644 --- a/src/parse/parser.rs +++ b/src/parse/parser.rs @@ -282,12 +282,6 @@ impl<'s> Parser<'s> { self.eat(); rescan = false; } else if required { - // FIXME The error has to be inserted before any space rolls - // around because the rescan will set the cursor back in front - // of the space and reconsume it. Supressing the rescan is not - // an option since additional rescans (e.g. for statements) can - // be triggered directly afterwards, without processing any - // other token. self.push_error(format_eco!("expected {}", end)); self.last_unterminated = Some(self.prev_end()); } @@ -380,14 +374,8 @@ impl Parser<'_> { /// Push an error into the children list. pub fn push_error(&mut self, msg: impl Into<EcoString>) { let error = NodeKind::Error(ErrorPos::Full, msg.into()); - for i in (0 .. self.children.len()).rev() { - if Self::is_trivia_ext(self.children[i].kind(), false) { - self.children.remove(i); - } else { - break; - } - } - self.children.push(GreenData::new(error, 0).into()); + let idx = self.trivia_start(); + self.children.insert(idx.0, GreenData::new(error, 0).into()); } /// Eat the current token and add an error that it is unexpected. |
