From 60fa8ab91f62e6e2bb07b7dc7400498d6d9dff67 Mon Sep 17 00:00:00 2001 From: Stephen Chang Date: Wed, 31 Aug 2016 12:58:56 -0400 Subject: [PATCH] fix syntax taint errs produced by srcloc workaround in #%app --- macrotypes/stx-utils.rkt | 2 +- turnstile/examples/rosette/rosette-notes.txt | 26 ++++++++++++++++++++ turnstile/examples/rosette/rosette2.rkt | 2 +- 3 files changed, 28 insertions(+), 2 deletions(-) diff --git a/macrotypes/stx-utils.rkt b/macrotypes/stx-utils.rkt index 81c5bdc..47e3591 100644 --- a/macrotypes/stx-utils.rkt +++ b/macrotypes/stx-utils.rkt @@ -74,7 +74,7 @@ (define (transfer-stx-props new orig #:ctx [ctx new]) (datum->syntax ctx (syntax-e new) orig orig)) (define (replace-stx-loc old new) - (datum->syntax old (syntax-e old) new old)) + (datum->syntax (syntax-disarm old #f) (syntax-e (syntax-disarm old #f)) new old)) ;; set-stx-prop/preserved : Stx Any Any -> Stx ;; Returns a new syntax object with the prop property set to val. If preserved diff --git a/turnstile/examples/rosette/rosette-notes.txt b/turnstile/examples/rosette/rosette-notes.txt index cc73732..24a4067 100644 --- a/turnstile/examples/rosette/rosette-notes.txt +++ b/turnstile/examples/rosette/rosette-notes.txt @@ -1,3 +1,28 @@ +2016-08-31 -------------------- + +Adding typed define/debug, debug (from query/debug), render (from lib/query): +- revealed problems with the way Rosette tracks source locations + - in query/debug.rkt: https://github.com/emina/rosette/blob/cb877b9094f368c5f392518e7538ae8a061433a2/rosette/query/debug.rkt#L38 + - specifically, make-variable-like-transformer does not preserve src loc + properly, see: https://github.com/emina/rosette/issues/40 + +Workaround: manually set the src loc in #%app to surface program +- this causes taint problems bc rosette #%app uses syntax-rules, which taints + its output, which causes problems when we try to destructure it +minimal example: +#lang racket +(require (for-syntax syntax/parse)) +(define-syntax-rule (mac x) + (#%app add1 x)) +(define-syntax test + (syntax-parser + [(_ x) + #:with e (local-expand #'(mac x) 'expression null) + (datum->syntax #'e (syntax-e #'e))])) +(test 1) +- calling syntax-disarm on the expanded pieces of a Rosette #%app appears to + prevent the taint errors + 2016-08-29 -------------------- Interesting parts of Typed Rosette @@ -28,6 +53,7 @@ TODOs: - depends on macrotypes and rosette - create version of turnstile that does not provide #%module-begin - eg rename existing turnstile to turnstile/lang? +- remove my-this-syntax stx param 2016-08-25 -------------------- diff --git a/turnstile/examples/rosette/rosette2.rkt b/turnstile/examples/rosette/rosette2.rkt index aa30114..5030451 100644 --- a/turnstile/examples/rosette/rosette2.rkt +++ b/turnstile/examples/rosette/rosette2.rkt @@ -252,7 +252,7 @@ [⊢ [e_arg ≫ e_arg- ⇐ : τ_in] ...] -------- ;; TODO: use e_fn/progsrc- (currently causing "cannot use id tainted in macro trans" err) - [⊢ [_ ≫ (ro:#%app e_fn- e_arg- ...) ⇒ : τ_out]]] + [⊢ [_ ≫ (ro:#%app e_fn/progsrc- e_arg- ...) ⇒ : τ_out]]] [(_ e_fn e_arg ...) ≫ [⊢ [e_fn ≫ e_fn- ⇒ : (~Ccase-> ~! . (~and ty_fns ((~C→ . _) ...)))]] #:with e_fn/progsrc- (replace-stx-loc #'e_fn- #'e_fn)