ErrorsValues and types · rule
syntax.optional_chaining
Field of a missing value read with ?..
Area 2, Values and types; not declinable; the next step is usually the agent's.
A field of a value that may be none is read in a match too.
type ShippingCode = Text { max_length: 10}type Address = Object { postal_code: ShippingCode}type Customer = Object { address: Address?}function postal_code(customer: Customer) -> ShippingCode? { return customer.address?.postal_code}
error Jadpo reads a value that may be none with match, not ?.
--> main.jadpo:14:28
|14 | return customer.address?.postal_code | ^^ write a `match`
- reason
?.reads a field of a value that may be missing in JavaScript, TypeScript, C#, Kotlin and Swift; Jadpo reads a value that may benonewith amatchthat handles both cases.- next
- Write
match customer.addresswith the armssome(address) -> address.postal_codeandnone -> none(agent) - rule
- syntax.
optional_ chaining - help
- https://jadpo.
dev/docs/errors/syntax. optional_ chaining
Markdown for agents: /docs/errors/syntax.optional_chaining.md.Built from Jadpo main at aee2e8f.