Passing a ternary (?:) string expression directly to an extern function's string implicit parameter crashes the compiler with SIGSEGV (at address ~0x5f), at compile time — the function does not need to be called.
Minimal repro
options gen2
require llvm/daslib/llvm_boost
def make(b : LLVMOpaqueBuilder?; v : LLVMOpaqueValue?; t : LLVMOpaqueType?; i : int) {
return LLVMBuildBitCast(b, v, t, i == 0 ? "a" : "b")
}
[export]
def main {
print("compiled\n")
}
bin/daslang repro.das → CRASH: SIGSEGV (Segmentation fault) (signal 11) at address 0x5f
The callee here is dasLLVM's raw binding:
[extern(cdecl, name="LLVMBuildBitCast", library="LLVM.dll")]
def LLVMBuildBitCast(... ; Name : string implicit) : LLVMOpaqueValue? {}
Variants matrix
| Name argument |
Result |
i == 0 ? "a" : "b" (ternary, two literals) |
CRASH |
i == 0 ? "a" : "a{i}" (ternary + interpolation) |
CRASH |
"a{i}" (plain interpolation, no ternary) |
compiles |
let nm = i == 0 ? "a" : "b" then pass nm |
compiles |
same ternary into a plain das function taking name : string |
compiles |
So the trigger is specifically an ExprOp3 string result flowing into a string implicit extern parameter; hoisting the ternary into a local is the workaround.
Side effect: the daslang MCP server's compile_check also SIGSEGVs on any file containing the pattern (same root, it just compiles the file).
Found while writing the dasLLAMA GEMM generator (emit_block_mx4, kernel-gen branch); the one hit site there is hoisted with a comment pointing here.
Passing a ternary (
?:) string expression directly to an extern function'sstring implicitparameter crashes the compiler with SIGSEGV (at address ~0x5f), at compile time — the function does not need to be called.Minimal repro
bin/daslang repro.das→CRASH: SIGSEGV (Segmentation fault) (signal 11) at address 0x5fThe callee here is dasLLVM's raw binding:
Variants matrix
i == 0 ? "a" : "b"(ternary, two literals)i == 0 ? "a" : "a{i}"(ternary + interpolation)"a{i}"(plain interpolation, no ternary)let nm = i == 0 ? "a" : "b"then passnmname : stringSo the trigger is specifically an
ExprOp3string result flowing into astring implicitextern parameter; hoisting the ternary into a local is the workaround.Side effect: the daslang MCP server's
compile_checkalso SIGSEGVs on any file containing the pattern (same root, it just compiles the file).Found while writing the dasLLAMA GEMM generator (
emit_block_mx4, kernel-gen branch); the one hit site there is hoisted with a comment pointing here.