Grabbing (missing) methods on function pointers would cause crash #2434.

This commit is contained in:
Christoffer Lerno
2025-08-25 16:39:17 +02:00
parent bc9b0900a5
commit 1634217fc4
3 changed files with 16 additions and 0 deletions

View File

@@ -67,6 +67,7 @@
- `has_tagof` on tagged lambdas returns false #2432 - `has_tagof` on tagged lambdas returns false #2432
- Properly add "inlined at" for generic instantiation errors #2382. - Properly add "inlined at" for generic instantiation errors #2382.
- Inlining a const as an lvalue would take the wrong path and corrupt the expression node. - Inlining a const as an lvalue would take the wrong path and corrupt the expression node.
- Grabbing (missing) methods on function pointers would cause crash #2434.
### Stdlib changes ### Stdlib changes
- Add `==` to `Pair`, `Triple` and TzDateTime. Add print to `Pair` and `Triple`. - Add `==` to `Pair`, `Triple` and TzDateTime. Add print to `Pair` and `Triple`.

View File

@@ -971,6 +971,7 @@ Decl *sema_resolve_type_method(SemaContext *context, CanonicalType *type, const
return NULL; return NULL;
} }
} }
if (!type_may_have_method(type)) return NULL;
Decl *type_decl = type->decl; Decl *type_decl = type->decl;
if (!decl_ok(type_decl)) return poisoned_decl; if (!decl_ok(type_decl)) return poisoned_decl;
Methods *methods = type_decl->method_table; Methods *methods = type_decl->method_table;

View File

@@ -0,0 +1,14 @@
module app;
typedef Foo = int;
fn void Foo.method(&self)
{
self.method.anything = null; // #error: There is no member or method
}
fn int main()
{
Foo bar;
bar.method();
return 0;
}