diff options
| author | Laurenz <laurmaedje@gmail.com> | 2023-09-16 20:38:27 +0200 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2023-09-16 20:41:44 +0200 |
| commit | 25613cfaf3a20f737ac347f7d7144a5dcaa709a5 (patch) | |
| tree | 150578e74ece5172133b990e9b900b8fedfecee7 /tests | |
| parent | b7430f6da01550d8388d6a3bcccf0ef0aca9130c (diff) | |
Fix missing capturing of assignments
The previous commit was a bit overambitious. The left-hand side of assignments should actually be fully captured: Argument lists in `at` calls can contain captured variables. And if the assigned variable itself is captured, then the function is faulty anyway. (And we ensure the correct error message by capturing it.)
Fixes #2169
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/typ/compiler/closure.typ | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/tests/typ/compiler/closure.typ b/tests/typ/compiler/closure.typ index 92d01446..85e9dbe2 100644 --- a/tests/typ/compiler/closure.typ +++ b/tests/typ/compiler/closure.typ @@ -132,6 +132,24 @@ } --- +// Mutable method with capture in argument. +#let x = "b" +#let f() = { + let a = (b: 5) + a.at(x) = 10 + a +} +#f() + +--- +#let x = () +#let f() = { + // Error: 3-4 variables from outside the function are read-only and cannot be modified + x.at(1) = 2 +} +#f() + +--- // Named arguments. #{ let greet(name, birthday: false) = { |
