From a11672697c45280587cc0afc2dc8c549f4dee371 Mon Sep 17 00:00:00 2001 From: recynie <99177772+recynie@users.noreply.github.com> Date: Sun, 17 May 2026 18:56:31 +0800 Subject: [PATCH] fix: clamp section index to 0 in add-points to prevent out-of-bounds error When #question is used before any #section is defined, section-counter is 0, causing section index to become -1 and triggering an array index out of bounds error. Use calc.max(..., 0) to guard against this. Fixes #1 --- lib/utils.typ | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/utils.typ b/lib/utils.typ index a993a66..5b8092d 100644 --- a/lib/utils.typ +++ b/lib/utils.typ @@ -2,7 +2,7 @@ #let section-points = state("sectionpoints", ()) #let add-points = p => { - let section = section-counter.get().at(0) - 1 + let section = calc.max(section-counter.get().at(0) - 1, 0) section-points.update(it => { for i in range(it.len(), section + 1) {