summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--library/src/layout/repeat.rs8
-rw-r--r--tests/typ/layout/repeat.typ5
2 files changed, 13 insertions, 0 deletions
diff --git a/library/src/layout/repeat.rs b/library/src/layout/repeat.rs
index a44bd075..4a05500e 100644
--- a/library/src/layout/repeat.rs
+++ b/library/src/layout/repeat.rs
@@ -9,6 +9,9 @@ use super::AlignElem;
/// Space may be inserted between the instances of the body parameter, so be
/// sure to include negative space if you need the instances to overlap.
///
+/// Errors if there no bounds on the available space, as it would create
+/// infinite content.
+///
/// ## Example
/// ```example
/// Sign on the dotted line:
@@ -48,6 +51,11 @@ impl Layout for RepeatElem {
let apart = remaining / (count - 1.0);
let size = Size::new(regions.size.x, piece.height());
+
+ if !size.is_finite() {
+ bail!(self.span(), "repeat with no size restrictions");
+ }
+
let mut frame = Frame::new(size);
if piece.has_baseline() {
frame.set_baseline(piece.baseline());
diff --git a/tests/typ/layout/repeat.typ b/tests/typ/layout/repeat.typ
index 03642164..5663281e 100644
--- a/tests/typ/layout/repeat.typ
+++ b/tests/typ/layout/repeat.typ
@@ -37,3 +37,8 @@ A#box(width: 1fr, repeat(rect(width: 6em, height: 0.7em)))B
#set text(dir: rtl)
ريجين#box(width: 1fr, repeat(rect(width: 4em, height: 0.7em)))سون
+
+---
+// Error: 2:2-2:13 repeat with no size restrictions
+#set page(width: auto)
+#repeat(".") \ No newline at end of file