Odin icon indicating copy to clipboard operation
Odin copied to clipboard

assignment of generic procs with ternary operator fails

Open awwdev opened this issue 4 years ago • 3 comments

Odin dev-2021-10:eebf49ba

fn_ : proc(_: int) //proc pointer
fn :: proc(_: $T ) {}

fn_ = fn //works
if true do fn_ = fn else do fn_ = fn //works

fn_ = true ? fn : fn //doesn't work

Cannot assign value 'true ? fn : fn' of type 'proc($T)' to 'proc(int)' in assignment

This is possibly a bug / oversight. The generic proc fn can be specialised, anytime, to (proc :: (_: int)) and thus matches the signature of the function pointer fn_ no matter the syntactic sugar you use.

awwdev avatar Oct 23 '21 11:10 awwdev

Hello!

I am marking this issue as stale as it has not received any engagement from the community or maintainers 120 days. That does not imply that the issue has no merit! If you feel strongly about this issue

  • open a PR referencing and resolving the issue;
  • leave a comment on it and discuss ideas how you could contribute towards resolving it;
  • leave a comment and describe in detail why this issue is critical for your use case;
  • open a new issue with updated details and a plan on resolving the issue.

The motivation for this automation is to help prioritize issues in the backlog and not ignore, reject, or belittle anyone..

github-actions[bot] avatar Jul 24 '22 21:07 github-actions[bot]

Still a problem in dev-2022-12:1d6f7680. Please reopen.

awwdev avatar Dec 25 '22 17:12 awwdev

The fn_ = fn statement produces an error for me starting with commit https://github.com/odin-lang/Odin/commit/0a0db23b1751c0b7021cc1b3af3329b5d93cf9da

main.odin(7:16) Cannot determine polymorphic type from parameter: 'invalid type' to '$T'
main.odin(9:11) Cannot assign value 'fn' of type 'proc($T)' to 'proc(int)' in assignment

Seems like it is now working as it should?

rick-masters avatar Mar 27 '24 14:03 rick-masters