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

    TPZ5020: Type could not be inferred

    Inference reached a value whose type stays ambiguous without more context.

    Diagnostic and cause

    Link

    Type could not be inferred

    Family
    topaz
    Phase
    check
    Code
    TPZ5020

    Cause and conditions

    A bare empty array binding needs a contextual element type. An Array<T> annotation supplies that context.

    Response

    Add a type annotation at the binding, parameter, or surrounding expression so inference can choose the required type.

    Source evidence

    Compiler phase: check.

    Compiler explanation: Inference reached a value whose type stays ambiguous without more context.

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

    • this expression needs a contextual type (§22.1): annotate the binding or surrounding expectation Source
    • map {} needs a contextual type (§6): annotate the binding or the expected key/value types Source

    Observed for the candidate in Topaz 5.21.3. Execution

    • error[TPZ5020]: [] needs a contextual type (§22.1): annotate the binding or the expected element type

    A bare empty array binding needs a contextual element type. An Array<T> annotation supplies that context.

    Rulediagnostics.tpz5020.p5.rule

    Type could not be inferred

    A bare empty array binding needs a contextual element type. An Array<T> annotation supplies that context.

    Source evidence

    Response

    Link

    Add a type annotation at the binding, parameter, or surrounding expression so inference can choose the required type.

    Reproduction and verification

    Link

    Rejected program

    Link
    example.tpzRejected programOpen in Playground
    1. let values = []
    Expected outputNonzero exit
    No stdout.
    $ topaz check example.tpz · target product 5.21.3
    Expected result

    Expected result

    Rejection during check. Nonzero exit.

    • TPZ5020 diagnostics-empty-array-needs-context at example.tpz:1:14
    Source evidence

    Repaired program

    Link
    example.tpzRepaired program
    1. let values: Array<int> = []
    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