From fb80d1842899f0cffb1b0c719772f742ef02ecfe Mon Sep 17 00:00:00 2001 From: Alexis King Date: Wed, 13 Dec 2017 11:05:15 -0800 Subject: [PATCH] =?UTF-8?q?syntax/parse:=20Arrange=20for=20built-in=20macr?= =?UTF-8?q?o=E2=80=99s=20names=20to=20be=20preserved?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The dance that syntax/parse performs to lazily load its implementation rewrites uses of syntax/parse macros in such a way that their original names were discarded, which shows up in error messages. By simply invoking the underlying transformer directly in the proxy macro instead of expanding to a rewritten use, users’ names can be preserved. fixes #1909 --- pkgs/racket-test/tests/stxparse/test-errors.rkt | 5 +++++ racket/collects/syntax/parse/private/sc.rkt | 9 ++------- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/pkgs/racket-test/tests/stxparse/test-errors.rkt b/pkgs/racket-test/tests/stxparse/test-errors.rkt index 4b52366d79..ba257c3d03 100644 --- a/pkgs/racket-test/tests/stxparse/test-errors.rkt +++ b/pkgs/racket-test/tests/stxparse/test-errors.rkt @@ -1,5 +1,6 @@ #lang scheme (require syntax/parse + (only-in syntax/parse [syntax-parse renamed-syntax-parse]) syntax/parse/debug rackunit "setup.rkt") @@ -206,3 +207,7 @@ #rx"expected attribute name") ;; two more +(tcerr "renamed syntax-parse bad syntax" + (renamed-syntax-parse) + #rx"^renamed-syntax-parse: ") + diff --git a/racket/collects/syntax/parse/private/sc.rkt b/racket/collects/syntax/parse/private/sc.rkt index fc8abf7907..ae0022ba48 100644 --- a/racket/collects/syntax/parse/private/sc.rkt +++ b/racket/collects/syntax/parse/private/sc.rkt @@ -6,10 +6,7 @@ ;; keep and keep as abs. path -- lazy-loaded macros produce references to this ;; must be required via *absolute module path* from any disappearing module ;; (so for consistency etc, require absolutely from all modules) -(require syntax/parse/private/residual - racket/syntax - racket/stxparam - syntax/stx) +(require syntax/parse/private/residual) (begin-for-syntax (lazy-require @@ -60,9 +57,7 @@ define-eh-alternative-set) (let ([tx (lambda (get-id) (lambda (stx) - (syntax-case stx () - [(_ . args) - (datum->syntax stx (cons (get-id) #'args) stx)])))]) + ((syntax-local-value (get-id)) stx)))]) (values (tx id:define-syntax-class) (tx id:define-splicing-syntax-class)