mozilla/pdf.js · error · FormatError
PostScript function: a procedure block must be followed by '
Error message
PostScript function: a procedure block must be followed by 'if' or '{…} ifelse'. What it means
Error "PostScript function: a procedure block must be followed by 'if' or '{…} ifelse'." thrown in mozilla/pdf.js.
Source
Thrown at src/core/postscript/ast.js:294
break;
case TOKEN.lbrace: {
// Start of a sub-procedure: must be followed by 'if' or '{ } ifelse'.
this._advance();
const thenBlock = this._parseBlock();
this._expect(TOKEN.rbrace);
if (this._token.id === TOKEN.if) {
this._advance();
instructions.push(new PsIf(thenBlock));
} else if (this._token.id === TOKEN.lbrace) {
this._advance();
const elseBlock = this._parseBlock();
this._expect(TOKEN.rbrace);
this._expect(TOKEN.ifelse);
instructions.push(new PsIfElse(thenBlock, elseBlock));
} else {
throw new FormatError(
"PostScript function: a procedure block must be followed by 'if' or '{…} ifelse'."
);
}
break;
}
case TOKEN.rbrace:
case TOKEN.eof:
// End of this block; let the caller consume the '}'.
return new PsBlock(instructions);
case TOKEN.if:
case TOKEN.ifelse:
// 'if'/'ifelse' without a preceding block.
throw new FormatError(
`PostScript function: unexpected '${tok.value}' operator.`
);
View on GitHub (pinned to 5903d58d58)
Solutions
- In the Type 4 function, follow each procedure block with `if` or use the `{...} {...} ifelse` form; a bare procedure is not allowed.
When it happens
Trigger: Thrown at src/core/postscript/ast.js:294 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of mozilla/pdf.js@5903d58d58 (2026-08-13).
Data as JSON: /api/errors/9918dec314ed9301.
Report an issue: GitHub.