Skip to content

Commit e469c79

Browse files
authored
Merge pull request #2131 from wilzbach/imports-spec
Update spec for multiple selective imports merged-on-behalf-of: MetaLang <MetaLang@users.noreply.github.com>
2 parents 620548c + cf44d16 commit e469c79

File tree

1 file changed

+19
-6
lines changed

1 file changed

+19
-6
lines changed

spec/module.dd

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -178,19 +178,15 @@ $(GNAME ImportDeclaration):
178178

179179
$(GNAME ImportList):
180180
$(I Import)
181-
$(I ImportBindings)
182181
$(I Import) $(D ,) $(I ImportList)
183182

184183
$(GNAME Import):
185184
$(I ModuleFullyQualifiedName)
186185
$(I ModuleAliasIdentifier) $(D =) $(I ModuleFullyQualifiedName)
186+
$(I ImportBindings)
187187

188188
$(GNAME ImportBindings):
189-
$(I Import) $(D :) $(I ImportBindList)
190-
191-
$(GNAME ImportBindList):
192-
$(I ImportBind)
193-
$(I ImportBind) $(D ,) $(I ImportBindList)
189+
$(I Import) $(D :) $(I ImportBind)
194190

195191
$(GNAME ImportBind):
196192
$(I Identifier)
@@ -407,6 +403,23 @@ void main()
407403

408404
$(P $(D static) cannot be used with selective imports.)
409405

406+
$(P Selective `import`s can be made from multiple modules if
407+
all `import`s are selective, or when the imported module has a qualified name:)
408+
409+
$(SPEC_RUNNABLE_EXAMPLE_COMPILE
410+
---
411+
import std.stdio : writeln, writefln, std.file : write, std.ascii;
412+
413+
void main()
414+
{
415+
writeln("hello!"); // ok, writeln from std.stdio
416+
writefln("%s!", "hello"); // ok, writefln from std.stdio
417+
write("world.txt", "hello"); // ok, write from std.file
418+
writeln(digits); // ok, digits from std.ascii
419+
}
420+
---
421+
)
422+
410423
$(H2 $(LNAME2 renamed_selective_imports, Renamed and Selective Imports))
411424

412425
$(P When renaming and selective importing are combined:)

0 commit comments

Comments
 (0)