Generics with floating value types

For an application/library I’m writing (in vala) I’ve come up against some error regarding generics I can’t really explain. I have a generic struct

public struct Parameter { T value; }

For most types there is no problem specialising the is e.g.

public struct Integer : Parameter { Integer(int val) { this.value = val; } }
public struct String : Parameter { String(string val) { this.value = val; } }

both work fine. However when using double or float it doesn’t work

public struct Double : Paramter { Double(double val) { this.value = val; } }

This result in the error

error: incompatible types when assigning to type ‘gpointer’ {aka ‘void *’} from type ‘gdouble’ {aka ‘double’}

BTW using vala 0.56.13 on Fedora 38.

This is probably a Vala bug. It would be good if you create a minimal reproducer code snippet and open an issue here. For a quick fix using float? (nullable) instead might work.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.