Files
sx/issues/0155-scalar-pointer-index-llvm-panic.sx
agra 8367ad18b1 fibers: M:1 scheduler core + suspending fiber-task async (B1.5a, B1.4a)
library/modules/std/sched.sx: a generic Fiber + Scheduler over the
proven naked swap_context on guarded mmap stacks --
init/spawn/yield_now/suspend_self/wake/run (B1.5a), then Task($R) +
go/wait/cancel, a truly-suspending nullary-thunk async layer (B1.4a).
go(work) runs a thunk as a real fiber; wait() parks the caller until it
completes. Self-contained in sched.sx (io.sx importing it would
duplicate the _fib_tramp global asm).

Hardened per adversarial review: wake guarded on .suspended (FIFO
corruption), suspend_self/yield_now guard a null current, loud
mmap/mprotect/OOM/deadlock bails, cancel skips not-yet-run work.
Closure-env + heap-Task leaks documented (bounded, default-GPA-invisible).

Examples: 1811 (round-robin), 1812 (suspend/wake + spurious-wake guard),
1813 (async interleave + await-suspend + cancel). Also files issue 0155
(scalar-pointer index panics codegen -- non-blocking, found in review).
2026-06-21 18:44:03 +03:00

19 lines
937 B
Plaintext

// issue 0155 — indexing a pointer-to-scalar (`pc[0]` where `pc: *i64`) panics
// the compiler at LLVM emission instead of either lowering `pc[i]` like C
// (`*(pc + i)`) or emitting a clean diagnostic that `*T` is not indexable.
//
// Observed: `thread … panic: unresolved type reached LLVM emission`
// at src/backend/llvm/types.zig:196 (the `.unresolved` arm of
// toLLVMTypeInfo), reached via emitIndexGet
// (src/backend/llvm/ops.zig ~1988) → the index expression's element
// type resolves to `.unresolved` and is never diagnosed.
// Expected: either a working scalar-pointer index (`pc[0]` == `pc.*`) or a
// proper "cannot index a *T; use a slice / deref with .*" diagnostic.
// A `.unresolved` reaching LLVM is always a compiler bug.
#import "modules/std.sx";
main :: () -> i64 {
x : i64 = 5;
pc : *i64 = @x;
return pc[0]; // panics the compiler
}