apple/pkl · error · ParserError

missingDelimiter

missingDelimiter

Error message

Missing `}` delimiter.

What it means

When parsing a Pkl class body, the parser reached end-of-file (or a token that is not '}') without finding the closing '}' of the class. The parser first reports a dedicated error at EOF and otherwise fails expecting Token.RBRACE, both producing this missingDelimiter error at the position after the last token.

Source

Thrown at pkl-parser/src/main/java/org/pkl/parser/ParserImpl.java:435

    }
    children.add(body);

    return new Class(children, modifiersOffset, nameOffset, startSpan.endWith(end));
  }

  private ClassBody parseClassBody() {
    var start = expect(Token.LBRACE, "missingDelimiter", "{").span;
    var children = new ArrayList<Node>();
    while (lookahead != Token.RBRACE && lookahead != Token.EOF) {
      var entryHeader = parseMemberHeader();
      if (lookahead == Token.FUNCTION) {
        children.add(parseClassMethod(entryHeader));
      } else {
        children.add(parseClassProperty(entryHeader));
      }
    }
    if (lookahead == Token.EOF) {
      throw new ParserError(
          ErrorMessages.create("missingDelimiter", "}"), prev.span.stopSpan().move(1));
    }
    var end = expect(Token.RBRACE, "missingDelimiter", "}").span;
    return new ClassBody(children, start.endWith(end));
  }

  private ClassProperty parseClassProperty(MemberHeader header) {
    var name = parseIdentifier();
    var start = header.span(name.span());
    var children = new ArrayList<@Nullable Node>();
    children.add(header.docComment);
    children.addAll(header.annotations);
    var modifiersOffset = header.annotations.size() + 1;
    children.addAll(header.modifiers);
    var nameOffset = modifiersOffset + header.modifiers.size();
    TypeAnnotation typeAnnotation = null;
    Expr expr = null;
    var bodies = new ArrayList<ObjectBody>();

View on GitHub (pinned to f3efcbfc9b)

Solutions

  1. Add the missing closing '}' at the reported span (end of file or at the noted position)
  2. Count and balance braces in the class body; check that string interpolations "\(...)" are properly closed
  3. Recover the file from version control if it was truncated by a merge or failed write
  4. Use a Pkl editor/formatter to locate the unbalanced brace before the reported location

Example fix

// before
class Person {
  name: String
// after
class Person {
  name: String
}
Defensive patterns

Strategy: validation

Validate before calling

// quick brace balance sanity check before evaluating a .pkl file
long opens = content.chars().filter(c -> c == '{').count();
long closes = content.chars().filter(c -> c == '}').count();
if (opens != closes) throw new IllegalStateException("Unbalanced braces in " + path);

Try / catch

try {
  module = Module.loadSource(source);
} catch (ParserError e) {
  if (e.getErrorCode().equals("missingDelimiter")) {
    System.err.println("Missing '}' near " + e.getSpan() + "; check class/property braces");
  }
  throw e;
}

Prevention

When it happens

Trigger: Parsing a .pkl file whose class declaration is missing its closing brace — e.g. truncated file, an unclosed `{` after `class Foo {`, or a brace consumed by an earlier syntax error inside a property/method.

Common situations: Cut-off files from bad merges or incomplete saves, editors auto-inserting but user deleting braces, unbalanced braces in string interpolations or comments confusing counting, and nested class/amendment syntax mistakes.

Related errors


AI-assisted analysis of apple/pkl@f3efcbfc9b (2026-09-08). Data as JSON: /api/errors/dab67a8eb35cc5e5. Report an issue: GitHub.