mirror of
https://github.com/typst/typst
synced 2025-05-13 20:46:23 +08:00
Make range-end exclusive
This commit is contained in:
parent
eaa3cbaa9c
commit
ccb4be4da4
@ -247,7 +247,7 @@ comparison!(geq, ">=", Ordering::Greater | Ordering::Equal);
|
||||
/// Compute the range from `lhs` to `rhs`.
|
||||
pub fn range(lhs: Value, rhs: Value) -> StrResult<Value> {
|
||||
match (lhs, rhs) {
|
||||
(Int(a), Int(b)) => Ok(Array((a ..= b).map(Int).collect())),
|
||||
(Int(a), Int(b)) => Ok(Array((a .. b).map(Int).collect())),
|
||||
(a, b) => mismatch!("cannot apply '..' to {} and {}", a, b),
|
||||
}
|
||||
}
|
||||
|
@ -278,7 +278,7 @@ pub enum BinOp {
|
||||
MulAssign,
|
||||
/// The divide-assign operator: `/=`.
|
||||
DivAssign,
|
||||
/// The inclusive range operator: `..`.
|
||||
/// The range operator: `..`.
|
||||
Range,
|
||||
}
|
||||
|
||||
|
@ -53,7 +53,7 @@
|
||||
---
|
||||
{
|
||||
let x = 2
|
||||
for _ in 0..60 {
|
||||
for _ in 0..61 {
|
||||
x *= 2
|
||||
}
|
||||
// Error: 4-18 cannot repeat this string 4611686018427387904 times
|
||||
|
@ -163,12 +163,12 @@
|
||||
// Test range operator.
|
||||
|
||||
#let array = (1, 2, 3)
|
||||
#test(1..3, array)
|
||||
#test(1.. 3, array)
|
||||
#test(1 ..3, array)
|
||||
#test(1 .. 3, array)
|
||||
#test(1..4, array)
|
||||
#test(1.. 4, array)
|
||||
#test(1 ..4, array)
|
||||
#test(1 .. 4, array)
|
||||
|
||||
#test(-4..2, (-4, -3, -2, -1, 0, 1, 2))
|
||||
#test(-4..2, (-4, -3, -2, -1, 0, 1))
|
||||
#test(10..5, ())
|
||||
|
||||
---
|
||||
|
Loading…
x
Reference in New Issue
Block a user