Skip to main content
NM-RFC-0007

Typed function results and program errors

Design document · English reading edition

RFCs record designs and changes. A proposal appearing here does not mean its feature is ready to use. Explore current language support

Status recorded in the original: Runtime experimental

Bound original source · SHA-256
d549c3cc10b1b87728de722a5325a1313fa1e79ed579ee2d61090ae3765707da

Reading edition reviewed: 2026-10-02

Purpose and scope

Separates a program's own outcome from successful engine execution. An error deliberately returned by user code is different from a parser or simulator failure.

Core design rules

  • The entry function can return a value or symbolic error through a bounded Result<T, Error> contract.
  • The payload of ok(...) must match the declared return type.
  • Engine success and program outcome are reported separately; a program error is not labeled an engine failure.

Example from the original

This example illustrates the design recorded in the original. It is not by itself a claim of executable or stable support; check required options and the current version.

nm
module typed_result;

fn main() -> Result<Int, Error> {
  let q = qreg[1];
  let measured: Bit = measure(q[0]);
  let encoded: Int = bit_to_int(measured);
  return ok(encoded);
}

Limits and interpretation

  • Arbitrary exceptions, general error objects and unchecked return payloads are outside the scope.
  • Result recovery in classical helpers does not automatically extend this historical entry-function slice.

Status and implementation boundary

The source describes a runtime-experimental result contract. Check NM-RFC-0035 and the corresponding guides for the boundaries of later helper-function additions.

Table 1
Review topicInformation to check
Source revisionSHA-256 digest bound to this reading edition
AvailabilityCurrent capability record and tool options
Evidence boundaryModel, size and interpretation limits above