From 3dc7d25724e3e3ceb1df31adf212646c1e515669 Mon Sep 17 00:00:00 2001 From: Tony Garnock-Jones Date: Thu, 19 Jun 2014 22:38:05 -0400 Subject: [PATCH] Warn on wildcard gestalt-projections --- minimart/gestalt.rkt | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/minimart/gestalt.rkt b/minimart/gestalt.rkt index 91e88ed..2497fd6 100644 --- a/minimart/gestalt.rkt +++ b/minimart/gestalt.rkt @@ -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.