Warn on wildcard gestalt-projections

This commit is contained in:
Tony Garnock-Jones 2014-06-19 22:38:05 -04:00
parent e1f72f92e8
commit 3dc7d25724
1 changed files with 14 additions and 2 deletions

View File

@ -165,12 +165,24 @@
;; Gestalt × GestaltProjection → (Option (Setof (Listof Value)))
;; Projects g with pr and calls matcher-key-set on the result.
(define (gestalt-project/keys g pr)
(matcher-key-set (gestalt-project g pr)))
(check-projection-result g pr (matcher-key-set (gestalt-project g pr))))
;; Gestalt × GestaltProjection → (Option (Setof Value))
;; Projects g with pr and calls matcher-key-set/single on the result.
(define (gestalt-project/single g pr)
(matcher-key-set/single (gestalt-project g pr)))
(check-projection-result g pr (matcher-key-set/single (gestalt-project g pr))))
;; Gestalt × GestaltProjection × (Option A) → (Option A)
(define (check-projection-result g pr result)
(when (not result)
(match-define (projection metalevel level get-advertisements? spec _) pr)
(log-warning "Wildcard detected projecting ~a at metalevel ~a, level ~a\nwith pattern ~v from gestalt:\n~a"
(if get-advertisements? "advs" "subs")
metalevel
level
spec
(gestalt->pretty-string g)))
result)
;; Gestalt -> Gestalt
;; Discards the 0th metalevel, renumbering others appropriately.