Validate play vars

This commit is contained in:
Ray Miller 2025-01-08 09:56:12 +00:00
parent 7f73a9b7de
commit 3153469a2c
Signed by: ray
GPG key ID: 043F786C4CD681B8

View file

@ -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)