Elektrine lite

← Feed

@EndlessMason@hachyderm.io

Post #2272214

2026-04-20 12:14 UTC

@bshn@hachyderm.io > automatically perform certain "trivial" casts that are considered safe and obvious. > unexpected behavior if not caught early on. How can both of these be true at the same time? Surely the compiler isn't doing unsafe/unexpected things automatically

Replies (1)

  • @bshn@hachyderm.io 2026-04-21 16:42

    @EndlessMason@hachyderm.io I want to say a big thank you, as you not only asked a great question, but your reply also led me to understand that I copied wrong example to the initial post (and thanks god no one noticed 🤣). About your question specifically, I think the words "unexpected" behavior are toooo close to "undefined" behavior, and by using them I am putting readers to a confusion. In my thoughts "unexpected" were used to represent how such casts can affect the typesystem of our programs and produce unexpected (from programmers point of view) behavior once we make changes in the code or just make wrong assumptions from the start. Most of such situations will be caught by compiler, yet the resolution of errors it will show still require additional effort. https://bshn.rs/blog/not-so-trivial-casts/ I made a small post with examples of how casts, explicit type definitions and implicit coercion compare to each other. And I also plan to create additional post (here and maybe also on my blog), to show how **Trivial_Numeric_Casts** can lead to bugs (I will not call it unexpected behavior anymore) next week.

    Open ##2272215