Issue #2241: A block without -> T gets a row type the compiler writes from the row its grammar describes

Open and answer this issue on GitHub.

libraries, blocked, database · opened 2026-11-19 · updated 2026-11-22 · 0 comments

Goal

A dsl block without -> T gets a row type the compiler writes from the row its grammar describes (ADR-323 D3, D5; ADR-299 D2, D22). q.execute(db) then hands back rows with fields: u.name, u.a.id. This comes after the declared-struct form “dsl … -> T { … } eod” (#477), by the owner’s order of 2026-11-19: a program can read rows into its own struct first, and the type written from data comes last.

Part of #89 Needs #114 After #477

Governing decisions

Today

After #114, a statement block’s execute hands back Vec[db::Row], and --comptime shows the row and parameter types the grammar described. No row type is written. The conversion of a db::Row into a typed row and db::NullInField (packages/db/src/main.nika) are not used by the compiler.

To build

  1. The row struct. For a statement block without -> T, write a struct from the described row: one nested struct per namespace (a field whose type is a Record), and the short names one level down by D22’s rule. execute returns Vec[<that struct>]. Each block gets its own type. Test: tests/compiler/tests/a_blocks_rows_have_its_columns_as_fields.nika with .stdout. A stub grammar describes namespaces a { id: I64, name: Text, email: Maybe(Text) } and b { id: I64 }. A fake connection returns rows, and the program reads u.name, u.email ?? "-", u.a.id, u.b.id.
  2. The conversion (ADR-299 D8, D18). Each db::Row becomes the struct. A Null in a field that is not T? fails execute with db::NullInField, naming the field and the column. Test: tests/compiler/tests/a_null_in_a_field_that_is_no_option_fails_execute.nika with .stdout.
  3. The messages (D22, ADR-323 D4). u.id where a and b both have id is NK1107, with help naming u.a.id and u.b.id. u.emial is NK1107, naming the block’s line and the fields. A field two levels down read by its short name is NK1107, naming its full path. Test: tests/compiler/tests/a_shared_or_misspelled_column_names_the_ways.nika with .stderr.
  4. --comptime prints the written row type of each block, beside #114’s description.

Done when

for u in q.execute(db) { println(u.name) } builds and runs on a statement block without -> T. u.id over two namespaces with id is NK1107, and the help names both paths. The commit of item 3 carries Fixes #N. The report gives one Found: line per finding.

Files

The emitter’s statement path that #114 adds, check_fields.nika (field access on the written type), project_check.nika (item 4), and their lowered files. Not touched: packages/db, #477’s -> T path.

Back to Open Issues