diff --git a/src/slang-nodes/types.d.ts b/src/slang-nodes/types.d.ts index 4a6070d41..9f56a82a9 100644 --- a/src/slang-nodes/types.d.ts +++ b/src/slang-nodes/types.d.ts @@ -461,6 +461,11 @@ export type StrictAstNode = | YulPaths | YulPath; +export type FunctionWithBody = Extract< + FunctionLike, + { body: FunctionBody['variant'] } +>; + export type PolymorphicNode = Extract; export type StrictPolymorphicNode = Extract< diff --git a/src/slang-printers/print-function.ts b/src/slang-printers/print-function.ts index 024eb111a..2e835834f 100644 --- a/src/slang-printers/print-function.ts +++ b/src/slang-printers/print-function.ts @@ -3,9 +3,8 @@ import { doc } from 'prettier'; import { joinExisting } from '../slang-utils/join-existing.js'; import type { AstPath, Doc } from 'prettier'; -import type { FunctionLike } from '../slang-nodes/types.d.ts'; +import type { FunctionLike, FunctionWithBody } from '../slang-nodes/types.d.ts'; import type { PrintFunction } from '../types.d.ts'; -import type { FunctionBody } from '../slang-nodes/FunctionBody.js'; const { dedent, group, indent, line } = doc.builders; @@ -15,9 +14,7 @@ export function printFunction( path: AstPath, print: PrintFunction ): Doc { - const body = ( - node as Extract - ).body; + const body = (node as FunctionWithBody).body; return group([ functionName, @@ -37,7 +34,7 @@ export function printFunction( export function printFunctionWithBody( functionName: Doc, node: FunctionLike, - path: AstPath>, + path: AstPath, print: PrintFunction ): Doc { return [ diff --git a/src/slangPrinter.ts b/src/slangPrinter.ts index 295d9a07c..3aa5b7557 100644 --- a/src/slangPrinter.ts +++ b/src/slangPrinter.ts @@ -30,8 +30,8 @@ function ignoreComments(path: AstPath): void { let key: keyof StrictAstNode; for (key in node) { switch (key) { - // We ignore `kind`, `loc`, and `comments` since these are added by the - // parser. `updateMetadata` is an internal function. + // We ignore `kind` and `loc` since these are added by the parser. + // `updateMetadata` is an internal function. case 'kind': case 'loc': case 'updateMetadata':