-
Notifications
You must be signed in to change notification settings - Fork 13k
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
Modules can't be defined inside of functions #493
Comments
Ditto for native modules |
Why? |
Harmless either way. I don't see a lot of functions big enough to warrant their own modules, and we don't support reaching into a function scope from outside, so I wager this is not likely to matter often. Lowering to frontend enhancement req. |
Mods in functions have magically started working. |
Discussions with @jbclements indicate this feature is bad for hygienic macros |
@brson, @pcwalton, @graydon, @dherman: I'm currently struggling to keep resolution separate from macro expansion and parsing. One key element in this fight is not allowing modules inside functions. In more detail: the macro expander needs to know when two varrefs (I'm not going to use the term "identifier" any more, because that means something different) may refer to the same binding. With module paths, it may be that a::b and b are two ways of referring to the same binding. In a world without modules inside functions, I conjecture that it may be possible to punt on this issue by observing that if a::b and b refer to the same binding, they're "external" varrefs and thus not within the purview of hygiene. If this sounds a bit sketchy to you, it does to me, too. The alternative, though, is to fold resolution into expansion, an idea that appears to give people pause. So, for the moment, I'm going to proceed with the assumption that modules can't occur inside functions.... |
@jbclements I don't really understand the problem, but I also don't understand why |
I note that given our current path-resolution rules, there is no way |
Several things to add here. First, a few months ago, Felix came up with a way to refer to a module defined inside a function:
... which worked at the time, but no longer does! It now fails to resolve the 'z' in the 'use'. I conjecture that this is due to changes in the resolver due to @pcwalton. So, I believe that modules within functions are now pretty much completely useless. On the other hand, I no longer believe that hygiene requires eliminating them. I'm not going to go into it unless people want me to. TL; DR. I'm closing this bug (again). It might make sense to get rid of modules inside fns, but it's not a high priority for me. |
Note that as of writing this comment, the example does work again after dropping the
|
Added defines from ttycom.h for dragonfly and freebsd. I wasn't sure about the convention but looking at other files it seems that whatever is over 0x80000000 is c_ulong so I went with that.
Fix passing custom CG_RUSTFLAGS when building sysroot
While pretty much useless, the following should work:
Currently fails in typestate.
The text was updated successfully, but these errors were encountered: