Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Null safety project support #50

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

kyubuns
Copy link

@kyubuns kyubuns commented Jun 7, 2020

class Main {
    static function main() {
        trace((new hxbit.Serializer()).serialize(new Hoge([1,2,3])).toHex());
    }
}

class Hoge implements hxbit.Serializable {
    public function new(fuga: Array<Int>) {
        this.fuga = fuga;
    }

    @:s public var fuga: Array<Int>;
}
-main Main
-lib hxbit
--interp
--macro nullSafety("Main", Strict)
> haxe build.hxml
Main.hx:12: characters 6-34 : Null safety: Cannot assign nullable value here.

I want to use nullSafety in my project.
-D hxbit_nullsafety flag, Initialize with the default value, not null.

@ncannasse
Copy link
Member

That's not a correct fix. I think instead the correct type should be Null<Array> and then additional fixes in macro to be able to assign nullables to not nullable field (which would then alloc empty array)

@kyubuns
Copy link
Author

kyubuns commented Jun 8, 2020

Sounds good!

As an aside, I discovered this bug when I tried to Serialize Null in the same way.
HaxeFoundation/haxe#9544

This is the problem with this line.
https://github.com/HeapsIO/hxbit/blob/master/hxbit/Macros.hx#L463

@Beeblerox Beeblerox mentioned this pull request Jun 11, 2020
1 task
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants