✓
Passing Passing: the compiler rejects this program as expected.
Code
// PINS the refusal: `[layout(...)]` must name a layout the grid IMPLEMENTS.
//
// This is the same discipline as 697_009's `[unsafe(bonuds)]`, and it matters
// for a sharper reason here. A misspelled facet on `[unsafe]` waives nothing
// and leaves the program SAFE while reading as unsafe -- bad, but conservative.
// A misspelled LAYOUT leaves the grid on the layout you were trying to change,
// so the program keeps the performance characteristic the author believed they
// had just replaced, and the annotation sits in the source as evidence that the
// decision was made. Nothing about the program's behaviour reveals it: the
// results are identical either way (697_010), so only a measurement would ever
// catch it, and only if someone thought to take one.
//
// So an unrecognised layout is refused, and the diagnostic names both layouts
// the grid actually has rather than only rejecting the input.
//
// 697_010 pins the accepting side, including the explicit `[layout(column)]`
// spelling of the default.
import std/io
import std/grid
[layout(rwo)]std/grid:new(cells, size: 8) { v: 0[i64] }
std/io:print.ln("unreachable")
Actual compiler output
error[KORU161]: std/grid:new: `rwo` is not a layout this grid offers - it has `row` (one record per cell, for scatter) and `column` (one array per field, the default, for sweeps). A layout it does not implement is refused rather than ignored, because a misspelling would silently keep the layout you were trying to change
--> tests/regression/600_STDLIB/697_GRID/697_011_layout_must_name_a_layout/input.k:21:0Must contain:
is not a layout this grid offersFlows
flow ~new click a branch to expand · @labels scroll to their anchor
new (cells, size: 8, source: v: 0[i64])
flow ~print.ln click a branch to expand · @labels scroll to their anchor
print.ln (expr: "unreachable")
Test Configuration
MUST_ERROR