You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Opaque types used in struct fields pass check but fail at codegen as unsized types #42
A program can pass with check, but fail during with run when a struct contains a field of an opaque type.
Minimal repro:
type Handle = opaque
type Wrapper = {
h: Handle,
}
fn main:
let w = Wrapper { h: 0 as Handle }
let _ = w
Commands:
with check /tmp/opaque_field.w
with run /tmp/opaque_field.w
with check output:
ok
with run fails in LLVM verification with errors like:
LLVM verify error: Cannot allocate unsized type
%0 = alloca %Wrapper, align 8
...
storing unsized types is not allowed
...
GEP into unsized type!
...
error: code generation failed
error: run failed
Expected behavior
An opaque handle type should be usable as a field inside ordinary structs. This is a standard handle-wrapper pattern.
If opaque is intentionally not storable in structs, that should be rejected during semantic analysis with a clear diagnostic. But it should not pass with check and then fail in LLVM verification.
Why this matters
The spec explicitly uses opaque handles for runtime resources and c_import emits forward declarations as type Name = opaque. Users need to be able to wrap those handles inside normal value types without hitting backend verification failures.
Activity
ehartford commentedon Mar 23, 2026
Closed by commit 0366e82.