From f0e2a3eb1268f217366d9de58f479001a534663a Mon Sep 17 00:00:00 2001 From: "g. nicholas d'andrea" Date: Sat, 4 Jul 2026 16:38:29 -0400 Subject: [PATCH] format: add the Name context type and guard to the TS types MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The `name` context has had a schema and spec page, but the TypeScript types never mirrored it — there was no `Context.Name` interface or `isName` guard, and `name` was absent from the `Context` union and `isContext`. Add them, matching the other context guards, so a bare `{ name }` context is recognized. --- packages/format/src/types/program/context.test.ts | 4 ++++ packages/format/src/types/program/context.ts | 12 ++++++++++++ 2 files changed, 16 insertions(+) diff --git a/packages/format/src/types/program/context.test.ts b/packages/format/src/types/program/context.test.ts index 4470a322d..88bbf537c 100644 --- a/packages/format/src/types/program/context.test.ts +++ b/packages/format/src/types/program/context.test.ts @@ -6,6 +6,10 @@ testSchemaGuards("ethdebug/format/program/context", [ schema: "schema:ethdebug/format/program/context", guard: isContext, }, + { + schema: "schema:ethdebug/format/program/context/name", + guard: Context.isName, + }, { schema: "schema:ethdebug/format/program/context/code", guard: Context.isCode, diff --git a/packages/format/src/types/program/context.ts b/packages/format/src/types/program/context.ts index b9ec6fc4f..cc9060acc 100644 --- a/packages/format/src/types/program/context.ts +++ b/packages/format/src/types/program/context.ts @@ -3,6 +3,7 @@ import { Type } from "#types/type"; import { Pointer, isPointer } from "#types/pointer"; export type Context = + | Context.Name | Context.Code | Context.Variables | Context.Remark @@ -15,6 +16,7 @@ export type Context = export const isContext = (value: unknown): value is Context => [ + Context.isName, Context.isCode, Context.isVariables, Context.isRemark, @@ -27,6 +29,16 @@ export const isContext = (value: unknown): value is Context => ].some((guard) => guard(value)); export namespace Context { + export interface Name { + name: string; + } + + export const isName = (value: unknown): value is Name => + typeof value === "object" && + !!value && + "name" in value && + typeof value.name === "string"; + export interface Code { code: Materials.SourceRange; }