alantech / alan

Autoscalable Programming Language
https://alan-lang.org
MIT License
304 stars 10 forks source link

Prefer normal functions if one is defined #829

Closed dfellis closed 1 month ago

dfellis commented 1 month ago

So the reason why my custom store function wasn't being used is because the generic function store{T}(a: T, b: T) -> T matches all types when the stored value is the same type as the original value, and the way resolve_function worked before (because the borrow checker made that the easiest way to implement it), it would first see if any generic function can resolve for the desired function and use that, then if not, it would check if there's a "normal" function that would do. This worked most of the time because there was never a generic function that also matched a "normal" function within the codebase, yet, but if there's ever a match for both generic and normal, the normal function, which had to be handwritten by the developer, should be preferred, so this PR reverses that and then updates the new gpu test back to the desired store syntax (desired because it should also work with =, but a bit confusing here as written as a let assignment as well, so I stuck with the method syntax).