Add test for issue #4573 (#5542)

This commit is contained in:
Ian Wrzesinski 2024-12-08 11:29:49 -05:00 committed by GitHub
parent fbcd624eeb
commit e6de044b1d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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"
}