Issue #2801: catch value of a String-returning call: handler arms stay Text, value arm is EitherText (NK1343)

Open and answer this issue on GitHub.

ready · opened 2026-11-23 · updated 2026-11-23 · 0 comments

Found

A catch used as a value, on a call whose function returns String throws, yields a block Text from its handler while the success arm is the function’s EitherText. rustc refuses the generated match and the user sees NK1343.

Probe

use std::io

fn refuse(word: String) -> String throws {
	if word == "x" { throw io::IoError::NotText("not text") }
	return word
}

fn main() throws {
	for word in ["x", "ok"] {
		let got = refuse(word) catch {
			match error {
				io::IoError::NotText(message) => f"not text: {message}",
				else => "else",
			}
		}
		println(got)
	}
}

Generated (block types):

let got = match refuse(word) {
    Ok(value) => value,                       // EitherText<'_>
    Err(error) => { let (error, __nikaia_site) = error.split(); match error {
        io::IoError::NotText(ref message) => format!("not text: {}", message),
        _ => nikaia_std::block::Text::from("else"),   // Text
    } },
};

rustc: E0308: match arms have incompatible types … expected EitherText<'_>, found Text.

To build

Done when

The probe runs and prints both lines in both settings.

Found while testing the fix of the io::IoError text payloads on block types (ADR-327 D8); that test (ioerror_text_payload) prints inside each arm instead, so it does not depend on this.

Back to Open Issues