Skip to content

Resolve instance declarations and instance signatures #90

Closed

Description

@biuld

Part of #75 (Phase 2). Instance declarations are not part of resolution, which costs two M2 failing cases and blocks the library work in Phase 3.

Failing cases

File Expected Why
failing/881.purs DuplicateValueDeclaration Two foo definitions in one instance; we report nothing.
failing/InstanceSigsOrphanTypeDeclaration.purs OrphanTypeDeclaration A type declared in an instance signature; we report nothing.

Why this is on the critical path

Phase 3's Prelude needs Eq, Ord, Functor, Apply, Applicative, Foldable, Semigroup, Monoid as classes with instances. The class and instance elaboration is done (#63, closed; commits 7b39ca8, c983b32, 814e04b, fe82bb0, and I verified a class + superclass + instance program runs under Wasmtime with the superclass-projected method). What is missing is instances in the resolver: duplicate member detection, instance signatures participating in orphan checks, and instance names in the module namespace.

Scope

  • Instance declarations lower into AST and HIR and enter the resolver.
  • Instance member names join the value namespace for duplicate detection (DuplicateValueDeclaration).
  • Instance signatures are checked for orphan types (OrphanTypeDeclaration).
  • Instance names participate in module-level name conflicts.
  • Export/import of classes carries instance visibility consistently.

Do not narrow this to the two failing cases: the resolver must model instances the way it models classes, or Phase 3 will build the library on a partial model.

Acceptance

Both cases agree, instances resolve across modules, and stdlib can declare classes with instances.

Activity

  1. added
    gate:L2Blocks module, import, export and name resolution (D-04 L2)
    area:frontendFrontend: syntax, resolution, kinds, types, classes
    on Oct 1, 2026
  2. biuld commented on Oct 2, 2026

    @biuld
    OwnerAuthor

    Closed by #117 (merge commit 0c7544d), two commits: 98e46e0 attributes every program diagnostic to a named DiagnosticOrigin, cb52868 resolves instance declarations and instance signatures.

    Evidence, re-measured on the merged tree with the annotations oracle against the vendored v0.15.16 corpus:

    • M2 failing agreement 72/72, up from 70/72. The two cases this issue names now agree: failing/881.purs (DuplicateValueDeclaration) and failing/InstanceSigsOrphanTypeDeclaration.purs (OrphanTypeDeclaration).
    • passing resolution 59/413, unchanged, with 354 first-stage blockers: 337 missing library modules, 8 at P3, 5 at P2, 4 at P0, none on assembly.
    • L4 17/38 (was 16/40) and L5 45/87 (was 45/89), with 33 cases blocked before the type checker against 29. These are case reclassifications rather than new type-checking evidence; D-04 names each case that moved.
    • L1 904/908, L3 29/48, and the L6/M7 runtime board are unchanged.

    The scoreboard numbers were not trustworthy until diagnostic attribution was fixed, so the first commit repairs it before the second re-measures. Two defects, both confirmed by tests that fail without the fix: a lenient pass enumerated the modules that survived resolution and used that position as the source index, so a diagnostic landed on whichever module took the failing module's slot and an imported instance was looked up in the importing module's own slot; and the trusted library prefix was subtracted with saturation, mapping every library diagnostic and every module-less backend diagnostic onto the caller's first source. DiagnosticOrigin now names a caller source, the library, and the program as a whole. That commit is scoreboard-neutral against master: the full board output is byte-identical.

    Corpus cases stays 2, the two failing cases this issue recovers, one per errorCode; no passing count moved.

    Validation: cargo fmt --all --check, cargo clippy --workspace --all-targets -- -D warnings, cargo test --workspace (1126 passed, 0 failed), PSRS_REQUIRE_WASMTIME=1 cargo test --workspace (1126 passed, 0 failed, 5 ignored, Wasmtime 49.0.1), PURESCRIPT_REPO=… cargo test -p psrs-driver --test upstream (4 passed), full scoreboards run twice with identical output, and both required Wasmtime CI checks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:frontendFrontend: syntax, resolution, kinds, types, classesenhancementNew feature or requestgate:L2Blocks module, import, export and name resolution (D-04 L2)

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions