mirror of
https://github.com/Ed94/Odin.git
synced 2026-08-06 23:58:50 +00:00
Add anonymous using import names with an underscore (#127)
`using import _ "foo.odin"`
This commit is contained in:
+5
-1
@@ -2525,7 +2525,11 @@ void check_add_import_decl(Checker *c, AstNodeImportDecl *id) {
|
|||||||
|
|
||||||
String import_name = path_to_entity_name(id->import_name.string, id->fullpath);
|
String import_name = path_to_entity_name(id->import_name.string, id->fullpath);
|
||||||
if (is_blank_ident(import_name)) {
|
if (is_blank_ident(import_name)) {
|
||||||
error(token, "File name, %.*s, cannot be use as an import name as it is not a valid identifier", LIT(id->import_name.string));
|
if (id->is_using) {
|
||||||
|
// TODO(bill): Should this be a warning?
|
||||||
|
} else {
|
||||||
|
error(token, "File name, %.*s, cannot be use as an import name as it is not a valid identifier", LIT(id->import_name.string));
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
GB_ASSERT(id->import_name.pos.line != 0);
|
GB_ASSERT(id->import_name.pos.line != 0);
|
||||||
id->import_name.string = import_name;
|
id->import_name.string = import_name;
|
||||||
|
|||||||
+1
-1
@@ -4349,7 +4349,7 @@ AstNode *parse_import_decl(AstFile *f, bool is_using) {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_blank_ident(import_name)) {
|
if (!is_using && is_blank_ident(import_name)) {
|
||||||
syntax_error(import_name, "Illegal import name: `_`");
|
syntax_error(import_name, "Illegal import name: `_`");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user