mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 12:01:16 +00:00
- Correctly errors when a generic module contains a self-generic type.
This commit is contained in:
@@ -60,6 +60,7 @@
|
||||
- Incorrectly allowed getting pointer to a macro #2049.
|
||||
- &self not runtime null-checked in macro #1827.
|
||||
- Bug when printing a boolean value as an integer using printf.
|
||||
- Show error when a generic module contains a self-generic type.
|
||||
|
||||
### Stdlib changes
|
||||
- `new_*` functions in general moved to version without `new_` prefix.
|
||||
|
||||
@@ -4497,6 +4497,13 @@ Decl *sema_analyse_parameterized_identifier(SemaContext *c, Path *decl_path, con
|
||||
Decl *alias = name_resolve.found;
|
||||
ASSERT(alias);
|
||||
Module *module = alias->unit->module;
|
||||
|
||||
if (c->unit->module->generic_module == module)
|
||||
{
|
||||
sema_error_at(c, span, "This identifier is recursively using %s.", module->name->module);
|
||||
return poisoned_decl;
|
||||
}
|
||||
|
||||
unsigned parameter_count = vec_size(module->parameters);
|
||||
ASSERT(parameter_count > 0);
|
||||
if (parameter_count != vec_size(params))
|
||||
|
||||
29
test/test_suite/generic/generic_self_ref.c3
Normal file
29
test/test_suite/generic/generic_self_ref.c3
Normal file
@@ -0,0 +1,29 @@
|
||||
module gui::widget {Type};
|
||||
import gui::widget_types;
|
||||
import std::collections::list;
|
||||
import std::io;
|
||||
|
||||
struct Widget
|
||||
{
|
||||
int id;
|
||||
Type type;
|
||||
List {any} children;
|
||||
}
|
||||
|
||||
fn void Widget{Label}.draw(Widget* self) // #error: This identifier is recursively using gui::widget
|
||||
{
|
||||
io::printfn("Hello Label");
|
||||
}
|
||||
|
||||
module gui::widget_types;
|
||||
import gui::widget;
|
||||
struct Label
|
||||
{
|
||||
String text;
|
||||
}
|
||||
|
||||
fn void main()
|
||||
{
|
||||
Widget {int} y;
|
||||
y.draw();
|
||||
}
|
||||
Reference in New Issue
Block a user