From 6ababab853395519f0cab53a7f04a6c91ff84e83 Mon Sep 17 00:00:00 2001 From: Kevin Tew Date: Wed, 1 Feb 2012 11:48:36 -0700 Subject: [PATCH] fix multiple places imported into the same module --- collects/meta/props | 1 + collects/racket/place.rkt | 20 ++++++++++++++++++-- collects/tests/racket/place1.rkt | 7 +++++++ collects/tests/racket/place2.rkt | 7 +++++++ collects/tests/racket/places.rkt | 3 +++ 5 files changed, 36 insertions(+), 2 deletions(-) create mode 100644 collects/tests/racket/place1.rkt create mode 100644 collects/tests/racket/place2.rkt create mode 100644 collects/tests/racket/places.rkt diff --git a/collects/meta/props b/collects/meta/props index f172b21c84..ba61ebfab5 100755 --- a/collects/meta/props +++ b/collects/meta/props @@ -1857,6 +1857,7 @@ path/s is either such a string or a list of them. "collects/tests/racket/place-channel-socket.rkt" responsible (tewk) drdr:command-line (racket "-tm" *) "collects/tests/racket/place-channel.rkt" responsible (tewk) drdr:command-line (racket "-tm" *) drdr:timeout 300 "collects/tests/racket/place.rktl" responsible (tewk) drdr:command-line (racket "-f" *) +"collects/tests/racket/places.rkt" responsible (tewk) drdr:command-line (racket *) "collects/tests/racket/port.rktl" drdr:command-line #f "collects/tests/racket/portlib.rktl" drdr:command-line #f "collects/tests/racket/pretty.rktl" drdr:command-line (racket "-f" *) diff --git a/collects/racket/place.rkt b/collects/racket/place.rkt index f2847d976e..a9f6e1121f 100644 --- a/collects/racket/place.rkt +++ b/collects/racket/place.rkt @@ -219,6 +219,17 @@ (and (not out) outr) (and (not err) errr)))])) + +(define-for-syntax (modpath->string modpath) + (cond + [(equal? modpath #f) + (number->string (current-inexact-milliseconds))] + [else + (define name (resolved-module-path-name modpath)) + (cond + [(symbol? name) (symbol->string name)] + [(path? name) (path->string name)])])) + (define-for-syntax (place-form _in _out _err _start-place-func stx orig-stx) (syntax-case stx () [(who ch body1 body ...) @@ -226,14 +237,19 @@ ;; when a `place' form is the only thing in a module mody: #`(begin #,stx) ;; normal case: - (begin + (let () (unless (syntax-transforming-module-expression?) (raise-syntax-error #f "can only be used in a module" stx)) (unless (identifier? #'ch) (raise-syntax-error #f "expected an identifier" stx #'ch)) + (define func-name-stx + (datum->syntax stx + (string->symbol + (string-append "place/anon" + (modpath->string (current-module-declare-name)))))) (with-syntax ([internal-def-name (syntax-local-lift-expression #'(lambda (ch) body1 body ...))] - [func-name (generate-temporary #'place/anon)] + [func-name (generate-temporary func-name-stx)] [in _in] [out _out] [err _err] diff --git a/collects/tests/racket/place1.rkt b/collects/tests/racket/place1.rkt new file mode 100644 index 0000000000..a323367899 --- /dev/null +++ b/collects/tests/racket/place1.rkt @@ -0,0 +1,7 @@ +#lang racket/base +(require racket/place) + +(provide p1) + +(define (p1) + (place ch 1)) diff --git a/collects/tests/racket/place2.rkt b/collects/tests/racket/place2.rkt new file mode 100644 index 0000000000..05fcae9a87 --- /dev/null +++ b/collects/tests/racket/place2.rkt @@ -0,0 +1,7 @@ +#lang racket/base +(require racket/place) + +(provide p2) + +(define (p2) + (place ch 1)) diff --git a/collects/tests/racket/places.rkt b/collects/tests/racket/places.rkt new file mode 100644 index 0000000000..1af2e797b5 --- /dev/null +++ b/collects/tests/racket/places.rkt @@ -0,0 +1,3 @@ +#lang racket/base +(require "place1.rkt") +(require "place2.rkt")