From d002cdf451e1c6efbf7cd7f2303264526b6f8a92 Mon Sep 17 00:00:00 2001 From: Laurenz Date: Thu, 12 Aug 2021 16:00:09 +0200 Subject: Named arguments for user defined functions --- tests/typ/code/closure.typ | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'tests/typ/code') diff --git a/tests/typ/code/closure.typ b/tests/typ/code/closure.typ index 1bc369e9..3b8b4261 100644 --- a/tests/typ/code/closure.typ +++ b/tests/typ/code/closure.typ @@ -83,3 +83,17 @@ // Error: 8-13 unexpected argument f(1, "two", () => x) } + +--- +// Named arguments. +{ + let greet(name, birthday: false) = { + if birthday { "Happy Birthday, " } else { "Hey, " } + name + "!" + } + + test(greet("Typst"), "Hey, Typst!") + test(greet("Typst", birthday: true), "Happy Birthday, Typst!") + + // Error: 23-35 unexpected argument + test(greet("Typst", whatever: 10)) +} -- cgit v1.2.3