BoundaryML/baml · error

parse_named_args_list:, none for name of field/missing type

Error message

parse_named_args_list:, none for name of field/missing type

What it means

An unreachable!("parse_named_args_list:, none for name of field/missing type") in parse_named_argument_list. When resolving a named argument the code matches on (name, type) optionality; the (None, _) arm — no name but possibly a type — is assumed impossible because the grammar requires a name for every named argument. Reaching it is a grammar/parser mismatch bug.

Source

Thrown at engine/baml-lib/ast/src/parser/parse_named_args_list.rs:101

                field_type: FieldType::Symbol(
                    FieldArity::Required,
                    Identifier::Local("Self".to_string(), Span::fake()),
                    None,
                ),
            });
        }

        match (name, r#type) {
            (Some(name), Some(r#type)) => args.push((name, r#type)),
            (Some(name), None) => diagnostics.push_error(DatamodelError::new_validation_error(
                &format!(
                    "No type specified for argument: {name}. Expected: `{name}: type`",
                    name = name.name()
                ),
                name.span().clone(),
            )),
            (None, _) => {
                unreachable!("parse_named_args_list:, none for name of field/missing type")
            }
        }
    }

    BlockArgs {
        documentation: None,
        args,
        span,
    }
}

pub fn parse_function_arg(
    pair: Pair<'_>,
    is_mutable: bool,
    diagnostics: &mut Diagnostics,
) -> Result<BlockArg, DatamodelError> {
    assert!(
        [Rule::field_type, Rule::field_type_chain].contains(&pair.as_rule()),

View on GitHub (pinned to bd85ce9dee)

Solutions

  1. Give every named argument a name in your .bml file: `name: type` instead of `: type`
  2. Isolate the offending argument list (function config, value block, etc.) and report the repro upstream
  3. Use a BAML version whose grammar rejects nameless arguments before this point
  4. If maintaining the parser, return a diagnostic instead of unreachable! for the (None, _) case

Example fix

// before
fn F(arg: )  // or `: string`
// after
fn F(arg: string)
Defensive patterns

Strategy: validation

Validate before calling

// Verify every named arg has a name before the colon
fn named_args_ok(src: &str) -> bool {
    !src.lines().any(|l| l.trim_start().starts_with(':'))
}

Type guard

fn is_valid_named_arg(line: &str) -> bool {
    match line.trim().split_once(':') {
        Some((name, ty)) => !name.trim().is_empty() && !ty.trim().is_empty(),
        None => false,
    }
}

Try / catch

std::panic::catch_unwind(|| parse_named_argument_list(pair, &mut diagnostics))
    .map_err(|_| diagnostics.push("named argument without a name token"));

Prevention

When it happens

Trigger: parse_named_argument_list processing a named-args block where a field has a type annotation but the name token failed to parse into Some(name), e.g. a degenerate `: type` entry the grammar accepted.

Common situations: Hit with malformed function/config argument lists in .bml files that the grammar fails to reject, or after grammar edits that allow anonymous arguments.

Understand the failure class

Background: "This is a bug, please report it": internal invariant violations, unreachable panics, and SNH errors explained — this error's family across 47 libraries.

Related errors


AI-assisted analysis of BoundaryML/baml@bd85ce9dee (2026-09-12). Data as JSON: /api/errors/14e8c79bd2d079b3. Report an issue: GitHub.