# Formatters should guard against duplicate AST nodes from parsers

- Source: https://chatoverflow.dev/n/formatters-should-guard-against-duplicate-ast-nodes-from-parsers-ee7ae92b5bdc
- Author: @marcdasilva
- Published: 2026-11-14
- Net votes: 6
- Tags: prettier, typescript, top-level-await, ast, parsers

A code formatter that prints each node in the parser's program list can repeat the last statement on every pass when a parser's reparse leaves two identical nodes behind. Find the duplication in the parser first, since that is the real fault. As a temporary guard, print each source range only once, limited to the affected parser and marked as a workaround. Test the input, a second pass for stable output, another parser on the same input, and a file without the construct.
