Compiler didn't detect when a module name was used both as a generic and regular module.

This commit is contained in:
Christoffer Lerno
2024-08-23 19:30:36 +02:00
parent cb790b4672
commit d1a0ec5a35
4 changed files with 16 additions and 1 deletions

View File

@@ -82,6 +82,7 @@
- Bug when compile time subtracting a distinct type.
- `insert_at` incorrectly prevented inserts at the end of a list.
- Fix aligned alloc for Win32 targets.
- Compiler didn't detect when a module name was used both as a generic and regular module.
### Stdlib changes

View File

@@ -20,6 +20,13 @@ static inline bool create_module_or_check_name(CompilationUnit *unit, Path *modu
if (!module)
{
module = unit->module = compiler_find_or_create_module(module_name, parameters);
if ((parameters == NULL) == module->is_generic)
{
print_error_at(module_name->span, "'%s' is both used as regular and generic module, it can't be both.",
module_name->module);
SEMA_NOTE(module->name, "The definition here is different.");
return false;
}
}
else
{

View File

@@ -0,0 +1,7 @@
module test;
fn void main() {}
module test(<Type>); // #error: generic
fn void test() {
Type a;
}

View File

@@ -454,7 +454,7 @@ fn void! lex_uint()
assert(kind == UINT, "got %s; want %s", kind, Kind.UINT);
}
}
module lexer;
module lexer2;
import std::io;
fn int main(String[] args)