mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-30 23:31:12 +00:00
Get rid of RIGID_AS_FLEX unification mode
This was relevant when we checked numeric ranges using unification, but thanks to Folkert's refactoring, that is no longer necessary.
This commit is contained in:
parent
5f5f025e4c
commit
6a447f2333
1 changed files with 1 additions and 59 deletions
|
@ -99,13 +99,6 @@ bitflags! {
|
||||||
///
|
///
|
||||||
/// For example, t1 += [A Str] says we should "add" the tag "A Str" to the type of "t1".
|
/// For example, t1 += [A Str] says we should "add" the tag "A Str" to the type of "t1".
|
||||||
const PRESENT = 1 << 1;
|
const PRESENT = 1 << 1;
|
||||||
/// Instructs the unifier to treat rigids exactly like flex vars.
|
|
||||||
/// Usually rigids can only unify with flex vars, because rigids are named and bound
|
|
||||||
/// explicitly.
|
|
||||||
/// However, when checking type ranges, as we do for `RangedNumber` types, we must loosen
|
|
||||||
/// this restriction because otherwise an admissible range will appear inadmissible.
|
|
||||||
/// For example, Int * is in the range <I8, U8, ...>.
|
|
||||||
const RIGID_AS_FLEX = 1 << 2;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -126,11 +119,7 @@ impl Mode {
|
||||||
|
|
||||||
#[cfg(debug_assertions)]
|
#[cfg(debug_assertions)]
|
||||||
fn pretty_print(&self) -> &str {
|
fn pretty_print(&self) -> &str {
|
||||||
if self.contains(Mode::EQ | Mode::RIGID_AS_FLEX) {
|
if self.contains(Mode::EQ) {
|
||||||
"~*"
|
|
||||||
} else if self.contains(Mode::PRESENT | Mode::RIGID_AS_FLEX) {
|
|
||||||
"+=*"
|
|
||||||
} else if self.contains(Mode::EQ) {
|
|
||||||
"~"
|
"~"
|
||||||
} else if self.contains(Mode::PRESENT) {
|
} else if self.contains(Mode::PRESENT) {
|
||||||
"+="
|
"+="
|
||||||
|
@ -1928,19 +1917,6 @@ fn unify_rigid(
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
RigidVar(_)
|
|
||||||
| RecursionVar { .. }
|
|
||||||
| Structure(_)
|
|
||||||
| Alias(_, _, _, _)
|
|
||||||
| RangedNumber(..)
|
|
||||||
| LambdaSet(..)
|
|
||||||
if ctx.mode.contains(Mode::RIGID_AS_FLEX) =>
|
|
||||||
{
|
|
||||||
// Usually rigids can only unify with flex, but the mode indicates we are treating
|
|
||||||
// rigid vars as flex, so admit this.
|
|
||||||
merge(subs, ctx, *other)
|
|
||||||
}
|
|
||||||
|
|
||||||
RigidVar(_)
|
RigidVar(_)
|
||||||
| RigidAbleVar(..)
|
| RigidAbleVar(..)
|
||||||
| RecursionVar { .. }
|
| RecursionVar { .. }
|
||||||
|
@ -1990,40 +1966,6 @@ fn unify_rigid_able(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
RigidVar(_)
|
|
||||||
| RecursionVar { .. }
|
|
||||||
| Structure(_)
|
|
||||||
| Alias(_, _, _, _)
|
|
||||||
| RangedNumber(..)
|
|
||||||
| LambdaSet(..)
|
|
||||||
if ctx.mode.contains(Mode::RIGID_AS_FLEX) =>
|
|
||||||
{
|
|
||||||
// Usually rigids can only unify with flex, but the mode indicates we are treating
|
|
||||||
// rigid vars as flex, so admit this.
|
|
||||||
match other {
|
|
||||||
Alias(opaque_name, vars, _real_var, AliasKind::Opaque) if vars.is_empty() => {
|
|
||||||
let mut output = merge(subs, ctx, *other);
|
|
||||||
let must_implement_ability = MustImplementAbility {
|
|
||||||
typ: Obligated::Opaque(*opaque_name),
|
|
||||||
ability,
|
|
||||||
};
|
|
||||||
output.must_implement_ability.push(must_implement_ability);
|
|
||||||
output
|
|
||||||
}
|
|
||||||
|
|
||||||
// these have underscores because they're unused in --release builds
|
|
||||||
_other => {
|
|
||||||
// For now, only allow opaque types with no type variables to implement abilities.
|
|
||||||
mismatch!(
|
|
||||||
%not_able, ctx.second, ability,
|
|
||||||
"RigidAble {:?} with non-opaque or opaque with type variables {:?}",
|
|
||||||
ctx.first,
|
|
||||||
&_other
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
RigidVar(_)
|
RigidVar(_)
|
||||||
| RigidAbleVar(..)
|
| RigidAbleVar(..)
|
||||||
| RecursionVar { .. }
|
| RecursionVar { .. }
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue