From 59957746e91c1322a8ca6d228bcaa0f31941ee1b Mon Sep 17 00:00:00 2001 From: Marmare314 <49279081+Marmare314@users.noreply.github.com> Date: Wed, 26 Apr 2023 11:32:11 +0200 Subject: Pattern as parameter (#854) --- tests/typ/compiler/closure.typ | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'tests') diff --git a/tests/typ/compiler/closure.typ b/tests/typ/compiler/closure.typ index 2d12a2bc..0f6809b5 100644 --- a/tests/typ/compiler/closure.typ +++ b/tests/typ/compiler/closure.typ @@ -145,6 +145,29 @@ test(greet("Typst", whatever: 10)) } +--- +// Parameter unpacking. +#let f((a, b), ..c) = (a, b, c) +#test(f((1, 2), 3, 4), (1, 2, (3, 4))) + +#let f((k: a, b), c: 3, (d,)) = (a, b, c, d) +#test(f((k: 1, b: 2), (4,)), (1, 2, 3, 4)) + +// Error: 22-23 duplicate parameter: a +#let f((a: b), (c,), a) = none + +// Error: 8-14 expected identifier, found array +#let f((a, b): 0) = none + +// Error: 10-19 expected identifier, found destructuring pattern +#let f(..(a, b: c)) = none + +// Error: 10-16 expected identifier, found array +#let f(..(a, b)) = none + +// Error: 10-19 expected identifier, found destructuring pattern +#let f(..(a, b: c)) = none + --- // Error: 11-12 duplicate parameter: x #let f(x, x) = none -- cgit v1.2.3