{"record":{"id":"14e8c79bd2d079b3","repo":"BoundaryML/baml","slug":"parse-named-args-list-none-for-name-of-field-missing-type","errorCode":null,"errorMessage":"parse_named_args_list:, none for name of field/missing type","messagePattern":"parse_named_args_list:, none for name of field/missing type","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"engine/baml-lib/ast/src/parser/parse_named_args_list.rs","lineNumber":101,"sourceCode":"                field_type: FieldType::Symbol(\n                    FieldArity::Required,\n                    Identifier::Local(\"Self\".to_string(), Span::fake()),\n                    None,\n                ),\n            });\n        }\n\n        match (name, r#type) {\n            (Some(name), Some(r#type)) => args.push((name, r#type)),\n            (Some(name), None) => diagnostics.push_error(DatamodelError::new_validation_error(\n                &format!(\n                    \"No type specified for argument: {name}. Expected: `{name}: type`\",\n                    name = name.name()\n                ),\n                name.span().clone(),\n            )),\n            (None, _) => {\n                unreachable!(\"parse_named_args_list:, none for name of field/missing type\")\n            }\n        }\n    }\n\n    BlockArgs {\n        documentation: None,\n        args,\n        span,\n    }\n}\n\npub fn parse_function_arg(\n    pair: Pair<'_>,\n    is_mutable: bool,\n    diagnostics: &mut Diagnostics,\n) -> Result<BlockArg, DatamodelError> {\n    assert!(\n        [Rule::field_type, Rule::field_type_chain].contains(&pair.as_rule()),","sourceCodeStart":83,"sourceCodeEnd":119,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/engine/baml-lib/ast/src/parser/parse_named_args_list.rs#L83-L119","documentation":"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.","triggerScenarios":"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.","commonSituations":"Hit with malformed function/config argument lists in .bml files that the grammar fails to reject, or after grammar edits that allow anonymous arguments.","solutions":["Give every named argument a name in your .bml file: `name: type` instead of `: type`","Isolate the offending argument list (function config, value block, etc.) and report the repro upstream","Use a BAML version whose grammar rejects nameless arguments before this point","If maintaining the parser, return a diagnostic instead of unreachable! for the (None, _) case"],"exampleFix":"// before\nfn F(arg: )  // or `: string`\n// after\nfn F(arg: string)","handlingStrategy":"validation","validationCode":"// Verify every named arg has a name before the colon\nfn named_args_ok(src: &str) -> bool {\n    !src.lines().any(|l| l.trim_start().starts_with(':'))\n}","typeGuard":"fn is_valid_named_arg(line: &str) -> bool {\n    match line.trim().split_once(':') {\n        Some((name, ty)) => !name.trim().is_empty() && !ty.trim().is_empty(),\n        None => false,\n    }\n}","tryCatchPattern":"std::panic::catch_unwind(|| parse_named_argument_list(pair, &mut diagnostics))\n    .map_err(|_| diagnostics.push(\"named argument without a name token\"));","preventionTips":["Always write `name: type` for arguments; never a leading colon","Prefer letting the BAML CLI produce diagnostics over raw parsing of suspect input","When the grammar allows anonymous args, handle them in the Some/Some match rather than unreachable!","Validate generated .bml (e.g. from codegen) before parsing"],"tags":["parser","rust","panic","named-args","internal-bug"],"backgroundTag":"internal-invariant-violation","analyzedSha":"bd85ce9dee1463ff04d27efd20531013a4ff46c1","analyzedAt":"2026-09-12T03:38:25.718Z","contentChangedAt":"2026-09-12T03:38:25.718Z","schemaVersion":2},"datasetVersion":"2026-09-14T11:17:12.474Z"}