]> git.ipfire.org Git - thirdparty/vala.git/commit
parser: Fix statement error recovery
authorSergey Bugaev <bugaevc@gmail.com>
Sat, 24 May 2025 10:22:55 +0000 (13:22 +0300)
committerRico Tzschichholz <ricotz@ubuntu.com>
Wed, 11 Jun 2025 10:27:46 +0000 (12:27 +0200)
commitec79d7049548b1fc667815599f45ab07bef8b47e
tree1e1bbb164e7d2593b223c4b8db981180f7c944d3
parentf2bc96710d1a53ee2c5826e58e74fb103e0d927b
parser: Fix statement error recovery

Parser.rollback () can only be used to move *backward* through tokens,
not forward. When we run into a ParseError while parsing a statement,
'begin' points to the start of the statement, and 'e_begin' to the error
location inside the statement. 'rollback (begin)' is then justified,
since we're rolling back to the start of the statement; but moving to
'e_begin' again can not be done with 'rollback (e_begin)'.

Because we failed to seek forward, an syntax error could send us into an
infinite loop. Use Parser.jump () instead, which moves forward through
tokens.

Regession of f5934184d050d1a19f394fdab6f2ee66ff30965f

Fixes https://gitlab.gnome.org/GNOME/vala/issues/1590
tests/Makefile.am
tests/parser/try-catch-format-string.test [new file with mode: 0644]
vala/valaparser.vala