mirror of
https://github.com/odin-lang/Odin.git
synced 2026-04-20 05:20:28 +00:00
Merge pull request #4168 from laytan/fix-bad-import-name-errors
fix some issues with the "bad import name" errors
This commit is contained in:
@@ -4946,12 +4946,18 @@ gb_internal void check_add_import_decl(CheckerContext *ctx, Ast *decl) {
|
||||
}
|
||||
|
||||
|
||||
if (import_name.len == 0) {
|
||||
if (is_blank_ident(import_name) && !is_blank_ident(id->import_name.string)) {
|
||||
String invalid_name = id->fullpath;
|
||||
invalid_name = get_invalid_import_name(invalid_name);
|
||||
|
||||
error(id->token, "Import name %.*s, is not a valid identifier. Perhaps you want to reference the package by a different name like this: import <new_name> \"%.*s\" ", LIT(invalid_name), LIT(invalid_name));
|
||||
error(token, "Import name, %.*s, cannot be use as an import name as it is not a valid identifier", LIT(id->import_name.string));
|
||||
ERROR_BLOCK();
|
||||
|
||||
if (id->import_name.string.len > 0) {
|
||||
error(token, "Import name, '%.*s' cannot be use as an import name as it is not a valid identifier", LIT(id->import_name.string));
|
||||
} else {
|
||||
error(id->token, "Import name '%.*s' is not a valid identifier", LIT(invalid_name));
|
||||
error_line("\tSuggestion: Rename the directory or explicitly set an import name like this 'import <new_name> %.*s'", LIT(id->relpath.string));
|
||||
}
|
||||
} else {
|
||||
GB_ASSERT(id->import_name.pos.line != 0);
|
||||
id->import_name.string = import_name;
|
||||
|
||||
4
tests/vendor/all.odin
vendored
4
tests/vendor/all.odin
vendored
@@ -1,4 +1,4 @@
|
||||
package tests_vendor
|
||||
|
||||
@(require) import "glfw"
|
||||
@(require) import "lua/5.4"
|
||||
@(require) import "glfw"
|
||||
@(require) import _ "lua/5.4"
|
||||
|
||||
Reference in New Issue
Block a user