emberjs/ember.js · error

Unexpected named block inside <:${name.chars}> named block:

Error message

Unexpected named block inside <:${name.chars}> named block: named blocks cannot contain nested named blocks

What it means

Named blocks cannot be nested inside other named blocks. When normalizing children of a `<:name>` block, any nested named block triggers this error because the yielded-block structure is flat.

Source

Thrown at packages/@glimmer/syntax/lib/v2/normalize.ts:939

  constructor(
    private el: BuildElement,
    loc: SourceSpan,
    children: (ASTv2.ContentNode | ASTv2.NamedBlock)[],
    block: BlockContext
  ) {
    super(loc, children, block);
  }

  assertNamedBlock(name: SourceSlice, table: BlockSymbolTable): ASTv2.NamedBlock {
    if (this.el.base.selfClosing) {
      throw generateSyntaxError(
        `<:${name.chars}/> is not a valid named block: named blocks cannot be self-closing`,
        this.loc
      );
    }

    if (isPresentArray(this.namedBlocks)) {
      throw generateSyntaxError(
        `Unexpected named block inside <:${name.chars}> named block: named blocks cannot contain nested named blocks`,
        this.loc
      );
    }

    if (!isLowerCase(name.chars)) {
      throw generateSyntaxError(
        `<:${name.chars}> is not a valid named block, and named blocks must begin with a lowercase letter`,
        this.loc
      );
    }

    if (
      this.el.base.attrs.length > 0 ||
      this.el.base.componentArgs.length > 0 ||
      this.el.base.modifiers.length > 0
    ) {
      throw generateSyntaxError(

View on GitHub (pinned to 26f97246a8)

Solutions

  1. Flatten the named blocks so each is a direct child of the component element.
  2. Use distinct top-level named block names instead of nesting.
  3. Extract an inner component if you need hierarchical block structure.

Example fix

// before
<Card><:body><:inner>x</:inner></:body></Card>

// after
<Card><:body>x</:body><:inner>y</:inner></Card>
Defensive patterns

Strategy: validation

Validate before calling

// Named blocks must be flat, one level deep.
function assertNoNestedNamedBlocks(namedBlock) {
  if (namedBlock.children.some(c => c.type === 'named-block')) {
    throw new Error(`Nested named block inside <:${namedBlock.name}>`);
  }
}

Prevention

When it happens

Trigger: Compiling a template like `<Card><:body><:inner>x</:inner></:body></Card>` — a `<:...>` block inside another `<:...>` block.

Common situations: Trying to group named blocks hierarchically; copy-paste nesting mistakes when composing deeply structured component APIs.

Related errors


AI-assisted analysis of emberjs/ember.js@26f97246a8 (2026-09-01). Data as JSON: /api/errors/58033c8b3c052ccd. Report an issue: GitHub.