SomeRanDev / reflaxe

Haxe framework for creating compilation targets using macros
MIT License
91 stars 4 forks source link

Fix NullTypeEnforcer simplifying dynamic null comparisons #14

Closed fourst4r closed 7 months ago

fourst4r commented 7 months ago

Because null is a valid value for Dynamic, even in strict null safety mode.

fourst4r commented 7 months ago

Hmmm, I just realized this also means type parameters can be null as well without specifying Null<T>.

function main() {
    foo(null);
}

function foo<T>(t:T) {
    trace(t);
}
SomeRanDev commented 7 months ago

Hmmm yeah, this is complicated. The goal of this code is to avoid comparisons with null on platforms where null comparisons should only occur on types specifically set to be nullable.

For example, in Reflaxe/C++, there are instances where I use Dynamic to represent an unknown C++ type (which cannot be compared to null since there's no guarantee it's wrapped in std::optional). Really wish there was an official Untyped type...

With that said, this doesn't seem to break my current project using Reflaxe/C++, and all the Reflaxe/C++ tests pass, so let's do it! I definitely need to clean this code up a bit too, but this should be fine for now.