type some_func = fn() void;
type t = (*some_func | int);
export fn main() void = {
func(&empty);
};
fn func(v: t) void = void;
fn empty() void = void;
This currently fails with Argument type *fn() void is not assignable to parameter type t
. Works fine if the pointer is moved into the alias, or if &empty
is explicitly cast to *some_func
.
Might be related to type hints somehow.
Relevant commits: f2723ad7
- Make pointer/slice assignability rules more strict
This specific problem happens because *unaliased_fn isn't assignable to *aliased_fn, but when unary & expressions and alloc expressions have type *unaliased_fn and are given a type hint of *aliased_fn, they can convert. This is needed since function declarations can't have aliased types, and a cast shouldn't be required here. But this conversion doesn't happen when the type hint is a tagged union. Maybe we could just make *unaliased_fn assignable to *aliased_fn as a special case? That might be the best option.
i'd prefer to try to make this work with tagged unions