From e6de044b1da1e1c801a69149d757bada7154a83b Mon Sep 17 00:00:00 2001 From: Ian Wrzesinski <133046678+wrzian@users.noreply.github.com> Date: Sun, 8 Dec 2024 11:29:49 -0500 Subject: [PATCH] Add test for issue #4573 (#5542) --- tests/suite/scripting/destructuring.typ | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/tests/suite/scripting/destructuring.typ b/tests/suite/scripting/destructuring.typ index 3c0c754c..87bdefa7 100644 --- a/tests/suite/scripting/destructuring.typ +++ b/tests/suite/scripting/destructuring.typ @@ -373,3 +373,23 @@ // Error: 6-12 too many elements to destructure // Hint: 6-12 the provided array has a length of 3, but the pattern expects 2 elements #for (x, y) in ((1,2,3), (4,5,6)) {} + +--- issue-4573-destructuring-unclosed-delimiter --- +// Tests a case where parsing within an incorrectly predicted paren expression +// (the "outer" assignment) would put the parser in an invalid state when +// reloading a stored prediction (the "inner" assignment) and cause a panic when +// generating the unclosed delimiter error. See the comment in the issue for +// more details. +#{ + ( + // Error: 5-7 expected pattern, found keyword `if` + // Hint: 5-7 keyword `if` is not allowed as an identifier; try `if_` instead + // Error: 9 expected comma + // Error: 13-17 unexpected keyword `else` + // Error: 20 expected comma + if x {} else {} + // Error: 5-6 unclosed delimiter + { () = "inner" + ) = "outer" +} +