mirror of
https://github.com/roc-lang/roc.git
synced 2025-10-01 15:51:12 +00:00
Merge pull request #2838 from rtfeldman/abilities-typechecking
Inference and checking for abilities
This commit is contained in:
commit
4ea4aa4708
46 changed files with 2432 additions and 530 deletions
|
@ -3,6 +3,7 @@ use bumpalo::collections::Vec;
|
|||
use bumpalo::Bump;
|
||||
use roc_builtins::bitcode::{FloatWidth, IntWidth};
|
||||
use roc_collections::all::{default_hasher, MutMap};
|
||||
use roc_error_macros::todo_abilities;
|
||||
use roc_module::ident::{Lowercase, TagName};
|
||||
use roc_module::symbol::{Interns, Symbol};
|
||||
use roc_problem::can::RuntimeError;
|
||||
|
@ -72,6 +73,7 @@ impl<'a> RawFunctionLayout<'a> {
|
|||
use roc_types::subs::Content::*;
|
||||
match content {
|
||||
FlexVar(_) | RigidVar(_) => Err(LayoutProblem::UnresolvedTypeVar(var)),
|
||||
FlexAbleVar(_, _) | RigidAbleVar(_, _) => todo_abilities!("Not reachable yet"),
|
||||
RecursionVar { structure, .. } => {
|
||||
let structure_content = env.subs.get_content_without_compacting(structure);
|
||||
Self::new_help(env, structure, *structure_content)
|
||||
|
@ -952,6 +954,7 @@ impl<'a> Layout<'a> {
|
|||
use roc_types::subs::Content::*;
|
||||
match content {
|
||||
FlexVar(_) | RigidVar(_) => Err(LayoutProblem::UnresolvedTypeVar(var)),
|
||||
FlexAbleVar(_, _) | RigidAbleVar(_, _) => todo_abilities!("Not reachable yet"),
|
||||
RecursionVar { structure, .. } => {
|
||||
let structure_content = env.subs.get_content_without_compacting(structure);
|
||||
Self::new_help(env, structure, *structure_content)
|
||||
|
@ -2661,6 +2664,7 @@ fn layout_from_num_content<'a>(
|
|||
// (e.g. for (5 + 5) assume both 5s are 64-bit integers.)
|
||||
Ok(Layout::default_integer())
|
||||
}
|
||||
FlexAbleVar(_, _) | RigidAbleVar(_, _) => todo_abilities!("Not reachable yet"),
|
||||
Structure(Apply(symbol, args)) => match *symbol {
|
||||
// Ints
|
||||
Symbol::NUM_NAT => Ok(Layout::usize(target_info)),
|
||||
|
|
|
@ -137,8 +137,10 @@ impl FunctionLayout {
|
|||
use LayoutError::*;
|
||||
|
||||
match content {
|
||||
Content::FlexVar(_) => Err(UnresolvedVariable(var)),
|
||||
Content::RigidVar(_) => Err(UnresolvedVariable(var)),
|
||||
Content::FlexVar(_)
|
||||
| Content::RigidVar(_)
|
||||
| Content::FlexAbleVar(_, _)
|
||||
| Content::RigidAbleVar(_, _) => Err(UnresolvedVariable(var)),
|
||||
Content::RecursionVar { .. } => Err(TypeError(())),
|
||||
Content::Structure(flat_type) => Self::from_flat_type(layouts, subs, flat_type),
|
||||
Content::Alias(_, _, actual, _) => Self::from_var_help(layouts, subs, *actual),
|
||||
|
@ -243,8 +245,10 @@ impl LambdaSet {
|
|||
use LayoutError::*;
|
||||
|
||||
match content {
|
||||
Content::FlexVar(_) => Err(UnresolvedVariable(var)),
|
||||
Content::RigidVar(_) => Err(UnresolvedVariable(var)),
|
||||
Content::FlexVar(_)
|
||||
| Content::RigidVar(_)
|
||||
| Content::FlexAbleVar(_, _)
|
||||
| Content::RigidAbleVar(_, _) => Err(UnresolvedVariable(var)),
|
||||
Content::RecursionVar { .. } => {
|
||||
unreachable!("lambda sets cannot currently be recursive")
|
||||
}
|
||||
|
@ -627,8 +631,10 @@ impl Layout {
|
|||
use LayoutError::*;
|
||||
|
||||
match content {
|
||||
Content::FlexVar(_) => Err(UnresolvedVariable(var)),
|
||||
Content::RigidVar(_) => Err(UnresolvedVariable(var)),
|
||||
Content::FlexVar(_)
|
||||
| Content::RigidVar(_)
|
||||
| Content::FlexAbleVar(_, _)
|
||||
| Content::RigidAbleVar(_, _) => Err(UnresolvedVariable(var)),
|
||||
Content::RecursionVar {
|
||||
structure,
|
||||
opt_name: _,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue