Fixing pretty printer not adding enough parens around record access things

This commit is contained in:
Dustin Swan 2026-04-08 18:47:47 -06:00
parent a88a4fb764
commit 1a26ec4d24
No known key found for this signature in database
GPG key ID: 30D46587E2100467

View file

@ -319,9 +319,17 @@ export function prettyPrint(ast: AST, indent = 0): string {
return `${params} \\ ${body}` return `${params} \\ ${body}`
} }
case 'record-access': case 'record-access': {
const field = needsQuotes(ast.field) ? `${JSON.stringify(ast.field)}` : ast.field; const field = needsQuotes(ast.field) ? `${JSON.stringify(ast.field)}` : ast.field;
return `${prettyPrint(ast.record, indent)}.${field}`; const inner = prettyPrint(ast.record, indent);
const needsParens = ast.record.kind === 'apply' ||
ast.record.kind === 'lambda' ||
ast.record.kind === 'match' ||
ast.record.kind === 'let' ||
ast.record.kind === 'rebind';
return needsParens ? `(${inner}).${field}` : `${inner}.${field}`;
// return `${prettyPrint(ast.record, indent)}.${field}`;
}
case 'record-update': { case 'record-update': {
const updates = Object.entries(ast.updates) const updates = Object.entries(ast.updates)