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
{{ message }}
Repository navigation
@couldCoerce - check if a type will coerce to another #3641
Sometimes its safe to assign a variable to a similar type when the types don't exactly match. Such is the case with []const u8 and [3]u8. Checking if the types match fails, but it IS safe to assign a []const u8 variable to a value of type [3]u8. I would like to be able to test if [3]u8 can be coerced into a []const u8.
I ran into this issue trying to instantiate a tagged union from a runtime known tag, I check the union field type against val: var on line 82 of the linked gist. It would have been safe to assign the value, but because the types don't match control flow proceeds into the 'else unreachable' branch.
A @couldCoerce method would eliminate the need for possibly complex type comparisons necessary to determine wether it is safe to perform this assignment.
Activity
billzez commentedon Jan 13, 2023
I would also find this useful. Can this be reopened?
maxzhao commentedon Jan 13, 2023
please reopen, it's very useful for some case