mirror of
https://github.com/typst/typst
synced 2025-05-22 13:05:29 +08:00
Check for control flow event before let binding (#1912)
Fixes #1906 (trying to destructure the result of `continue`).
This commit is contained in:
parent
5c6434d4ce
commit
877df549aa
@ -1470,6 +1470,9 @@ impl Eval for ast::LetBinding<'_> {
|
|||||||
Some(expr) => expr.eval(vm)?,
|
Some(expr) => expr.eval(vm)?,
|
||||||
None => Value::None,
|
None => Value::None,
|
||||||
};
|
};
|
||||||
|
if vm.flow.is_some() {
|
||||||
|
return Ok(Value::None);
|
||||||
|
}
|
||||||
|
|
||||||
match self.kind() {
|
match self.kind() {
|
||||||
ast::LetBindingKind::Normal(pattern) => define_pattern(vm, pattern, value),
|
ast::LetBindingKind::Normal(pattern) => define_pattern(vm, pattern, value),
|
||||||
|
Binary file not shown.
Before Width: | Height: | Size: 7.7 KiB After Width: | Height: | Size: 9.5 KiB |
@ -145,3 +145,18 @@
|
|||||||
for _ in range(3) [B]
|
for _ in range(3) [B]
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
---
|
||||||
|
// Ref: true
|
||||||
|
// Test continue while destructuring.
|
||||||
|
// Should output "one = I \ two = II \ one = I".
|
||||||
|
#for num in (1, 2, 3, 1) {
|
||||||
|
let (word, roman) = if num == 1 {
|
||||||
|
("one", "I")
|
||||||
|
} else if num == 2 {
|
||||||
|
("two", "II")
|
||||||
|
} else {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
[#word = #roman \ ]
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user