Enforce rule: fields legal only at actor toplevel or in facet setup code

This commit is contained in:
Tony Garnock-Jones 2016-07-10 16:47:37 -04:00
parent 175c619edc
commit 9bf2991da8
1 changed files with 8 additions and 3 deletions

View File

@ -207,8 +207,13 @@
(define-syntax (field stx) (define-syntax (field stx)
(syntax-parse stx (syntax-parse stx
[(_ [id:id init] ...) [(_ [id:id init] ...)
(syntax/loc stx (quasisyntax/loc stx
(begin (define id (make-field 'id init)) (begin
(when (and (in-script?) (current-facet-id))
(error 'field
"~a: Cannot declare fields in script; are you missing a (react ...)?"
#,(source-location->string stx)))
(define id (make-field 'id init))
...))])) ...))]))
(define-syntax (assert stx) (define-syntax (assert stx)