mirror of
https://github.com/roc-lang/roc.git
synced 2024-11-13 09:49:11 +03:00
Add AbilityMember can variant for resolving ability specializations
This commit is contained in:
parent
ebbcd57022
commit
edee222763
@ -21,6 +21,7 @@ use roc_region::all::{Loc, Region};
|
||||
use roc_types::subs::{ExhaustiveMark, RedundantMark, VarStore, Variable};
|
||||
use roc_types::types::{Alias, Category, LambdaSet, OptAbleVar, Type};
|
||||
use std::fmt::{Debug, Display};
|
||||
use std::sync::{Arc, Mutex};
|
||||
use std::{char, u32};
|
||||
|
||||
#[derive(Clone, Default, Debug)]
|
||||
@ -83,6 +84,13 @@ pub enum Expr {
|
||||
|
||||
// Lookups
|
||||
Var(Symbol),
|
||||
AbilityMember(
|
||||
/// Actual member name
|
||||
Symbol,
|
||||
/// Specialization to use
|
||||
Arc<Mutex<Option<Symbol>>>,
|
||||
),
|
||||
|
||||
// Branching
|
||||
When {
|
||||
/// The actual condition of the when expression.
|
||||
@ -213,6 +221,7 @@ impl Expr {
|
||||
Self::SingleQuote(..) => Category::Character,
|
||||
Self::List { .. } => Category::List,
|
||||
&Self::Var(sym) => Category::Lookup(sym),
|
||||
&Self::AbilityMember(sym, _) => Category::Lookup(sym),
|
||||
Self::When { .. } => Category::When,
|
||||
Self::If { .. } => Category::If,
|
||||
Self::LetRec(_, expr) => expr.value.category(),
|
||||
@ -1368,6 +1377,7 @@ pub fn inline_calls(var_store: &mut VarStore, scope: &mut Scope, expr: Expr) ->
|
||||
| other @ Accessor { .. }
|
||||
| other @ Update { .. }
|
||||
| other @ Var(_)
|
||||
| other @ AbilityMember(..)
|
||||
| other @ RunLowLevel { .. }
|
||||
| other @ ForeignCall { .. } => other,
|
||||
|
||||
|
@ -704,6 +704,7 @@ fn fix_values_captured_in_closure_expr(
|
||||
| Str(_)
|
||||
| SingleQuote(_)
|
||||
| Var(_)
|
||||
| AbilityMember(..)
|
||||
| EmptyRecord
|
||||
| RuntimeError(_)
|
||||
| ZeroArgumentTag { .. }
|
||||
|
@ -336,6 +336,11 @@ pub fn constrain_expr(
|
||||
// make lookup constraint to lookup this symbol's type in the environment
|
||||
constraints.lookup(*symbol, expected, region)
|
||||
}
|
||||
AbilityMember(symbol, _specialization) => {
|
||||
// make lookup constraint to lookup this symbol's type in the environment
|
||||
constraints.lookup(*symbol, expected, region)
|
||||
// TODO: consider trying to solve `_specialization` here.
|
||||
}
|
||||
Closure(ClosureData {
|
||||
function_type: fn_var,
|
||||
closure_type: closure_var,
|
||||
|
@ -15,7 +15,7 @@ use roc_debug_flags::{
|
||||
dbg_do, ROC_PRINT_IR_AFTER_REFCOUNT, ROC_PRINT_IR_AFTER_RESET_REUSE,
|
||||
ROC_PRINT_IR_AFTER_SPECIALIZATION,
|
||||
};
|
||||
use roc_error_macros::internal_error;
|
||||
use roc_error_macros::{internal_error, todo_abilities};
|
||||
use roc_exhaustive::{Ctor, CtorName, Guard, RenderAs, TagId};
|
||||
use roc_module::ident::{ForeignSymbol, Lowercase, TagName};
|
||||
use roc_module::low_level::LowLevel;
|
||||
@ -3564,6 +3564,7 @@ pub fn with_hole<'a>(
|
||||
|
||||
specialize_naked_symbol(env, variable, procs, layout_cache, assigned, hole, symbol)
|
||||
}
|
||||
AbilityMember(..) => todo_abilities!(),
|
||||
Tag {
|
||||
variant_var,
|
||||
name: tag_name,
|
||||
|
Loading…
Reference in New Issue
Block a user