Skip to content

Commit

Permalink
[dimport.d] move addAlias to parser, remove import dmd.errors
Browse files Browse the repository at this point in the history
  • Loading branch information
thewilsonator committed Oct 5, 2024
1 parent 645db4e commit f16b1bb
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 22 deletions.
10 changes: 0 additions & 10 deletions compiler/src/dmd/astbase.d
Original file line number Diff line number Diff line change
Expand Up @@ -390,16 +390,6 @@ struct ASTBase
this.ident = id;
}
}
void addAlias(Identifier name, Identifier _alias)
{
if (isstatic)
error(loc, "cannot have an import bind list");
if (!aliasId)
this.ident = null;

names.push(name);
aliases.push(_alias);
}

override void accept(Visitor v)
{
Expand Down
11 changes: 0 additions & 11 deletions compiler/src/dmd/dimport.d
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ module dmd.dimport;
import dmd.arraytypes;
import dmd.dmodule;
import dmd.dsymbol;
import dmd.errors;
import dmd.identifier;
import dmd.location;
import dmd.visitor;
Expand Down Expand Up @@ -84,16 +83,6 @@ extern (C++) final class Import : Dsymbol
this.visibility = Visibility.Kind.private_; // default to private
}

extern (D) void addAlias(Identifier name, Identifier _alias)
{
if (isstatic)
.error(loc, "%s `%s` cannot have an import bind list", kind, toPrettyChars);
if (!aliasId)
this.ident = null; // make it an anonymous import
names.push(name);
aliases.push(_alias);
}

override const(char)* kind() const
{
return isstatic ? "static import" : "import";
Expand Down
7 changes: 6 additions & 1 deletion compiler/src/dmd/parse.d
Original file line number Diff line number Diff line change
Expand Up @@ -3501,7 +3501,12 @@ class Parser(AST, Lexer = dmd.lexer.Lexer) : Lexer
name = _alias;
_alias = null;
}
s.addAlias(name, _alias);
if (s.isstatic)
error(loc, "static import `%s` cannot have an import bind list", s.toPrettyChars());
if (!s.aliasId)
s.ident = null; // make it an anonymous import
s.names.push(name);
s.aliases.push(_alias);
}
while (token.value == TOK.comma);
break; // no comma-separated imports of this form
Expand Down

0 comments on commit f16b1bb

Please sign in to comment.