Skip to content

Default values not always correct #12311

@Aidan63

Description

@Aidan63

Several places in the coroutine branch use Texpr.Builder.default_value to get a default value for a type, the problem with this function is that it often gives default values which aren't correct. There are two main things it gets wrong.

  • Many targets have core type abstracts which represent properly sized integer types, default_value returns null for these which is not correct.
  • haxe.Int64 gets a default value of null, which is fine for some targets, but not targets which use a native 64 bit int.

The easiest solution would be to add a bunch of cases for all these known target specific types so they get reasonable default values, as well as pulling in some sort of context so we can check the target and return a appropriate Int64 default value.

Maybe a better solution to prevent an ever growing list of types would be some sort of defaultValue metadata, e.g. @:defaultValue(Int64.ofInt(0))? That would require default_value to do typing though.

Alternatively do nothing and have the coroutine branch attempt to deal with it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions