Closed Feoramund closed 3 days ago
So I experimented with this before, but it might have too many false positives because of polymorphic procedures.
I think this might still have that problem but for nested procedures within polymorphic ones.
foo :: proc(x: $T) {
bar :: proc(x: T) {
... // this isn't a polymorphic procedure to the compiler, per se
}
}
So what might need to be done is check if the procedure's chain of parents is polymorphic anywhere and then disallow it.
I am going to merge this and then solve that specific problem.
This looks awesome. Thanks for figuring out the rest of it. :) The check for unneeded transmutes is really cool too.
This is a feature I've wanted for a while, and I think I've finally figured out how to get it working. I had to disable this check on polymorphic procedures, because the information that a type was originally polymorphic didn't seem to be stored anywhere, as far as I could find. (
is_type_polymorphic
wasn't working for me on the individual types, at least, but it did work on the contextual proc.)This should be a good feature for refactoring code when changing one type to another.
I would have done this for
transmute
too, but I saw the usage of a compile-time type-switching paradigm inbase:runtime/internal.odin
where__float16
is declared to be one type or another, and this was causing the identical transmute prevention to trigger. I wasn't sure what to do about that, so I left it as-is and didn't maketransmute
also check for identical types, for the time being until I get some feedback.