Skip to content

Commit 887ff5a

Browse files
committed
Fix LLVMPtr subtyping
1 parent 38d24e5 commit 887ff5a

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

src/jltypes.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2739,8 +2739,9 @@ void jl_init_types(void) JL_GC_DISABLED
27392739
jl_pointer_typename = ((jl_datatype_t*)jl_unwrap_unionall((jl_value_t*)jl_pointer_type))->name;
27402740

27412741
// LLVMPtr{T, AS} where {T, AS}
2742-
tv = jl_svec2(tvar("T"), tvar("AS"));
2743-
jl_svec_t *tv_base = jl_svec1(tvar("T"));
2742+
jl_tvar_t *elvar = tvar("T");
2743+
tv = jl_svec2(elvar, tvar("AS"));
2744+
jl_svec_t *tv_base = jl_svec1(elvar);
27442745
jl_llvmpointer_type = (jl_unionall_t*)
27452746
jl_new_primitivetype((jl_value_t*)jl_symbol("LLVMPtr"), core,
27462747
(jl_datatype_t*)jl_apply_type((jl_value_t*)jl_ref_type, jl_svec_data(tv_base), 1), tv,

test/llvmcall.jl

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,5 +264,7 @@ MyStruct(kern) = MyStruct(kern, reinterpret(Core.LLVMPtr{UInt8,1}, 0))
264264
MyStruct() = MyStruct(0)
265265
s = MyStruct()
266266

267+
# ensure LLVMPtr properly subtypes
268+
@test eltype(supertype(Core.LLVMPtr{UInt8,1})) <: UInt8
267269
@test s.kern == 0
268270
@test reinterpret(Int, s.ptr) == 0

0 commit comments

Comments
 (0)