mirror of
https://github.com/roc-lang/roc.git
synced 2025-08-03 19:58:18 +00:00
Treat numbers as ad-hoc types for the purpose of checking ability obligations
This commit is contained in:
parent
568e8d9475
commit
7b23077265
3 changed files with 37 additions and 29 deletions
|
@ -553,15 +553,6 @@ impl ObligationCache<'_> {
|
|||
}
|
||||
Erroneous(_) => return Err(var),
|
||||
},
|
||||
Alias(name, _, _, AliasKind::Opaque) => {
|
||||
let opaque = *name;
|
||||
if self
|
||||
.check_opaque_and_read(subs, opaque, Symbol::ENCODE_ENCODING)
|
||||
.is_err()
|
||||
{
|
||||
return Err(var);
|
||||
}
|
||||
}
|
||||
Alias(
|
||||
Symbol::NUM_U8
|
||||
| Symbol::NUM_U16
|
||||
|
@ -576,13 +567,23 @@ impl ObligationCache<'_> {
|
|||
| Symbol::NUM_NAT
|
||||
| Symbol::NUM_F32
|
||||
| Symbol::NUM_F64
|
||||
| Symbol::NUM_DEC,
|
||||
| Symbol::NUM_DEC
|
||||
| Symbol::NUM_NUM,
|
||||
_,
|
||||
_,
|
||||
_,
|
||||
) => {
|
||||
// yes
|
||||
}
|
||||
Alias(name, _, _, AliasKind::Opaque) => {
|
||||
let opaque = *name;
|
||||
if self
|
||||
.check_opaque_and_read(subs, opaque, Symbol::ENCODE_ENCODING)
|
||||
.is_err()
|
||||
{
|
||||
return Err(var);
|
||||
}
|
||||
}
|
||||
Alias(_, arguments, real_type_var, _) => {
|
||||
push_var_slice!(arguments.all_variables());
|
||||
stack.push(*real_type_var);
|
||||
|
|
|
@ -2233,7 +2233,10 @@ fn make_specialization_decision(subs: &Subs, var: Variable) -> SpecializeDecisio
|
|||
use Content::*;
|
||||
use SpecializationTypeKey::*;
|
||||
match subs.get_content_without_compacting(var) {
|
||||
Structure(_) | Alias(_, _, _, AliasKind::Structural) => {
|
||||
Alias(opaque, _, _, AliasKind::Opaque) if opaque.module_id() != ModuleId::NUM => {
|
||||
SpecializeDecision::Specialize(Opaque(*opaque))
|
||||
}
|
||||
Structure(_) | Alias(_, _, _, _) => {
|
||||
// This is a structural type, find the name of the derived ability function it
|
||||
// should use.
|
||||
match roc_derive_key::Derived::encoding(subs, var) {
|
||||
|
@ -2258,7 +2261,6 @@ fn make_specialization_decision(subs: &Subs, var: Variable) -> SpecializeDecisio
|
|||
}
|
||||
}
|
||||
}
|
||||
Alias(opaque, _, _, AliasKind::Opaque) => SpecializeDecision::Specialize(Opaque(*opaque)),
|
||||
Error => SpecializeDecision::Drop,
|
||||
FlexAbleVar(_, _)
|
||||
| RigidAbleVar(..)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue