Rules
СсылкаDerived record representation
For a record that derives Show, Show. returns its record name and fields in declaration order. A nonempty record uses Name { field: value, field: value }; an empty record uses Name {}. Each field uses the standard value rendering, so string fields appear without added quotes. A record without a Show conformance is rejected with TPZ5522. A manual Show implementation supplies its own method result.
Причина
The record name and field names expose the value's structure. Declaration order makes the display stable across construction sites, and nested values use the shared renderer.
Examples
СсылкаRender declared fields and an empty record
Ссылкаimport std.iorecord Pair derives Show { z: int, a: string }record Empty derives Show {}io.writeLine(Show.show(Pair { a: "Topaz", z: 3 }))io.writeLine(Show.show(Empty {}))
Pair { z: 3, a: Topaz }
Empty {}
Ожидаемый результат
Ожидаемый результат
Выполнение завершается. Код завершения 0.
Pair { z: 3, a: Topaz }Empty {}
Reject a record without Show conformance
Ссылкаrecord Pair { z: int, a: string }let text = Show.show(Pair { z: 3, a: "Topaz" })
Нет стандартного вывода.Ожидаемый результат
Ожидаемый результат
Этап отклонения check. Ненулевой код завершения.
protocol-call-argument-does-not-conform at
derived-show-bad.tpz:2:22