mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 12:01:16 +00:00
Compiler didn't detect when a module name was used both as a generic and regular module.
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
{
|
||||
|
||||
7
test/test_suite/module/module_generic_mixing.c3
Normal file
7
test/test_suite/module/module_generic_mixing.c3
Normal file
@@ -0,0 +1,7 @@
|
||||
module test;
|
||||
fn void main() {}
|
||||
|
||||
module test(<Type>); // #error: generic
|
||||
fn void test() {
|
||||
Type a;
|
||||
}
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user