Generic dispatch through a supertrait emits an invalid evidence GEP #3

Closed
opened 2026-06-15 14:08:18 +02:00 by st · 0 comments
Owner

Repro

fn f[T: Int](a: T, b: T): T = Num.add(a, b)   // Num is Int's supertrait
fn main(): i64 = f(1, 2)

LLVM verification fails: Invalid indices for GEP pointer type!

%dict_slot_1 = getelementptr inbounds nuw { { ptr, ptr } }, ptr %evidence, i32 0, i32 1

The evidence struct for a T: Int constraint has one slot, but supertrait (Num) dispatch indexes slot 1.

Also hit by examples/supertraits.aml (same root cause).

Codegen area: evidence/vtable layout for constrained type params.

Repro ``` fn f[T: Int](a: T, b: T): T = Num.add(a, b) // Num is Int's supertrait fn main(): i64 = f(1, 2) ``` LLVM verification fails: Invalid indices for GEP pointer type! `%dict_slot_1 = getelementptr inbounds nuw { { ptr, ptr } }, ptr %evidence, i32 0, i32 1` The evidence struct for a T: Int constraint has one slot, but supertrait (Num) dispatch indexes slot 1. Also hit by examples/supertraits.aml (same root cause). Codegen area: evidence/vtable layout for constrained type params.
st closed this issue 2026-06-21 21:32:20 +02:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
st/amelie#3
No description provided.