#3414

readline: named stdin/stdout imports not recognized as createInterface input/output

Openespetroopened 4d ago

Summary

createInterface({ input: stdin, output: stdout }) where stdin/stdout are named imports (import { stdin, stdout } from 'node:process') compiles but throws at runtime:

Uncaught Error: createInterface with an input that is not a readable stream has no lowering [SC2020]

The literal member forms (process.stdin, process.stdout) work. This is exactly the shape @clack/prompts ships (import { stdout, stdin } from 'node:process' in @clack/core), so interactive prompts remain blocked by it.

Cause

packages/compiler/src/frontend/lowering/builtins/readline.ts: lowerInput (~line 1272) only fast-paths the process.stdin member expression; lowerOutput handles process.stdout/process.stderr. A named-import binding falls through to streamFromDyn, whose stream-shape check fails → SC2020 fence.

Reproduction

import { createInterface } from "node:readline";
import { stdin, stdout } from "node:process";
const rl = createInterface({ input: stdin, output: stdout });
rl.question("q? ", (a) => { console.log("got", a); rl.close(); });

echo alice | ./binary → SC2020 (before fix). Verified on main (d4c82a5c3), darwin-arm64. A PR is underway.

Activity

0

No activity yet.