Skip to content

Treat negative integer/float ranks as non-compatible

Val Och requested to merge v19930312/vala:negative-integer-rank into main

This allows to improve type safety for handle types.

For example, in OpenGL bindings I have:

	[CCode (cheader_filename = "epoxy/gl.h", cname = "GLuint", default_value = "0", has_type_id = false)]
	[IntegerType (rank = -1)]
	public struct BufferHandle {
	}
	[CCode (cheader_filename = "epoxy/gl.h", cname = "GLuint", default_value = "0", has_type_id = false)]
	[IntegerType (rank = -1)]
	public struct DisplayListHandle {
	}
	[CCode (cheader_filename = "epoxy/gl.h", cname = "GLuint", default_value = "0", has_type_id = false)]
	[IntegerType (rank = -1)]
	public struct FramebufferHandle {
	}

This ensures that function accepting a specific handle type won't accept different ones, while still allowing to explicitly cast to other integer types and assign from integer literals.

Merge request reports