"On static platforms, null can't be used as basic type"

Hi,
I’m trying to use the haxe lib moon-ai.
I get the error when trying to build for flash “On static platforms, null can’t be used as basic type”.
for this code:

 var result:NeuronConnectionInfo =
        {
            type: null,
            connection: null,
        };

here is the hx file https://github.com/profound7/moon-ai/blob/master/src/moon/ai/neural/Neuron.hx
its on line 308

As you can see, type is an instance of NeuronConnectionType, and NeuronConnectionType is an Int. On statically-typed platforms (like Flash and C++), integers can’t be null.

You have two options here. Either set the default value to 0 (or one of the enum values), or modify NeuronConnectionInfo to allow null values.

private typedef NeuronConnectionInfo =
{
    var type:Null<NeuronConnectionType>;
    var connection:NeuronConnection;
}
1 Like

thank you :grinning: