Diagnostic and cause
링크TPZ5022
- 계열
- topaz
- 단계
- check
- 코드
TPZ5022
원인과 조건
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.
관련 규칙 · When inference needs an annotation →대응
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 mainmust 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⟩.cannot be generic Source⟨value⟩ - protocol method
⟨value⟩.must take the conforming value as its first parameter Source⟨value⟩ - protocol method
⟨value⟩.requires an explicit return type (use⟨value⟩ -for unit) Source> () - protocol method
⟨value⟩.cannot be variadic Source⟨value⟩ - protocol method
⟨value⟩.cannot declare parameter defaults Source⟨value⟩ - protocol method
⟨value⟩.must use⟨value⟩ Selfor 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⟩.is module-local and cannot be exported Source⟨value⟩ - protocol implementation method
⟨value⟩.cannot be generic Source⟨value⟩ - protocol implementation method
⟨value⟩.requires an explicit return type (use⟨value⟩ -for unit) Source> () - protocol implementation method
⟨value⟩.cannot be variadic Source⟨value⟩ - protocol implementation method
⟨value⟩.cannot declare parameter defaults Source⟨value⟩ - protocol implementation method
⟨value⟩.must match the declared signature exactly; expected ⟨value⟩, found ⟨value⟩ Source⟨value⟩ - unknown protocol
⟨value⟩inimpl ⟨value⟩<⟨value⟩>Source JSONconformance is derive-only; usederives JSONSource- 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 takeselfas its first parameter Source - method
⟨value⟩on⟨value⟩must take bareselfas 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
implblock cannot be exported; mark individual methods withexportSource - cannot define methods on
⟨value⟩(⟨value⟩);implis only allowed on an own-module record, enum, or newtype Source - cannot define receiver methods on generic nominal
⟨value⟩yet; genericimplbinders 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.must match the declared signature exactly; expected (Item) ->show string, found (int) ->string
A protocol implementation signature differs from its protocol, or a type cannot be determined under the applicable annotation rule. The Result error annotation rule also applies to lambdas used as callbacks.
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. A lambda, including one used as a callback, follows the same annotation requirement under callback propagation.
이유
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. Each callable has its own propagation destination. A callback can return a Result without ending its caller.
Response
링크Match the declared parameter and result types to the required signature. If Result error inference remains undetermined, add a type annotation. A lambda binding can declare its complete function type, including the Result error type.
Reproduction and verification
링크Rejected program
링크record Item { value: int }impl Show<Item> {function show(value: int) -> string { "item" }}
표준 출력 없음.기대 결과
기대 결과
거절 단계 check. 종료 코드가 0이 아닙니다.
diagnostics-protocol-implementation-signature at
example.tpz:3:12
Repaired program
링크record Item { value: int }impl Show<Item> {function show(value: Item) -> string { "item" }}
기대 결과
기대 결과
검사가 프로그램을 받아들입니다. 종료 코드 0.
Lambda return inference
링크The lambda annotation example applies TPZ5022 to an undetermined Result error type. Callback propagation gives each lambda its own return destination. The example and its execution record belong to that language rule.