Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

racket-base-requires does not preserve requires for submodules #76

Closed
florence opened this issue Jan 8, 2015 · 4 comments
Closed

racket-base-requires does not preserve requires for submodules #76

florence opened this issue Jan 8, 2015 · 4 comments

Comments

@florence
Copy link
Contributor

florence commented Jan 8, 2015

#lang racket
(module+ test list->set)

gets rewritten to

#lang racket/base


(module+ test list->set)

which will then error, because list->set comes from racket/set not racket/base

@greghendershott
Copy link
Owner

Yep. This is a known limitation.

But I notice that this caveat in the doc string for racket-trim-requires:

Note: This only works for requires at the top level of a source
file using `#lang`. It does *not* work for `require`s inside
`module` forms.

Did not get copied into the doc string for racket-base-requires, too.

At the very least, I should update the doc string. Last I had looked at it, though, it was not clear to me how to remove this limitation. I can take another look, in case it's more clear to me, now.

@florence
Copy link
Contributor Author

florence commented Jan 8, 2015

Ahhh. I see.

Could you use rackets module->imports to find the needed requires? Or does the problem lie elsewhere?

@greghendershott
Copy link
Owner

The limitation is with show-requires, it doesn't seem to consider sub-modules.

Maybe I could traverse the file to discover sub-modules (and sub-sub-modules and so on), run show-requires on each, and combine the results. Maybe that would be reliable, I don't know.

Another tack would be to submit a PR against show-requires. :)

Honestly so far I've found it only a mild nuisance, sometimes needing to manually add back a missing require. I feel like the feature is usually saving me a dozen manual changes, and 1 step backward isn't a big deal. So I haven't felt super-motivated to fix it, especially if it's a lot of work. However I agree it's technically not correct. And I might feel differently working with very submodule-heavy source files.

@florence
Copy link
Contributor Author

florence commented Jan 8, 2015

I've just been playing with show-requires called directly on submodules and it... explodes. Looks like an internal error with how show-requires calls get-module-code.

Gah, I see why this is difficult. Oh well. :) Maybe a warning message when either command is run (and submodules are present?) saying "hey you might have broken submodules" is in order, to stop anyone else from being surprised?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants