{"record":{"id":"4b8f593d4620eff6","repo":"BoundaryML/baml","slug":"unexpected-infix-operator","errorCode":null,"errorMessage":"Unexpected infix operator: {:?}","messagePattern":"Unexpected infix operator: (.+?)","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"engine/baml-lib/ast/src/parser/parse_expression.rs","lineNumber":154,"sourceCode":"                Rule::NEQ => BinaryOperator::Neq,\n                Rule::LT => BinaryOperator::Lt,\n                Rule::LTEQ => BinaryOperator::LtEq,\n                Rule::GT => BinaryOperator::Gt,\n                Rule::GTEQ => BinaryOperator::GtEq,\n                Rule::ADD => BinaryOperator::Add,\n                Rule::SUB => BinaryOperator::Sub,\n                Rule::MUL => BinaryOperator::Mul,\n                Rule::DIV => BinaryOperator::Div,\n                Rule::MOD => BinaryOperator::Mod,\n                Rule::BIT_AND => BinaryOperator::BitAnd,\n                Rule::BIT_OR => BinaryOperator::BitOr,\n                Rule::BIT_XOR => BinaryOperator::BitXor,\n                Rule::BIT_SHL => BinaryOperator::Shl,\n                Rule::BIT_SHR => BinaryOperator::Shr,\n                Rule::OR => BinaryOperator::Or,\n                Rule::AND => BinaryOperator::And,\n                Rule::INSTANCE_OF => BinaryOperator::InstanceOf,\n                _ => unreachable!(\"Unexpected infix operator: {:?}\", operator.as_rule()),\n            };\n\n            Some(Expression::BinaryOperation {\n                left: Box::new(left?),\n                operator,\n                right: Box::new(right?),\n                span: span.clone(),\n            })\n        });\n\n    parser.parse(token.into_inner())\n}\n\nfn parse_primary_expression(\n    token: Pair<'_>,\n    diagnostics: &mut internal_baml_diagnostics::Diagnostics,\n) -> Option<Expression> {\n    let span = diagnostics.span(token.as_span());","sourceCodeStart":136,"sourceCodeEnd":172,"githubUrl":"https://github.com/BoundaryML/baml/blob/bd85ce9dee1463ff04d27efd20531013a4ff46c1/engine/baml-lib/ast/src/parser/parse_expression.rs#L136-L172","documentation":"This is a `unreachable!()` panic in `parse_raw_string` in the BAML AST parser. After looping over the children of a `raw_string_literal` pair, the function asserts it captured a `(content, span)` tuple; reaching the fallback means no child assigned content — the raw-string grammar produced a node with no recognized content token, breaking the grammar/parser contract. It indicates the raw string literal parsed to an empty/unrecognized shape.","triggerScenarios":"Parsing a raw string literal (e.g. `#\"...\"#`) whose `raw_string_literal` pair contains only rules not matched inside the loop — possible after a grammar change to the raw-string rules without updating `parse_raw_string`, or a zero-child raw_string_literal pair.","commonSituations":"Using raw string syntax with unusual hash counts or delimiters in a BAML version where raw-string lexing changed; contributors editing baml.pest raw_string_literal rules without updating the parser; corrupted/empty string token reaching the parser.","solutions":["Rewrite the raw string using standard BAML raw-string syntax (`#\"text\"#`) with balanced delimiters","Replace the raw string with a regular quoted string or template string if the escaping allows it","Check the BAML source at the panic span for a truncated or malformed raw string and fix the delimiters","If you are a contributor: extend `parse_raw_string`'s loop to handle all child rules of `raw_string_literal` in baml.pest"],"exampleFix":"// before (malformed raw string)\nlet s #\"unterminated\n// after\nlet s #\"terminated\"#","handlingStrategy":"validation","validationCode":"// Validate raw string delimiters are balanced before parsing:\nfunction assertBalancedRawString(src) {\n  const opens = (src.match(/#\"/g) || []).length;\n  const closes = (src.match(/\"#/g) || []).length;\n  if (opens !== closes) {\n    throw new Error(`Unbalanced raw string delimiters will crash the BAML parser: ${src}`);\n  }\n}","typeGuard":"const isWellFormedRawString = (s) => /^#\"[\\s\\S]*\"#$/.test(s.trim());","tryCatchPattern":"catch (panicOutput) {\n  if (String(panicOutput).includes('Encountered impossible raw string')) {\n    logParserBug('raw_string_literal yielded no content', panicOutput);\n    return null;\n  }\n  throw panicOutput;\n}","preventionTips":["Always close raw strings with the matching `\"#` delimiter","Prefer plain quoted strings when escaping is trivial","Update parse_raw_string whenever raw_string_literal rules change in baml.pest","Add parser tests for empty and multi-hash raw strings"],"tags":["parser","panic","raw-string","rust"],"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-14T05:17:10.506Z"}