You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
iterate_random :: () -> Iterator(i32) {
return .{
data = alloc.on_heap(random.Random.make()),
next = (data: rawptr) -> (i32, bool) {
random := cast(^random.Random) data;
return cast(i32) random->int(), true;
},
};
}
Getting this error:
(/home/bumbread/test/test.onyx:20,36) Trying to resolve type of source expression.
20 | random := cast(^random.Random) data;
^~~~~~
(/home/bumbread/test/test.onyx:20,23) Trying to resolve destination type for cast.
20 | random := cast(^random.Random) data;
^~~~
The text was updated successfully, but these errors were encountered:
Looks like this is because of the random variable being declared on the same line. The := syntax is really a shorthand for this:
main :: () {
random: #auto;
random = cast(^random.Random) data;
}
So what's happening is the compiler is trying to lookup Random inside the random variable, which does not have a type yet. I believe if you call the variable something else, it will work successfully. Or, you can use explicitly say the parameter is a pointer to random.Random, then you can remove the cast all together.
Getting this error:
The text was updated successfully, but these errors were encountered: