mirror of
https://github.com/roc-lang/roc.git
synced 2025-10-02 16:21:11 +00:00
No Encode/Decode for Nat
This commit is contained in:
parent
99050956d3
commit
572a666780
5 changed files with 131 additions and 14 deletions
|
@ -13,8 +13,8 @@ use roc_module::symbol::Symbol;
|
|||
use roc_problem::Severity;
|
||||
use roc_region::all::{LineInfo, Region};
|
||||
use roc_solve_problem::{
|
||||
NotDerivableContext, NotDerivableDecode, NotDerivableEq, TypeError, UnderivableReason,
|
||||
Unfulfilled,
|
||||
NotDerivableContext, NotDerivableDecode, NotDerivableEncode, NotDerivableEq, TypeError,
|
||||
UnderivableReason, Unfulfilled,
|
||||
};
|
||||
use roc_std::RocDec;
|
||||
use roc_types::pretty_print::{Parens, WILDCARD};
|
||||
|
@ -371,7 +371,29 @@ fn underivable_hint<'b>(
|
|||
])),
|
||||
])))
|
||||
}
|
||||
NotDerivableContext::Encode(reason) => match reason {
|
||||
NotDerivableEncode::Nat => {
|
||||
Some(alloc.note("").append(alloc.concat([
|
||||
alloc.reflow("Encoding a "),
|
||||
alloc.type_str("Nat"),
|
||||
alloc.reflow(" is not supported. Consider using a fixed-sized unsigned integer, like a "),
|
||||
alloc.type_str("U64"),
|
||||
alloc.reflow("instead."),
|
||||
])))
|
||||
}
|
||||
},
|
||||
NotDerivableContext::Decode(reason) => match reason {
|
||||
NotDerivableDecode::Nat => {
|
||||
Some(alloc.note("").append(alloc.concat([
|
||||
alloc.reflow("Decoding to a "),
|
||||
alloc.type_str("Nat"),
|
||||
alloc.reflow(" is not supported. Consider decoding to a fixed-sized unsigned integer, like "),
|
||||
alloc.type_str("U64"),
|
||||
alloc.reflow(", then converting to a "),
|
||||
alloc.type_str("Nat"),
|
||||
alloc.reflow(" if needed."),
|
||||
])))
|
||||
}
|
||||
NotDerivableDecode::OptionalRecordField(field) => {
|
||||
Some(alloc.note("").append(alloc.concat([
|
||||
alloc.reflow("I can't derive decoding for a record with an optional field, which in this case is "),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue