Skip to content
Topaz6.0 · Before release
Download

Search documentation

Specification 6.0 · Not released · Tested product 5.21.3

Use arrow keys to choose a result. Press Enter to open.

Type an API name, diagnostic number, rule, or project topic.

    Diagnostics

    TPZ5022: Malformed or unknown type

    A type annotation, alias, or protocol bound names a type/protocol form that is not valid here.

    Diagnostic and cause

    Link

    TPZ5022

    Family
    topaz
    Phase
    check
    Code
    TPZ5022

    Cause and conditions

    Confirmed TPZ5022 paths include an inferred result containing a generic projection without a nameable return type, and an unresolved result when the function calls a definition whose return type is still pending.

    Response

    Source evidence

    Compiler phase: check.

    Compiler explanation: A type annotation, alias, or protocol bound names a type/protocol form that is not valid here.

    Message templates. The marker ⟨value⟩ stands for text computed for the reported program.

    • export function main must be non-generic and have signature ⟨value⟩; found ⟨value⟩ Source
    • cannot infer a return type for ⟨value⟩: it returns a destructured generic value with no nameable type — annotate the return type Source
    • ⟨value⟩ is (mutually) recursive: declare its return type (§7) Source
    • cannot derive ⟨value⟩ for generic nominal ⟨value⟩ yet; conditional generic conformance is not defined Source
    • integer literal ⟨value⟩ is out of range Source
    • record literal declares field ⟨value⟩ twice Source
    • ⟨value⟩ takes ⟨value⟩ type argument⟨value⟩, found ⟨value⟩ Source
    • integer literal type ⟨value⟩ is out of range Source
    • record type declares field ⟨value⟩ twice Source
    • type parameter ⟨value⟩ takes no type arguments Source
    • primitive type ⟨value⟩ takes no type arguments Source
    • ⟨value⟩ takes no type arguments Source
    • ⟨value⟩ name ⟨value⟩ collides with ⟨value⟩; choose another name Source
    • enum variant ⟨value⟩ collides with a reserved prelude constructor; choose another variant name Source
    • enum variant ⟨value⟩ has a payload ⟨value⟩ that is a union containing an enum — enum-in-union payloads are not supported Source
    • protocol method ⟨value⟩.⟨value⟩ cannot be generic Source
    • protocol method ⟨value⟩.⟨value⟩ must take the conforming value as its first parameter Source
    • protocol method ⟨value⟩.⟨value⟩ requires an explicit return type (use -> () for unit) Source
    • protocol method ⟨value⟩.⟨value⟩ cannot be variadic Source
    • protocol method ⟨value⟩.⟨value⟩ cannot declare parameter defaults Source
    • protocol method ⟨value⟩.⟨value⟩ must use Self or the protocol's type parameter as its first parameter type Source
    • ⟨value⟩ is already a type and cannot also be a protocol Source
    • protocol ⟨value⟩ takes at most one conforming-type parameter; found ⟨value⟩ Source
    • protocol ⟨value⟩ has no method ⟨value⟩ Source
    • protocol implementation method ⟨value⟩.⟨value⟩ is module-local and cannot be exported Source
    • protocol implementation method ⟨value⟩.⟨value⟩ cannot be generic Source
    • protocol implementation method ⟨value⟩.⟨value⟩ requires an explicit return type (use -> () for unit) Source
    • protocol implementation method ⟨value⟩.⟨value⟩ cannot be variadic Source
    • protocol implementation method ⟨value⟩.⟨value⟩ cannot declare parameter defaults Source
    • protocol implementation method ⟨value⟩.⟨value⟩ must match the declared signature exactly; expected ⟨value⟩, found ⟨value⟩ Source
    • unknown protocol ⟨value⟩ in impl ⟨value⟩<⟨value⟩> Source
    • JSON conformance is derive-only; use derives JSON Source
    • cannot implement protocol ⟨value⟩ for generic nominal ⟨value⟩ yet; generic conformance binders are not defined Source
    • impl ⟨value⟩<⟨value⟩> is missing method ⟨value⟩ Source
    • method ⟨value⟩ on ⟨value⟩ must take self as its first parameter Source
    • method ⟨value⟩ on ⟨value⟩ must take bare self as its first parameter (no type annotation, default, or variadic marker) Source
    • generic methods are not supported yet (method ⟨value⟩) Source
    • method name ⟨value⟩ on ⟨value⟩ collides with a builtin member; choose another name Source
    • method ⟨value⟩ on ⟨value⟩ collides with a field of the same name; rename the method (a field shadows a method) Source
    • an impl block cannot be exported; mark individual methods with export Source
    • cannot define methods on ⟨value⟩ (⟨value⟩); impl is only allowed on an own-module record, enum, or newtype Source
    • cannot define receiver methods on generic nominal ⟨value⟩ yet; generic impl binders are not defined Source
    • ⟨value⟩ declarations are module-top-level only Source

    Observed for the candidate in Topaz 5.21.3. Execution

    • error[TPZ5022]: protocol implementation method Show.show must match the declared signature exactly; expected (Item) -> string, found (int) -> string

    A protocol implementation signature differs from its protocol, or a type cannot be determined under the applicable annotation rule.

    Rulediagnostics.tpz5022.p5.rule

    Malformed or unknown type

    A protocol implementation method must have exactly the parameter and result types required by its protocol after substituting the conforming type. TPZ5022 also requires annotations under function return inference and Result error inference.

    Why

    Result error inference uses the same annotation diagnostic as function return inference. The emitted return type is determined instead of falling back to a broad value type.

    Source evidence

    Response

    Link

    Compare the declaration with the required type or protocol signature. Match the declared parameter and result types and remove unsupported type-related forms.

    Reproduction and verification

    Link

    Rejected program

    Link
    example.tpzRejected programOpen in Playground
    1. record Item { value: int }
    2. impl Show<Item> {
    3. function show(value: int) -> string { "item" }
    4. }
    Expected outputNonzero exit
    No stdout.
    $ topaz check example.tpz · target product 5.21.3
    Expected result

    Expected result

    Rejection during check. Nonzero exit.

    • TPZ5022 diagnostics-protocol-implementation-signature at example.tpz:3:12
    Source evidence

    Repaired program

    Link
    example.tpzRepaired program
    1. record Item { value: int }
    2. impl Show<Item> {
    3. function show(value: Item) -> string { "item" }
    4. }
    Expected outputexit 0
    $ topaz check example.tpz · target product 5.21.3
    Expected result

    Expected result

    Checking accepts the program. Exit code 0.

    Source evidence

    Menu

    Download