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 refers to Module m, CTRL-click on the imported module name itself does not work anymore.)

Asked by Sebastian Erdweg on 8 May 2014 at 11:02

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:

  • 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.

Answered by Sebastian Erdweg on 8 May 2014 at 11:19

Every import is handled as an implicit reference. If resolution does not work after changing refers to Module m to imports Sort from Module m, it is either a bug or something else is wrong. Make sure it is from Module m and not from 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 for Sort in which the import is expressed, which is probably the surrounding module.

Answered by Guido Wachsmuth on 8 May 2014 at 11:59

Ah, ok. With the Module it works. Complete working code for referrence:

mod@Module(m, _, _):
    defines unique Module m
       of module-ref mod
    scopes Sort, Symbol

Import(m):
    imports Sort, Symbol from Module m
Answered by Sebastian Erdweg on 8 May 2014 at 13:21