Diagnostic and cause
LinkRuntime value guard
- Family
- topaz
- Phase
- run
- Code
TPZ5001
Cause and conditions
At runtime TPZ5001 reports a value that fails the operation guard. Decimal scales follow Decimal rounding. Invalid scales fail before division classifies a zero divisor. BigInt radix and ByteBuffer byte guards use the same runtime identity. A comprehension stops when its pattern does not match a reached element.
Related rule: Reject invalid values during executionResponse
Use a valid value for the operation. Check its scale, radix or byte bounds. Use an explicit filter when a comprehension should skip unmatched values.
Source evidence
- compiler/crates/topaz_diag/src/explain.rs at
151141d7bb44· 580-592 - compiler/crates/topaz_product_runtime/src/diagnostic.rs at
151141d7bb44· 62-62 - compiler/crates/topaz_self_frontend/topaz/checker/bodies_captures.tpz at
151141d7bb44· 109-109 - compiler/crates/topaz_self_frontend/topaz/checker/call_complete.tpz at
151141d7bb44· 1120-1120 - compiler/crates/topaz_self_frontend/topaz/checker/call_facts.tpz at
151141d7bb44· 626-626 - compiler/crates/topaz_self_frontend/topaz/checker/expression_control.tpz at
151141d7bb44· 374-374 - compiler/crates/topaz_self_frontend/topaz/checker/expression_core.tpz at
151141d7bb44· 490-490 - compiler/crates/topaz_self_frontend/topaz/checker/nominals.tpz at
151141d7bb44· 267-267 - compiler/crates/topaz_self_frontend/topaz/checker/patterns.tpz at
151141d7bb44· 527-527 - compiler/crates/topaz_self_frontend/topaz/checker/statements.tpz at
151141d7bb44· 494-494 - compiler/crates/topaz_value/src/value/builtins/bigint_decimal.rs at
151141d7bb44· 108-135 - compiler/crates/topaz_value/src/value/builtins/bigint_decimal.rs at
151141d7bb44· 204-227 - compiler/crates/topaz_value/src/value/builtins/bigint_decimal.rs at
151141d7bb44· 53-63 - compiler/crates/topaz_value/src/value/builtins/byte_buffer.rs at
151141d7bb44· 67-74 - compiler/crates/topaz_value/src/value/builtins/byte_buffer.rs at
151141d7bb44· 108-122 - compiler/crates/topaz_self_frontend/topaz/emitter/emit.tpz at
151141d7bb44· 1852-1864 - compiler/crates/topaz_product_runtime/src/diagnostic.rs at
151141d7bb44· 62-62
Compiler phase: check/runtime.
Compiler explanation: A value's type does not match the type required by its context.
Message templates. The marker ⟨value⟩ stands for text computed for the reported program.
constinitializers must be constant expressions (§4) Source⟨value⟩is not iterable (§10) Sourcereturnoutside a function Source- a placeholder
_is valid only inside a pipeline stage (§11) Source - expected
⟨value⟩, found⟨value⟩Source ⟨value⟩outside a loop Source- bare
⟨value⟩cannot target ⟨value⟩ Source concurrenttimeout duration must fit in u64 milliseconds (§15) Source- the range step must not be zero (§10) Source
??needs an Option or nullable left operand, found⟨value⟩Source- Length operation requires compatible units and scalar operands, found
⟨value⟩and⟨value⟩Source - arithmetic needs matching numeric operands, found
⟨value⟩and⟨value⟩Source %needs int operands in v5.2, found⟨value⟩and⟨value⟩Source+needs matching int, float, string, BigInt, or Decimal operands, found⟨value⟩and⟨value⟩Sourceindoes not apply to a Map; usein map.Sourcekeys indoes not apply to strings Source- integer literal is out of range Source
- unary operator cannot apply to
⟨value⟩Source ?propagates an error, but the function returns⟨value⟩, not a Result Source?requires a Result value, found⟨value⟩Source⟨value⟩is not index-readable; only arrays support[…]indexing (§9) Source- integer literal
⟨value⟩is out of range Source - a placeholder
_is valid only in a pipeline stage's argument list (§11) Source ⟨value⟩is not iterable (§10) SourceBytevalues cannot be interpolated; snapshot toBuffer Bytesand encode explicitly Source- array spread needs an
Array, found⟨value⟩Source ?.needs an Option or nullable receiver, foundnamespaceSource?.needs an Option or nullable receiver, found⟨value⟩Source- record spread
.needs a declared record;. . ⟨value⟩is not one Source - record update needs a record, found
⟨value⟩Source - integer literal type
⟨value⟩is out of range Source - Length requires one compiler-owned Pt, Mm, Cm, In or Em marker Source
- this pattern can never match
⟨value⟩Source - a
⟨value⟩pattern cannot establish nominal identity for rigid scrutinee type⟨value⟩Source - this
⟨value⟩pattern can never match⟨value⟩Source - this
⟨value⟩pattern can never match⟨value⟩Source - a Map is not index-assignable; use
m.(§22) Sourceinsert - cannot assign through optional access
?.(§4) Source ??=needs an Option or nullable target, found⟨value⟩Source- constant expression error: ⟨value⟩ Source
A checked program can still receive an invalid value during execution. Invalid numeric parameters and byte values use TPZ5001. A failed comprehension pattern uses the same runtime code. Each operation keeps its own cause and source location.
Reject invalid values during execution
At runtime TPZ5001 reports a value that fails the operation guard. Decimal scales follow Decimal rounding. Invalid scales fail before division classifies a zero divisor. BigInt radix and ByteBuffer byte guards use the same runtime identity. A comprehension stops when its pattern does not match a reached element.
Source evidence
- compiler/crates/topaz_value/src/value/builtins/bigint_decimal.rs at
151141d7bb44· 108-135 - compiler/crates/topaz_value/src/value/builtins/bigint_decimal.rs at
151141d7bb44· 204-227 - compiler/crates/topaz_value/src/value/builtins/bigint_decimal.rs at
151141d7bb44· 53-63 - compiler/crates/topaz_value/src/value/builtins/byte_buffer.rs at
151141d7bb44· 67-74 - compiler/crates/topaz_value/src/value/builtins/byte_buffer.rs at
151141d7bb44· 108-122 - compiler/crates/topaz_self_frontend/topaz/emitter/emit.tpz at
151141d7bb44· 1852-1864 - compiler/crates/topaz_product_runtime/src/diagnostic.rs at
151141d7bb44· 62-62
Response
LinkUse a valid value for the operation. Check its scale, radix or byte bounds. Use an explicit filter when a comprehension should skip unmatched values.
Reproduction and verification
LinkRejected program
Linkimport std.decimal { Decimal }let one: Decimal = (1).toDecimal()one.round(-1)
No stdout.
Expected result
Pinned source identifies the guard and call location. This pair has not been run with the public CLI.
Source evidence
- compiler/crates/topaz_value/src/value/builtins/bigint_decimal.rs at
151141d7bb44· 108-135 - compiler/crates/topaz_value/src/value/builtins/bigint_decimal.rs at
151141d7bb44· 204-227 - compiler/crates/topaz_value/src/value/builtins/bigint_decimal.rs at
151141d7bb44· 53-63 - compiler/crates/topaz_value/src/value/builtins/byte_buffer.rs at
151141d7bb44· 67-74 - compiler/crates/topaz_value/src/value/builtins/byte_buffer.rs at
151141d7bb44· 108-122 - compiler/crates/topaz_self_frontend/topaz/emitter/emit.tpz at
151141d7bb44· 1852-1864 - compiler/crates/topaz_product_runtime/src/diagnostic.rs at
151141d7bb44· 62-62
Repaired program
Linkimport std.decimal { Decimal }import std.iolet one: Decimal = (1).toDecimal()io.writeLine(one.round(0).toString())
1
Expected result
Expected result
Execution completes. Exit code 0.
1
Pinned source identifies the guard and call location. This pair has not been run with the public CLI.
Source evidence
- compiler/crates/topaz_value/src/value/builtins/bigint_decimal.rs at
151141d7bb44· 108-135 - compiler/crates/topaz_value/src/value/builtins/bigint_decimal.rs at
151141d7bb44· 204-227 - compiler/crates/topaz_value/src/value/builtins/bigint_decimal.rs at
151141d7bb44· 53-63 - compiler/crates/topaz_value/src/value/builtins/byte_buffer.rs at
151141d7bb44· 67-74 - compiler/crates/topaz_value/src/value/builtins/byte_buffer.rs at
151141d7bb44· 108-122 - compiler/crates/topaz_self_frontend/topaz/emitter/emit.tpz at
151141d7bb44· 1852-1864 - compiler/crates/topaz_product_runtime/src/diagnostic.rs at
151141d7bb44· 62-62