Open mdwagner opened 9 months ago
Reduced:
lib Lib
type Foo = Int32*
end
x = Pointer(Int32).new(0x1234_u64).as(Lib::Foo)
x.value # pointer_get
x.value = 1 # pointer_set
Some other related pointer primitives break in normal codegen too:
lib Lib
type Foo = Int32*
end
x = Pointer(Int32).new(0x1234_u64).as(Lib::Foo)
x + 1_i64 # pointer_add
x - x # pointer_diff
x.realloc(8_u64) # pointer_realloc
# pointer_malloc has the same issue, but that is fine because
# typedefs cannot access the original type's class methods
That said, type
should only be used for opaque types, so if you find yourself expecting that a TokenAttrT
can be dereferenced to a TokenAttr
, maybe those types aren't so opaque after all?
Bug Report
First discovered in lexbor shard when trying out interpreter, these Lib bindings fail to run:
Error message:
However, if I replace
type
withalias
, it works:Crystal version:
Crystal interpreter version:
OS: Fedora 39 x86_64