f(x; ..s, name: v) (ADR-call-spread-v1 D2, D3)Open and answer this issue on GitHub.
ready · opened 2026-11-21 · updated 2026-11-21 · 0 comments
Part of #449 (subcommands of main, option A).
After #2636 (tuple spread in a call): the spread node and NK1355 come from there.
Decision: ADR-call-spread-v1 D2, D3 and D4; Part I 5.1.
struct Opts {
verbose: bool = false,
depth: int = 1,
}
fn show(file: String; verbose: bool = false, depth: int = 1) {
println(f"{file} {verbose} {depth}")
}
fn main() {
let o = Opts { verbose: true }
show("areas.md"; ..o, depth: 3)
}
Today:
error: Expected identifier here, but found `.`.
--> structopt.nika:12:22
areas.md true 3. ..s after the ; spreads the struct s into the options field by field (D2); an option of the function with no field of that name takes its default; a name written beside the spread wins over the field, wherever it stands (D3). A field with no option of that name is NK1109 (unknown option), naming the field and the struct; a field of the wrong type is NK1102. A second .. after the ;, or ..v of a value that is not a struct, is NK1355. The struct is evaluated once.
crates/nikaia/src/parser/mod.rs, rules config_args / config_arg / bare_config_args: an element may be ".." e:expr; ConfigArg in ast.nika (around line 1282) gets that form (e.g. ConfigArg::Spread { value } beside ConfigArg { name, value }, or a separate optional field on Expr::Call). Test call_spread_struct_into_options.nika + .stdout (the probe).check_core_args.nika (check_core_args_named and the option matching; also the NK1109 sites in check_core_call_on.nika and check_core_pilot.nika if they match options): expand the struct to name: s.name for each field not written beside it, then check as written. Tests: call_spread_struct_written_name_wins.nika + .stdout (written before and after the spread), call_spread_struct_unknown_field.nika + .stderr (NK1109), call_spread_struct_wrong_field_type.nika + .stderr (NK1102), call_spread_struct_twice.nika + .stderr (NK1355), call_spread_tuple_after_semicolon.nika + .stderr (NK1355: a tuple after the ;).__s.field for each spread option. Test call_spread_struct_evaluated_once.nika + .stdout.The tests pass, the call tests stay green; step 4’s commit carries Fixes #N; gaps are Found: lines.
Files: crates/nikaia/src/parser/mod.rs (Rust: the grammar’s only home; report the lines for #557 / #125), ast.nika, check_core_args.nika, the call emitter, Part III 30, tests in tests/compiler/tests/.
Facts: nikaia test --filter call_spread from tests/compiler.
Ruled out: a struct spread into positional arguments (D1 is tuples only); a spread that also fills options of a nested struct (not decided); filling a missing option from anything but its default.