From: Ludovic Courtès Date: Sat, 14 Dec 2019 22:56:12 +0000 (+0100) Subject: srfi-35: Generate a unique binding for the constructor. X-Git-Tag: v2.9.8~3 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=76e436c892c7f8f41f36ed6343eb1626ff84e90e;p=platform%2Fupstream%2Fguile.git srfi-35: Generate a unique binding for the constructor. Previously we'd get warnings like: t.scm:11:0: warning: shadows previous definition of `unused-constructor-51900bdce47d50c' at /tmp/t.scm:6:0 whenever 'define-condition-type' appeared more than once in a source file. * module/srfi/srfi-35.scm (define-condition-type): Rewrite as 'syntax-case' and generate UNUSED-CONSTRUCTOR as a function of TYPE. --- diff --git a/module/srfi/srfi-35.scm b/module/srfi/srfi-35.scm index fbbe89ef0..e430833c4 100644 --- a/module/srfi/srfi-35.scm +++ b/module/srfi/srfi-35.scm @@ -118,11 +118,20 @@ by C." (let ((pred (record-predicate type))) (or-map (lambda (x) (and (pred x) x)) (simple-exceptions c)))) -(define-syntax-rule (define-condition-type type parent predicate - (field accessor) ...) - (define-exception-type type parent - unused-constructor predicate - (field accessor) ...)) +(define-syntax define-condition-type + (lambda (s) + (syntax-case s () + ((_ type parent predicate (field accessor) ...) + ;; The constructor is unused, but generate a new name for each + ;; condition to avoid '-Wshadowed-toplevel' warnings when several + ;; condition types are defined in the same compilation unit. + (with-syntax ((unused-constructor + (datum->syntax + #'type + (symbol-append '#{ make-}# (syntax->datum #'type))))) + #'(define-exception-type type parent + unused-constructor predicate + (field accessor) ...)))))) (define-syntax condition-instantiation ;; Build the `(make-condition type ...)' call.