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
parser/switch-section-missing-colon.test \
parser/switch-section-outside-switch.test \
parser/template.vala \
+ parser/try-catch-format-string.test \
parser/try-catch-in-switch-case-invalid.test \
parser/tuple.vala \
parser/unsupported-property-async.test \
--- /dev/null
+Invalid Code
+
+void main () {
+ try {
+ this.connection = new Gda.Connection.from_string ("", @"DB_DIR=$db_path;DB_NAME=revala", null, Gda.ConnectionOptions.NONE);
+ } catch (GLib.Error as error) {
+ stdout.printf("Error creating the connection to the database");
+ throw error;
+ }
+}
string token = ((EnumClass) typeof (TokenType).class_ref ()).get_value (type).value_nick;
rollback (begin);
if (!is_expression ()) {
- rollback (e_begin);
+ jump (e_begin);
throw e;
}
try {
Report.warning (get_src (begin), "`%s' is a syntax keyword, replace with `@%s'", token, token);
} catch (ParseError e2) {
var e2_begin = get_location ();
- rollback (e_begin);
+ jump (e_begin);
next ();
Report.error (get_src (e_begin), "Possible `%s-statement' syntax error, %s", token, e.message);
- rollback (e2_begin);
+ rollback (begin);
+ jump (e2_begin);
throw e2;
}
}