An arrow function whose body is a conditional expression over two void calls trips an internal compiler error. The diagnostic asks for a report, so here it is.
Repro
export {}
function a(): void {
console.log('a')
}
function b(): void {
console.log('b')
}
function main() {
const flag = process.argv.length > 99
const pick = (n: number) => (flag ? a() : b())
pick(1)
}
main()
$ bun void3.ts
b
$ scriptc build void3.ts -o void3
void3.ts:10:32 - error SC9001: internal compiler error: in %fn0: ternary must not be void — please report this
9 | const flag = process.argv.length > 99
10 | const pick = (n: number) => (flag ? a() : b())
| ^~~~~~~~~~~~~~~~
11 | pick(1)
1 error.
Workaround
A block body with if/else compiles and behaves correctly:
const pick = (n: number) => {
if (flag) a()
else b()
}
Note
void-returning arrow bodies are documented as supported (SC1090's hint for void in value position says "void-returning arrow bodies compile"), so the conditional form looks like a gap in the same path rather than an intentional refusal.
Encountered while porting a real CLI; the shape was (value) => cond ? emitA(value) : emitB(value) over two functions returning void.
Environment
- scriptc 0.0.17,
@scriptc/compiler 0.0.17
- macOS 26.5.2, arm64, Node v24.18.0
- Reproduces on both static and
--dynamic builds
An arrow function whose body is a conditional expression over two
voidcalls trips an internal compiler error. The diagnostic asks for a report, so here it is.Repro
Workaround
A block body with
if/elsecompiles and behaves correctly:Note
void-returning arrow bodies are documented as supported (SC1090's hint forvoidin value position says "void-returning arrow bodies compile"), so the conditional form looks like a gap in the same path rather than an intentional refusal.Encountered while porting a real CLI; the shape was
(value) => cond ? emitA(value) : emitB(value)over two functions returningvoid.Environment
@scriptc/compiler0.0.17--dynamicbuilds