How to import names from another module
I tried the following:
mod@Module(m, _, _): defines unique Module m of module-ref mod scopes Sort, Symbol Import(m): imports Sort, Symbol from m refers to Module m
With this code, the imported module name correctly resolves to the imported module. But the sorts and symbols do not become available. How can I fix this?
(When I remove
Asked by Sebastian Erdweg on 8 May 2014 at 11:02refers to Module m
, CTRL-click on the imported module name itself does not work anymore.)
4 Answers
Second rule should be
imports Sort, Symbol from Module m
and drop the refers to clause
Answered by Gabriƫl Konat on 8 May 2014 at 11:15
Tried that, did not work:
Answered by Sebastian Erdweg on 8 May 2014 at 11:19
The sorts and symbols still do not come into scope. Maybe I need to say specify the scope I want to import them into? Note that AST syntax
Module(ID,List(Import),List(Def))
As mentioned above, without the refers-to clause, the import does not resolve to the module. CTRL-click fails and I think the
module-ref
property is also not set.
Every import is handled as an implicit reference. If resolution does not work after changing
Answered by Guido Wachsmuth on 8 May 2014 at 11:59refers to Module m
toimports Sort from Module m
, it is either a bug or something else is wrong. Make sure it isfrom Module m
and notfrom m
, which is valid syntax, but means something different. The fact that the resolution does not work is the root cause. Without this, the import will not work. The target scope is the scope forSort
in which the import is expressed, which is probably the surrounding module.
Ah, ok. With the
Module
it works. Complete working code for referrence:Answered by Sebastian Erdweg on 8 May 2014 at 13:21mod@Module(m, _, _): defines unique Module m of module-ref mod scopes Sort, Symbol Import(m): imports Sort, Symbol from Module m