Diagnostic and cause
СсылкаType could not be inferred
- Семейство
- topaz
- Этап
- check
- Код
TPZ5020
Причина и условия
A bare empty array binding needs a contextual element type. An Array<T> annotation supplies that context.
Действия
Add a type annotation at the binding, parameter, or surrounding expression so inference can choose the required type.
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.
Type could not be inferred
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.
Reproduction and verification
СсылкаRejected program
Ссылкаlet values = []
Нет стандартного вывода.Ожидаемый результат
Ожидаемый результат
Этап отклонения check. Ненулевой код завершения.
diagnostics-empty-array-needs-context at
example.tpz:1:14
Repaired program
Ссылкаlet values: Array<int> = []
Ожидаемый результат
Ожидаемый результат
Проверка принимает программу. Код завершения 0.