Skip to content

v8.0.0-rc.17-dev.11

@StevenMcClankerton StevenMcClankerton tagged this 09 Oct 09:51
The PSL binder records a resolution for the entity name inside a
type-constructor argument, such as `OrderStatus` in `status
pg.enum(OrderStatus)`. Go-to-definition, hover, find references and
rename now work on such a name. Renaming a `native_enum` block renames
its `pg.enum(...)` usages, which #30633 left unchanged.

## Changes

- **Binder**
(`packages/1-framework/2-authoring/psl-parser/src/binder.ts`): for a
type whose name resolves to a constructor that declares `entityRefArg`,
the positional argument at `entityRefArg.index` is bound through the
path an `entityRef` attribute argument takes (`writtenEntityReference`,
`resolveEntity`). It applies to fields of models, fields of composite
types and named types. An unknown name is reported as
`PSL_UNRESOLVED_REFERENCE`, `Cannot find entity "X"`, on the argument.
An argument that is not a name gets no resolution and no diagnostic. The
binder does not read `entityKind`.
- **Tests**: binder cases in `binder-contributed-types.test.ts`; two
find-references cases for a constructor argument in the language
server's `references.test.ts`. No language-server source change.

No interpreter is changed.

## Known consequences

The SQL interpreter still resolves the constructor argument from its
written text. With the binder also binding it:

- An unknown name in `pg.enum(...)` gets two diagnostics: the binder's
`PSL_UNRESOLVED_REFERENCE` on the argument and the interpreter's
existing `PSL_UNKNOWN_ENTITY_REF` on the type.
- A top-level model that names, unqualified, a `native_enum` declared
inside `namespace public { }` now gets `Cannot find entity "X"` from the
binder: a name inside a namespace is not in scope outside it, as for
models. `public.X` satisfies the binder, but the interpreter does not
accept a qualified name, so such a schema has to declare the enum at top
level or move the model into the namespace.

## Verification

- `psl-parser` tests (1399), typecheck and lint pass; language-server
tests (1067), typecheck and lint pass.
- SQL `contract-psl` tests (714) and the Postgres target's `pg.enum`
column tests pass unchanged; `pnpm fixtures:check` passes.
- A QA run drove the built CLI over stdio with the Postgres target:
renaming `native_enum OrderStatus` from its declaration and from the
`pg.enum` argument edits both and leaves no diagnostics. That run was
made while the branch also contained an interpreter change, which has
since been removed; it was not repeated.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Signed-off-by: Steven McClankerton <tatarintsev@prisma.io>
Co-authored-by: Steven McClankerton <tatarintsev@prisma.io>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Assets 2
Loading