From 3153469a2cddd2134fa7fcb4662485d1f7fad00e Mon Sep 17 00:00:00 2001 From: Ray Miller Date: Wed, 8 Jan 2025 09:56:12 +0000 Subject: [PATCH] Validate play vars --- modules/ordo/play.scm | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/modules/ordo/play.scm b/modules/ordo/play.scm index 8e5e606..aa2036c 100644 --- a/modules/ordo/play.scm +++ b/modules/ordo/play.scm @@ -31,6 +31,10 @@ (unless (every (lambda (h) (and (pair? h) (handler? (cdr h)))) handlers) (error (format #f "invalid handlers: ~a" handlers)))) +(define (validate-vars vars) + (unless (every pair? vars) + (error (format #f "invalid vars: ~a" vars)))) + (define (validate-triggers tasks handlers) (for-each (lambda (task) (for-each (lambda (trigger) @@ -46,6 +50,10 @@ (validate-tasks tasks) (validate-handlers handlers) (validate-triggers tasks handlers) + (validate-vars vars) + ;; Reconstruct the vars here because, when a quoted list is passed in the + ;; play, it can result in an error (expected mutable pair) from assoc-set! + ;; from register-context-var!. (make-play description connection (fold (match-lambda* (((k . v) accum) (alist-cons k v accum))) '() vars) tasks handlers)) (define (run-play play)