diff options
| author | Laurenz <laurmaedje@gmail.com> | 2021-07-30 18:04:08 +0200 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2021-07-30 18:49:19 +0200 |
| commit | 1ee1d078e2480ddd08d40915bc7a74a8352acff0 (patch) | |
| tree | 1e7ff367278a19fead3e404cf06d65bfb80a6cd9 /tests/typ/code/closure.typ | |
| parent | 42a27b48df427edf8dbb624c51551a90ecf2e7ea (diff) | |
Fatal errors
- Makes errors fatal, so that a phase is only reached when all previous phases were error-free
- Parsing still recovers and can produce multiple errors
- Evaluation fails fast and can thus produce only a single error (except for parse errors due to an import)
- The single error that could occur during execution is removed for now
- Removes Value::Error variant
Diffstat (limited to 'tests/typ/code/closure.typ')
| -rw-r--r-- | tests/typ/code/closure.typ | 31 |
1 files changed, 21 insertions, 10 deletions
diff --git a/tests/typ/code/closure.typ b/tests/typ/code/closure.typ index 20a5f18d..75241f32 100644 --- a/tests/typ/code/closure.typ +++ b/tests/typ/code/closure.typ @@ -2,13 +2,22 @@ // Ref: false --- +// Don't parse closure directly in template. +// Ref: true +#let x = "\"hi\"" + +// Should output `"hi" => "bye"`. +#x => "bye" + +--- // Basic closure without captures. { let adder = (x, y) => x + y test(adder(2, 3), 5) } +--- // Pass closure as argument and return closure. // Also uses shorthand syntax for a single argument. { @@ -19,6 +28,7 @@ test(h(2), 5) } +--- // Capture environment. { let mark = "?" @@ -35,15 +45,7 @@ test(greet("Typst"), "Hi, Typst!") } -// Don't leak environment. -{ - // Error: 18-19 unknown variable - let func() = x - let x = "hi" - - test(func(), error) -} - +--- // Redefined variable. { let x = 1 @@ -55,6 +57,15 @@ } --- +// Don't leak environment. +{ + // Error: 18-19 unknown variable + let func() = x + let x = "hi" + func() +} + +--- // Too few arguments. { let types(x, y) = "[" + type(x) + ", " + type(y) + "]" @@ -64,11 +75,11 @@ test(types("nope"), "[string, none]") } +--- // Too many arguments. { let f(x) = x + 1 // Error: 10-15 unexpected argument - // Error: 17-24 unexpected argument f(1, "two", () => x) } |
