mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 03:51:18 +00:00
Generic methods were incorrectly registered as functions, leading to naming collisions. #1402
This commit is contained in:
@@ -7,6 +7,7 @@
|
||||
|
||||
### Fixes
|
||||
- Issue where a lambda wasn't correctly registered as external. #1408
|
||||
- Generic methods were incorrectly registered as functions, leading to naming collisions. #1402
|
||||
|
||||
### Stdlib changes
|
||||
*None yet*
|
||||
|
||||
@@ -230,7 +230,10 @@ static void register_generic_decls(CompilationUnit *unit, Decl **decls)
|
||||
break;
|
||||
}
|
||||
htable_set(&unit->module->symbols, (void *)decl->name, decl);
|
||||
if (decl->visibility == VISIBLE_PUBLIC) global_context_add_generic_decl(decl);
|
||||
if (decl->visibility == VISIBLE_PUBLIC && decl->decl_kind != DECL_MACRO)
|
||||
{
|
||||
global_context_add_generic_decl(decl);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
33
test/test_suite/generic/generic_resolution_1402.c3t
Normal file
33
test/test_suite/generic/generic_resolution_1402.c3t
Normal file
@@ -0,0 +1,33 @@
|
||||
// #target: macos-x64
|
||||
module playground::bug(<Ty>);
|
||||
import std::io;
|
||||
|
||||
struct Foo
|
||||
{
|
||||
Ty x;
|
||||
}
|
||||
|
||||
fn void Foo.print_it(&self)
|
||||
{
|
||||
io::printf("Method %s\n", self.x);
|
||||
}
|
||||
|
||||
module playground::bug(<Ty>);
|
||||
import std::io;
|
||||
|
||||
macro void print_it(...)
|
||||
{
|
||||
io::printn("Macro 456");
|
||||
}
|
||||
|
||||
module playground;
|
||||
import playground::bug;
|
||||
|
||||
def MyFoo = Foo(<int>);
|
||||
|
||||
fn void main(String[] args)
|
||||
{
|
||||
MyFoo foo = { 123 };
|
||||
foo.print_it();
|
||||
bug::print_it(<int>)();
|
||||
}
|
||||
Reference in New Issue
Block a user