Comments (3)
I'd tested on procedures defined with define/contract
and plain provide
, which worked.
But I confirm what you're reporting, with an example using (provide/contract)
or (provide (contract-out ..))
.
The problem is that we definitely do want source-id
in the case of a (provide (rename-out ...))
. In that case, nominal-source-id
is the renamed/provided thing, and source-id
is how it was actually defined.
In other words, identifier-binding
seems to behave "backwards" for contract-out
vs. rename-out
. :(
Even worse, there's the case of (provide (contract-out [rename -FOO foo (-> any)]))
-- that is, both rename and contract. In that case source-id
is something like 'provide/contract-id-foo.13
, nominal-source-id
is foo
, and neither of those is the -FOO
identifier used at the definition site.
Maybe I need to try finding all 3 of the possibilities -- the value from the Emacs buffer, source-id
, and nominal-source-id
-- in the source file, until one succeeds (or none do)?? That seems a bit kludgy, but maybe it's the only way to accomplish this. I think I'll post to the Racket mailing list to ask.
;;; provide.rkt
#lang racket
(define (f)
0)
(provide f)
(define (-r)
0)
(provide (rename-out [-r r]))
(define/contract (dc)
(-> any)
0)
(provide dc)
(define (pc)
0)
(provide (contract-out [pc (-> any)]))
(define (-pcr)
0)
(provide (contract-out [rename -pcr pcr (-> any)]))
;;; some-other-file.rkt
#lang racket
(require "provide.rkt")
(pretty-print
(for/list ([sym '(f r dc pc pcr)])
(match (identifier-binding (namespace-symbol->identifier sym))
[(list source-mpi source-id
nominal-source-mpi nominal-source-id
source-phase import-phase nominal-export-phase)
(list sym "source" source-id "nominal" nominal-source-id)])))
;; ==>
;; '((f "source" f "nominal" f)
;; (r "source" -r "nominal" r)
;; (dc "source" dc "nominal" dc)
;; (pc "source" provide/contract-id-pc.9 "nominal" pc)
;; (pcr "source" provide/contract-id-pcr.13 "nominal" pcr))
from racket-mode.
Note: Although commit 0115d51 fixes the specific issue originally reported, it doesn't handle the contract-out
plus rename permutation I discussed above. Handling that, if possible at all, will require another approach.
from racket-mode.
Commit 1af7969 adds handing the renaming/contracting provides.
from racket-mode.
Related Issues (20)
- `racket-hash-lang-mode` should turn off `electric-pair-open-newline-between-pairs`
- Wrapping a region with pairs should not move to end of region HOT 3
- Emacs 30 update `shr-heading`, which breaks `racket-describe` HOT 4
- racket-repl-mode ansi escape code coloring HOT 6
- pretty-print not happening despite `racket-pretty-print` set to `t`? HOT 5
- `racket-repl-goto-error-location` chokes every *even* number of error locations HOT 2
- Using racket-hash-lang-mode with org-mode source blocks HOT 18
- `narrow-to-defun` doesn't work properly HOT 2
- `beginning-of-defun` doesn't work properly when narrowed HOT 6
- FYI: Scribble HTML change HOT 2
- `racket-xp-rename` could use future history
- support macro hiding in racket-stepper mode? HOT 10
- Racket mode is just not working. Can someone please help me? HOT 4
- Identifiers with @ in racket-xp-mode HOT 5
- Regexp-based highlighting of lines HOT 2
- racket-tests/expand-expression passes with racket 8.10 on debian HOT 1
- Length of popup error HOT 2
- Out of range error in narrowed buffer during redisplay using `racket-xp-mode` HOT 7
- REPL: only the first expression/form is evaluated/printed HOT 5
- racket-repl exec-path does not match racket-mode buffer's exec-path HOT 13
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from racket-mode.