lang F1 2.7: pack-as-value diagnostics (Phase 2 complete)

Using a bare pack name where a runtime value is required was silent garbage
(f(xs)/return xs produced a stray pointer). Now a clear, context-tailored
compile error: isPackName + diagPackAsValue, caught at lowerVarDecl (storage),
lowerReturn (return), lowerFor (iterate), and an identifier-arm catch-all for
call/other. Storage binds a placeholder so there is no cascade error.

Suggestions point at WORKING fixes -- materialize (..xs), or declare the slice
form ..xs: []P for runtime use. The plan category-B "spread ..xs" is broken
(spreading a comptime pack into a []Any param crashes the LLVM verifier; filed
issue 0053), so the diagnostics steer to the slice-of-protocol variadic instead.

Repurposed examples/162-pack-bare-args.sx (was an aspirational bare-$args->[]Any
auto-materialise, contradicting Decision 1) into the slice-form forward
(..args: []Any). examples/203 is the four-category negative test. specs.md "Pack
as value" updated. 238 examples + unit green.
This commit is contained in:
agra
2026-05-30 02:09:41 +03:00
parent ab572359ae
commit 8a875d354c
7 changed files with 197 additions and 20 deletions

View File

@@ -0,0 +1 @@
1

View File

@@ -0,0 +1,43 @@
error: pack 'xs' has no runtime value — a pack is comptime-only and can't be used as a value here
--> /Users/agra/projects/sx/examples/203-pack-as-value.sx:14:40
|
14 | storage :: (..xs: Show) -> void { y := xs; _ = y; } // A: store
| ^^
help: to store it, materialize a tuple: `(..xs)`
|
14 | storage :: (..xs: Show) -> void { y := xs; _ = y; } // A: store
| ^^
error: pack 'xs' has no runtime value — a pack is comptime-only and can't be used as a value here
--> /Users/agra/projects/sx/examples/203-pack-as-value.sx:15:40
|
15 | call :: (..xs: Show) -> void { sink(xs); } // B: pass to a call
| ^^
help: materialize a tuple `(..xs)` to store it, or declare `xs` as a slice variadic `..xs: []P` for runtime use instead of a pack `..xs: P`
|
15 | call :: (..xs: Show) -> void { sink(xs); } // B: pass to a call
| ^^
error: pack 'xs' has no runtime value — a pack is comptime-only and can't be used as a value here
--> /Users/agra/projects/sx/examples/203-pack-as-value.sx:16:42
|
16 | ret :: (..xs: Show) -> s64 { return xs; } // C: return
| ^^
help: to return it, return a tuple `(..xs)` and make the return type that tuple
|
16 | ret :: (..xs: Show) -> s64 { return xs; } // C: return
| ^^
error: pack 'xs' has no runtime value — a pack is comptime-only and can't be used as a value here
--> /Users/agra/projects/sx/examples/203-pack-as-value.sx:17:39
|
17 | iter :: (..xs: Show) -> void { for xs : (x) { _ = x; } } // D: runtime iterate
| ^^
help: to iterate at comptime use `inline for 0..xs.len (i)`; for a runtime loop declare it as `..xs: []P` (a protocol slice) instead of a pack
|
17 | iter :: (..xs: Show) -> void { for xs : (x) { _ = x; } } // D: runtime iterate
| ^^