diff --git a/releasenotes.md b/releasenotes.md index f9b4c6457..2680a7fbb 100644 --- a/releasenotes.md +++ b/releasenotes.md @@ -15,6 +15,7 @@ - Fix division-by-zero checks on `a /= 0` and `b /= 0f` #2558. - Fix fmod `a %= 0f`. - Regression vector ABI: initializing a struct containing a NPOT vector with a constant value would crash LLVM. #2559 +- Error message with hashmap shows "mangled" name instead of original #2562. ### Stdlib changes diff --git a/src/compiler/types.c b/src/compiler/types.c index 0e6dfc29b..7db63f562 100644 --- a/src/compiler/types.c +++ b/src/compiler/types.c @@ -355,7 +355,14 @@ static const char *type_to_error_string_with_path(Type *type) Decl *decl = type->decl; const char *suffix = decl->unit->module->generic_suffix; scratch_buffer_clear(); - scratch_buffer_append(decl->unit->module->name->module); + if (decl->unit->module->generic_module) + { + scratch_buffer_append(decl->unit->module->generic_module->name->module); + } + else + { + scratch_buffer_append(decl->unit->module->name->module); + } scratch_buffer_append("::"); if (suffix || type_is_inner_type(type)) { diff --git a/test/test_suite/generic/generic_error_out.c3 b/test/test_suite/generic/generic_error_out.c3 new file mode 100644 index 000000000..68f9fbb0f --- /dev/null +++ b/test/test_suite/generic/generic_error_out.c3 @@ -0,0 +1,10 @@ +module test; +import std::collections::map; + +fn void foo(HashMap{char[], String}* f) { } + +fn void main() +{ + HashMap{char[], char[]} x; + foo(&x); // #error: Implicitly casting 'std::collections::map::HashMap{char[], char[]}*' to 'std::collections::map::HashMap{char[], String}*' is not permitted, but you may do an explicit cast by placing '(std::collections::map::HashMap{char[], String}*)' before the expression +}