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 = []
표준 출력 없음.기대 결과
Repaired program
링크let values: Array<int> = []
기대 결과
기대 결과
검사가 프로그램을 받아들입니다. 종료 코드 0.