Accept toplevel action-producing expressions yielding 0 values.

A recent change to Racket must have changed the way `for` expands,
because now in conjunction with `local-expand`, we see *effectively* a
`(begin (values) (void))`. This isn't a problem usually, but in
`#lang syndicate`'s `module-begin` context, we split apart `begin`s
and examine their constituents, leading to examination of something
that will ultimately yield 0 values.

The change accepts either 0 or 1 values when collecting actions for
the module's main boot actor to execute. More than 1 value yielded by
such an expression is still considered an error. Currently, it gives
unhelpful error location information; a future refinement might be to
make the error reporting for this (rare) situation more helpful.
This commit is contained in:
Tony Garnock-Jones 2017-02-20 17:04:39 -05:00
parent deefa251d9
commit 6d8ced489c
1 changed files with 8 additions and 3 deletions

View File

@ -1180,9 +1180,14 @@
(with-store [(current-pending-actions '())
(current-pending-patch patch-empty)
(current-action-transformer values)]
(define result (thunk))
(flush-pending-patch!)
(cons result (current-pending-actions))))))
(call-with-values thunk
(lambda results
(flush-pending-patch!)
(when (> (length results) 1)
(error 'capture-actor-actions
"~a values supplied in top-level Syndicate action; more than one is unacceptable"
(length results)))
(cons results (current-pending-actions))))))))
(module+ for-module-begin
(provide capture-actor-actions))