@builtin was not respected for generic modules #1617.

This commit is contained in:
Christoffer Lerno
2024-11-13 23:34:34 +01:00
parent 61a76bb834
commit 7b516e6113
3 changed files with 18 additions and 1 deletions

View File

@@ -8,6 +8,7 @@
### Fixes
- Fix bug where `a > 0 ? f() : g()` could cause a compiler crash if both returned `void!`.
- `@builtin` was not respected for generic modules #1617.
### Stdlib changes

View File

@@ -992,7 +992,7 @@ bool unit_resolve_parameterized_symbol(SemaContext *context, NameResolve *name_r
sema_report_error_on_decl(context, name_resolve);
return false;
}
if (!decl_is_user_defined_type(name_resolve->found) && !name_resolve->path)
if (!decl_is_user_defined_type(name_resolve->found) && !name_resolve->path && !name_resolve->found->is_autoimport)
{
if (name_resolve->suppress_error) return false;
RETURN_SEMA_ERROR(name_resolve, "Function and variables must be prefixed with a path, e.g. 'foo::%s'.", name_resolve->symbol);

View File

@@ -0,0 +1,16 @@
module add(<Type>);
fn Type add(Type a, Type b) @builtin =>
a + b;
module iadd;
fn int iadd(int a, int b) @builtin =>
a + b;
module main;
import std::io, add, iadd;
fn void! main()
{
io::printfn("%s", iadd(1,2)); // Fine
io::printfn("%s", add(<int>)(1,2)); // Error
}