Summary
On the harden-glue branch, roc build panics during specialization with:
postcheck invariant violated: tag pattern matched a non-tag value
I reduced this from roc-ray/examples/hello_world.roc to a fully standalone three-file app/platform. roc check passes for the same source; only roc build panics.
Version
Observed with:
branch: harden-glue
commit: a4febaa2d63dbe44ff194065f61b19838987f1ac
roc version: debug-6334a2ed
Minimal repro
Create these three files:
mkdir -p repro-tag-pattern/platform
cd repro-tag-pattern
app.roc
app [main!] { pf: platform "platform/main.roc" }
import pf.Draw
main! : () => Try({}, [Exit(I64), ..])
main! = || {
_offset = Draw.offset(Draw.align_left)
Ok({})
}
platform/main.roc
platform ""
requires {} { main! : () => Try({}, [Exit(I64), ..]) }
exposes [Draw]
packages {}
provides {
"render_for_host": render_for_host!,
}
hosted {}
targets: {
x64glibc: { inputs: [app] },
}
import Draw
render_for_host! : () => Try({}, I64)
render_for_host! = || {
match main!() {
Ok({}) => Ok({})
Err(Exit(code)) => Err(code)
Err(_) => Err(-1)
}
}
platform/Draw.roc
Draw := [].{
HAlign : [Left, Center, Right]
Align : {
horizontal : HAlign,
}
align_left : Align
align_left = { horizontal: Left }
offset : Align -> F32
offset = |align|
match align.horizontal {
Left => 0
Center => 1
Right => 2
}
}
Run:
roc check app.roc
roc build app.roc
Expected
roc build should not panic. If this platform is invalid for linking because it only supplies app as a target input, it should fail with a normal linker/platform error after lowering.
Actual
roc check app.roc passes.
roc build app.roc exits 134 and panics:
thread ... panic: postcheck invariant violated: tag pattern matched a non-tag value
src/postcheck/common.zig:82
src/postcheck/monotype_lifted/spec_constr.zig:2927 bindPatToValue
src/postcheck/monotype_lifted/spec_constr.zig:2351 simplifyKnownMatchValue
src/postcheck/monotype_lifted/spec_constr.zig:1609 cloneExprValue
src/postcheck/monotype_lifted/spec_constr.zig:1517 cloneExpr
src/postcheck/monotype_lifted/spec_constr.zig:914 writeSpecialization
src/postcheck/monotype_lifted/spec_constr.zig:493 createSpecializations
src/postcheck/monotype_lifted/spec_constr.zig:421 run
src/lir/checked_pipeline.zig:237 lowerCheckedModulesToLir
src/cli/main.zig:8244 rocBuildLlvm
Reduction notes
- This does not depend on the
roc-ray platform package.
- This does not depend on
hello_world.roc.
- This does not need hosted effects, raylib libraries,
Host, App, Draw.text!, or a model type.
- The minimal trigger appears to be specializing through the platform-provided wrapper while the app calls a function that matches on a tag field from a known record constant.
Summary
On the
harden-gluebranch,roc buildpanics during specialization with:I reduced this from
roc-ray/examples/hello_world.rocto a fully standalone three-file app/platform.roc checkpasses for the same source; onlyroc buildpanics.Version
Observed with:
Minimal repro
Create these three files:
mkdir -p repro-tag-pattern/platform cd repro-tag-patternapp.rocplatform/main.rocplatform/Draw.rocRun:
Expected
roc buildshould not panic. If this platform is invalid for linking because it only suppliesappas a target input, it should fail with a normal linker/platform error after lowering.Actual
roc check app.rocpasses.roc build app.rocexits 134 and panics:Reduction notes
roc-rayplatform package.hello_world.roc.Host,App,Draw.text!, or a model type.