✓
Passing Passing: the compiler rejects this program as expected.
Code
// Single-entry records collapse to the scalar everywhere `->` PRODUCES a value:
// legal is `-> i64` or `-> { a, b, ... }`, never `-> { a }`. This pins the rule
// in the BARE-RETURN produce position — the sibling of 210_063's branch-payload
// rejection. A one-field record return must be guided to the scalar `-> i64`;
// the multi-field record return (241/242) is the legal form. The single-field
// event INPUT payload (`{ strict: bool }`) is exempt and stays legal.
import std/io
pub tor config { strict: bool } -> { a: i64 }
config = if(strict)
| then -> { a: 1 }
| else -> { a: 0 }
config(strict: true): r |> std/io:print.ln("{{ r.a:d }}")
Actual compiler output
error[PARSE003]: single field in record return `{ a: i64 }` — collapse to the scalar `-> <type>`; a record return is for two or more fields
--> tests/regression/200_COMPILER_FEATURES/210_PARSER/210_149_reject_single_field_bare_return_record/input.k:8:1
|
8 | pub tor config { strict: bool } -> { a: i64 }
| ^Must fail at frontend compile:
Parsing or type-checking must reject the program.
Error output must contain
single fieldTest Configuration
MUST_ERROR