Merge remote-tracking branch 'origin/trunk' into specialize-separately

This commit is contained in:
Richard Feldman 2020-06-13 23:54:30 -04:00
commit 1b3b9ee1c4
22 changed files with 499 additions and 465 deletions

View file

@ -430,19 +430,19 @@ pub fn uniq_expr_with(
loc_expr, loc_expr,
output, output,
problems, problems,
var_store: old_var_store, var_store: mut old_var_store,
var, var,
interns, interns,
.. ..
} = can_expr_with(arena, home, expr_str)?; } = can_expr_with(arena, home, expr_str)?;
// double check // double check
let var_store = VarStore::new(old_var_store.fresh()); let mut var_store = VarStore::new(old_var_store.fresh());
let expected2 = Expected::NoExpectation(Type::Variable(var)); let expected2 = Expected::NoExpectation(Type::Variable(var));
let constraint = roc_constrain::uniq::constrain_declaration( let constraint = roc_constrain::uniq::constrain_declaration(
home, home,
&var_store, &mut var_store,
Region::zero(), Region::zero(),
&loc_expr, &loc_expr,
declared_idents, declared_idents,
@ -464,12 +464,12 @@ pub fn uniq_expr_with(
// TODO what to do with those rigids? // TODO what to do with those rigids?
let (_introduced_rigids, constraint) = let (_introduced_rigids, constraint) =
constrain_imported_values(imports, constraint, &var_store); constrain_imported_values(imports, constraint, &mut var_store);
// load builtin types // load builtin types
let mut constraint = load_builtin_aliases(stdlib.aliases, constraint, &var_store); let mut constraint = load_builtin_aliases(stdlib.aliases, constraint, &mut var_store);
constraint.instantiate_aliases(&var_store); constraint.instantiate_aliases(&mut var_store);
let subs2 = Subs::new(var_store.into()); let subs2 = Subs::new(var_store.into());
@ -491,7 +491,7 @@ pub struct CanExprOut {
pub fn can_expr_with(arena: &Bump, home: ModuleId, expr_str: &str) -> Result<CanExprOut, Fail> { pub fn can_expr_with(arena: &Bump, home: ModuleId, expr_str: &str) -> Result<CanExprOut, Fail> {
let loc_expr = parse_loc_with(&arena, expr_str)?; let loc_expr = parse_loc_with(&arena, expr_str)?;
let var_store = VarStore::default(); let mut var_store = VarStore::default();
let var = var_store.fresh(); let var = var_store.fresh();
let expected = Expected::NoExpectation(Type::Variable(var)); let expected = Expected::NoExpectation(Type::Variable(var));
let module_ids = ModuleIds::default(); let module_ids = ModuleIds::default();
@ -510,7 +510,7 @@ pub fn can_expr_with(arena: &Bump, home: ModuleId, expr_str: &str) -> Result<Can
let mut env = Env::new(home, dep_idents, &module_ids, IdentIds::default()); let mut env = Env::new(home, dep_idents, &module_ids, IdentIds::default());
let (loc_expr, output) = canonicalize_expr( let (loc_expr, output) = canonicalize_expr(
&mut env, &mut env,
&var_store, &mut var_store,
&mut scope, &mut scope,
Region::zero(), Region::zero(),
&loc_expr.value, &loc_expr.value,
@ -538,7 +538,7 @@ pub fn can_expr_with(arena: &Bump, home: ModuleId, expr_str: &str) -> Result<Can
//load builtin values //load builtin values
let (_introduced_rigids, constraint) = let (_introduced_rigids, constraint) =
constrain_imported_values(imports, constraint, &var_store); constrain_imported_values(imports, constraint, &mut var_store);
// TODO determine what to do with those rigids // TODO determine what to do with those rigids
// for var in introduced_rigids { // for var in introduced_rigids {
@ -546,9 +546,10 @@ pub fn can_expr_with(arena: &Bump, home: ModuleId, expr_str: &str) -> Result<Can
// } // }
//load builtin types //load builtin types
let mut constraint = load_builtin_aliases(roc_builtins::std::aliases(), constraint, &var_store); let mut constraint =
load_builtin_aliases(roc_builtins::std::aliases(), constraint, &mut var_store);
constraint.instantiate_aliases(&var_store); constraint.instantiate_aliases(&mut var_store);
let mut all_ident_ids = MutMap::default(); let mut all_ident_ids = MutMap::default();

View file

@ -65,7 +65,7 @@ pub fn canonicalize_annotation(
scope: &mut Scope, scope: &mut Scope,
annotation: &roc_parse::ast::TypeAnnotation, annotation: &roc_parse::ast::TypeAnnotation,
region: Region, region: Region,
var_store: &VarStore, var_store: &mut VarStore,
) -> Annotation { ) -> Annotation {
let mut introduced_variables = IntroducedVariables::default(); let mut introduced_variables = IntroducedVariables::default();
let mut aliases = SendMap::default(); let mut aliases = SendMap::default();
@ -95,7 +95,7 @@ fn can_annotation_help(
annotation: &roc_parse::ast::TypeAnnotation, annotation: &roc_parse::ast::TypeAnnotation,
region: Region, region: Region,
scope: &mut Scope, scope: &mut Scope,
var_store: &VarStore, var_store: &mut VarStore,
introduced_variables: &mut IntroducedVariables, introduced_variables: &mut IntroducedVariables,
local_aliases: &mut SendMap<Symbol, Alias>, local_aliases: &mut SendMap<Symbol, Alias>,
references: &mut MutSet<Symbol>, references: &mut MutSet<Symbol>,
@ -407,7 +407,7 @@ fn can_assigned_field<'a>(
field: &AssignedField<'a, TypeAnnotation<'a>>, field: &AssignedField<'a, TypeAnnotation<'a>>,
region: Region, region: Region,
scope: &mut Scope, scope: &mut Scope,
var_store: &VarStore, var_store: &mut VarStore,
introduced_variables: &mut IntroducedVariables, introduced_variables: &mut IntroducedVariables,
local_aliases: &mut SendMap<Symbol, Alias>, local_aliases: &mut SendMap<Symbol, Alias>,
field_types: &mut SendMap<Lowercase, Type>, field_types: &mut SendMap<Lowercase, Type>,
@ -472,7 +472,7 @@ fn can_tag<'a>(
tag: &Tag<'a>, tag: &Tag<'a>,
region: Region, region: Region,
scope: &mut Scope, scope: &mut Scope,
var_store: &VarStore, var_store: &mut VarStore,
introduced_variables: &mut IntroducedVariables, introduced_variables: &mut IntroducedVariables,
local_aliases: &mut SendMap<Symbol, Alias>, local_aliases: &mut SendMap<Symbol, Alias>,
tag_types: &mut Vec<(TagName, Vec<Type>)>, tag_types: &mut Vec<(TagName, Vec<Type>)>,

View file

@ -24,7 +24,7 @@ use roc_types::subs::{VarStore, Variable};
/// delegates to the compiler-internal List.getUnsafe function to do the actual /// delegates to the compiler-internal List.getUnsafe function to do the actual
/// lookup (if the bounds check passed). That internal function is hardcoded in code gen, /// lookup (if the bounds check passed). That internal function is hardcoded in code gen,
/// which works fine because it doesn't involve any open tag unions. /// which works fine because it doesn't involve any open tag unions.
pub fn builtin_defs(var_store: &VarStore) -> MutMap<Symbol, Expr> { pub fn builtin_defs(var_store: &mut VarStore) -> MutMap<Symbol, Expr> {
mut_map! { mut_map! {
Symbol::LIST_LEN => list_len(var_store), Symbol::LIST_LEN => list_len(var_store),
Symbol::LIST_GET => list_get(var_store), Symbol::LIST_GET => list_get(var_store),
@ -45,14 +45,10 @@ pub fn builtin_defs(var_store: &VarStore) -> MutMap<Symbol, Expr> {
} }
/// Float.tan : Float -> Float /// Float.tan : Float -> Float
fn float_tan(var_store: &VarStore) -> Expr { fn float_tan(var_store: &mut VarStore) -> Expr {
use crate::expr::Expr::*; use crate::expr::Expr::*;
defn( let body = call(
Symbol::FLOAT_TAN,
vec![Symbol::FLOAT_TAN_ARG],
var_store,
call(
Symbol::FLOAT_DIV, Symbol::FLOAT_DIV,
vec![ vec![
call( call(
@ -67,124 +63,138 @@ fn float_tan(var_store: &VarStore) -> Expr {
), ),
], ],
var_store, var_store,
), );
defn(
Symbol::FLOAT_TAN,
vec![Symbol::FLOAT_TAN_ARG],
var_store,
body,
) )
} }
/// Float.isZero : Float -> Bool /// Float.isZero : Float -> Bool
fn float_is_zero(var_store: &VarStore) -> Expr { fn float_is_zero(var_store: &mut VarStore) -> Expr {
use crate::expr::Expr::*; use crate::expr::Expr::*;
defn( let body = call(
Symbol::FLOAT_IS_ZERO,
vec![Symbol::FLOAT_IS_ZERO_ARG],
var_store,
call(
Symbol::FLOAT_EQ, Symbol::FLOAT_EQ,
vec![ vec![
Float(var_store.fresh(), 0.0), Float(var_store.fresh(), 0.0),
Var(Symbol::FLOAT_IS_ZERO_ARG), Var(Symbol::FLOAT_IS_ZERO_ARG),
], ],
var_store, var_store,
), );
defn(
Symbol::FLOAT_IS_ZERO,
vec![Symbol::FLOAT_IS_ZERO_ARG],
var_store,
body,
) )
} }
/// Float.isNegative : Float -> Bool /// Float.isNegative : Float -> Bool
fn float_is_negative(var_store: &VarStore) -> Expr { fn float_is_negative(var_store: &mut VarStore) -> Expr {
use crate::expr::Expr::*; use crate::expr::Expr::*;
defn( let body = call(
Symbol::FLOAT_IS_NEGATIVE,
vec![Symbol::FLOAT_IS_NEGATIVE_ARG],
var_store,
call(
Symbol::FLOAT_GT, Symbol::FLOAT_GT,
vec![ vec![
Float(var_store.fresh(), 0.0), Float(var_store.fresh(), 0.0),
Var(Symbol::FLOAT_IS_NEGATIVE_ARG), Var(Symbol::FLOAT_IS_NEGATIVE_ARG),
], ],
var_store, var_store,
), );
defn(
Symbol::FLOAT_IS_NEGATIVE,
vec![Symbol::FLOAT_IS_NEGATIVE_ARG],
var_store,
body,
) )
} }
/// Float.isPositive : Float -> Bool /// Float.isPositive : Float -> Bool
fn float_is_positive(var_store: &VarStore) -> Expr { fn float_is_positive(var_store: &mut VarStore) -> Expr {
use crate::expr::Expr::*; use crate::expr::Expr::*;
defn( let body = call(
Symbol::FLOAT_IS_POSITIVE,
vec![Symbol::FLOAT_IS_POSITIVE_ARG],
var_store,
call(
Symbol::FLOAT_GT, Symbol::FLOAT_GT,
vec![ vec![
Var(Symbol::FLOAT_IS_POSITIVE_ARG), Var(Symbol::FLOAT_IS_POSITIVE_ARG),
Float(var_store.fresh(), 0.0), Float(var_store.fresh(), 0.0),
], ],
var_store, var_store,
), );
defn(
Symbol::FLOAT_IS_POSITIVE,
vec![Symbol::FLOAT_IS_POSITIVE_ARG],
var_store,
body,
) )
} }
/// Int.isNegative : Int -> Bool /// Int.isNegative : Int -> Bool
fn int_is_negative(var_store: &VarStore) -> Expr { fn int_is_negative(var_store: &mut VarStore) -> Expr {
use crate::expr::Expr::*; use crate::expr::Expr::*;
let body = call(
Symbol::NUM_LT,
vec![Var(Symbol::INT_IS_NEGATIVE_ARG), Int(var_store.fresh(), 0)],
var_store,
);
defn( defn(
Symbol::INT_IS_NEGATIVE, Symbol::INT_IS_NEGATIVE,
vec![Symbol::INT_IS_NEGATIVE_ARG], vec![Symbol::INT_IS_NEGATIVE_ARG],
var_store, var_store,
call( body,
Symbol::NUM_LT,
vec![Var(Symbol::INT_IS_NEGATIVE_ARG), Int(var_store.fresh(), 0)],
var_store,
),
) )
} }
/// Int.isPositive : Int -> Bool /// Int.isPositive : Int -> Bool
fn int_is_positive(var_store: &VarStore) -> Expr { fn int_is_positive(var_store: &mut VarStore) -> Expr {
use crate::expr::Expr::*; use crate::expr::Expr::*;
let body = call(
Symbol::NUM_GT,
vec![Var(Symbol::INT_IS_POSITIVE_ARG), Int(var_store.fresh(), 0)],
var_store,
);
defn( defn(
Symbol::INT_IS_POSITIVE, Symbol::INT_IS_POSITIVE,
vec![Symbol::INT_IS_POSITIVE_ARG], vec![Symbol::INT_IS_POSITIVE_ARG],
var_store, var_store,
call( body,
Symbol::NUM_GT,
vec![Var(Symbol::INT_IS_POSITIVE_ARG), Int(var_store.fresh(), 0)],
var_store,
),
) )
} }
/// Int.isZero : Int -> Bool /// Int.isZero : Int -> Bool
fn int_is_zero(var_store: &VarStore) -> Expr { fn int_is_zero(var_store: &mut VarStore) -> Expr {
use crate::expr::Expr::*; use crate::expr::Expr::*;
let body = call(
Symbol::INT_EQ_I64,
vec![Var(Symbol::INT_IS_ZERO_ARG), Int(var_store.fresh(), 0)],
var_store,
);
defn( defn(
Symbol::INT_IS_ZERO, Symbol::INT_IS_ZERO,
vec![Symbol::INT_IS_ZERO_ARG], vec![Symbol::INT_IS_ZERO_ARG],
var_store, var_store,
call( body,
Symbol::INT_EQ_I64,
vec![Var(Symbol::INT_IS_ZERO_ARG), Int(var_store.fresh(), 0)],
var_store,
),
) )
} }
/// Int.isOdd : Int -> Bool /// Int.isOdd : Int -> Bool
fn int_is_odd(var_store: &VarStore) -> Expr { fn int_is_odd(var_store: &mut VarStore) -> Expr {
use crate::expr::Expr::*; use crate::expr::Expr::*;
defn( let body = call(
Symbol::INT_IS_ODD,
vec![Symbol::INT_IS_ODD_ARG],
var_store,
call(
Symbol::INT_EQ_I64, Symbol::INT_EQ_I64,
vec![ vec![
call( call(
@ -195,19 +205,21 @@ fn int_is_odd(var_store: &VarStore) -> Expr {
Int(var_store.fresh(), 1), Int(var_store.fresh(), 1),
], ],
var_store, var_store,
), );
defn(
Symbol::INT_IS_ODD,
vec![Symbol::INT_IS_ODD_ARG],
var_store,
body,
) )
} }
/// Int.isEven : Int -> Bool /// Int.isEven : Int -> Bool
fn int_is_even(var_store: &VarStore) -> Expr { fn int_is_even(var_store: &mut VarStore) -> Expr {
use crate::expr::Expr::*; use crate::expr::Expr::*;
defn( let body = call(
Symbol::INT_IS_EVEN,
vec![Symbol::INT_IS_EVEN_ARG],
var_store,
call(
Symbol::INT_EQ_I64, Symbol::INT_EQ_I64,
vec![ vec![
call( call(
@ -218,12 +230,18 @@ fn int_is_even(var_store: &VarStore) -> Expr {
Int(var_store.fresh(), 0), Int(var_store.fresh(), 0),
], ],
var_store, var_store,
), );
defn(
Symbol::INT_IS_EVEN,
vec![Symbol::INT_IS_EVEN_ARG],
var_store,
body,
) )
} }
/// List.len : List * -> Int /// List.len : List * -> Int
fn list_len(var_store: &VarStore) -> Expr { fn list_len(var_store: &mut VarStore) -> Expr {
use crate::expr::Expr::*; use crate::expr::Expr::*;
// Polymorphic wrapper around LowLevel::ListLen // Polymorphic wrapper around LowLevel::ListLen
@ -238,15 +256,11 @@ fn list_len(var_store: &VarStore) -> Expr {
} }
/// List.get : List elem, Int -> Result elem [ OutOfBounds ]* /// List.get : List elem, Int -> Result elem [ OutOfBounds ]*
fn list_get(var_store: &VarStore) -> Expr { fn list_get(var_store: &mut VarStore) -> Expr {
use crate::expr::Expr::*; use crate::expr::Expr::*;
defn(
Symbol::LIST_GET,
vec![Symbol::LIST_GET_ARG_LIST, Symbol::LIST_GET_ARG_INDEX],
var_store,
// Perform a bounds check. If it passes, delegate to List.#getUnsafe // Perform a bounds check. If it passes, delegate to List.#getUnsafe
If { let body = If {
cond_var: var_store.fresh(), cond_var: var_store.fresh(),
branch_var: var_store.fresh(), branch_var: var_store.fresh(),
branches: vec![( branches: vec![(
@ -257,9 +271,11 @@ fn list_get(var_store: &VarStore) -> Expr {
Symbol::NUM_LT, Symbol::NUM_LT,
vec![ vec![
Var(Symbol::LIST_GET_ARG_INDEX), Var(Symbol::LIST_GET_ARG_INDEX),
RunLowLevel(LowLevel::ListLen { call(
arg: Symbol::LIST_GET_ARG_LIST, Symbol::LIST_LEN,
}), vec![Var(Symbol::LIST_GET_ARG_LIST)],
var_store,
),
], ],
var_store, var_store,
), ),
@ -302,19 +318,20 @@ fn list_get(var_store: &VarStore) -> Expr {
), ),
), ),
), ),
}, };
)
}
/// Int.rem : Int, Int -> Int
fn int_rem(var_store: &VarStore) -> Expr {
use crate::expr::Expr::*;
defn( defn(
Symbol::INT_REM, Symbol::LIST_GET,
vec![Symbol::INT_REM_ARG_0, Symbol::INT_REM_ARG_1], vec![Symbol::LIST_GET_ARG_LIST, Symbol::LIST_GET_ARG_INDEX],
var_store, var_store,
If { body,
)
}
/// Int.rem : Int, Int -> Int
fn int_rem(var_store: &mut VarStore) -> Expr {
use crate::expr::Expr::*;
let body = If {
branch_var: var_store.fresh(), branch_var: var_store.fresh(),
cond_var: var_store.fresh(), cond_var: var_store.fresh(),
branches: vec![( branches: vec![(
@ -349,19 +366,21 @@ fn int_rem(var_store: &VarStore) -> Expr {
vec![tag("DivByZero", Vec::new(), var_store)], vec![tag("DivByZero", Vec::new(), var_store)],
var_store, var_store,
))), ))),
}, };
defn(
Symbol::INT_REM,
vec![Symbol::INT_REM_ARG_0, Symbol::INT_REM_ARG_1],
var_store,
body,
) )
} }
/// Int.abs : Int -> Int /// Int.abs : Int -> Int
fn int_abs(var_store: &VarStore) -> Expr { fn int_abs(var_store: &mut VarStore) -> Expr {
use crate::expr::Expr::*; use crate::expr::Expr::*;
defn( let body = If {
Symbol::INT_ABS,
vec![Symbol::INT_ABS_ARG],
var_store,
If {
branch_var: var_store.fresh(), branch_var: var_store.fresh(),
cond_var: var_store.fresh(), cond_var: var_store.fresh(),
branches: vec![( branches: vec![(
@ -386,22 +405,16 @@ fn int_abs(var_store: &VarStore) -> Expr {
var_store, var_store,
)), )),
), ),
}, };
)
defn(Symbol::INT_ABS, vec![Symbol::INT_ABS_ARG], var_store, body)
} }
/// Int.div : Int, Int -> Result Int [ DivByZero ]* /// Int.div : Int, Int -> Result Int [ DivByZero ]*
fn int_div(var_store: &VarStore) -> Expr { fn int_div(var_store: &mut VarStore) -> Expr {
use crate::expr::Expr::*; use crate::expr::Expr::*;
defn( let body = If {
Symbol::INT_DIV,
vec![
Symbol::INT_DIV_ARG_NUMERATOR,
Symbol::INT_DIV_ARG_DENOMINATOR,
],
var_store,
If {
branch_var: var_store.fresh(), branch_var: var_store.fresh(),
cond_var: var_store.fresh(), cond_var: var_store.fresh(),
branches: vec![( branches: vec![(
@ -445,20 +458,25 @@ fn int_div(var_store: &VarStore) -> Expr {
var_store, var_store,
)), )),
), ),
}, };
defn(
Symbol::INT_DIV,
vec![
Symbol::INT_DIV_ARG_NUMERATOR,
Symbol::INT_DIV_ARG_DENOMINATOR,
],
var_store,
body,
) )
} }
/// List.first : List elem -> Result elem [ ListWasEmpty ]* /// List.first : List elem -> Result elem [ ListWasEmpty ]*
fn list_first(var_store: &VarStore) -> Expr { fn list_first(var_store: &mut VarStore) -> Expr {
use crate::expr::Expr::*; use crate::expr::Expr::*;
defn(
Symbol::LIST_FIRST,
vec![Symbol::LIST_FIRST_ARG],
var_store,
// Perform a bounds check. If it passes, delegate to List.getUnsafe. // Perform a bounds check. If it passes, delegate to List.getUnsafe.
If { let body = If {
// TODO Use "when" instead of "if" so that we can have False be the first branch. // TODO Use "when" instead of "if" so that we can have False be the first branch.
// We want that for branch prediction; usually we expect the list to be nonempty. // We want that for branch prediction; usually we expect the list to be nonempty.
cond_var: var_store.fresh(), cond_var: var_store.fresh(),
@ -501,7 +519,13 @@ fn list_first(var_store: &VarStore) -> Expr {
), ),
), ),
), ),
}, };
defn(
Symbol::LIST_FIRST,
vec![Symbol::LIST_FIRST_ARG],
var_store,
body,
) )
} }
@ -514,7 +538,7 @@ fn no_region<T>(value: T) -> Located<T> {
} }
#[inline(always)] #[inline(always)]
fn tag(name: &'static str, args: Vec<Expr>, var_store: &VarStore) -> Expr { fn tag(name: &'static str, args: Vec<Expr>, var_store: &mut VarStore) -> Expr {
Expr::Tag { Expr::Tag {
variant_var: var_store.fresh(), variant_var: var_store.fresh(),
ext_var: var_store.fresh(), ext_var: var_store.fresh(),
@ -527,7 +551,7 @@ fn tag(name: &'static str, args: Vec<Expr>, var_store: &VarStore) -> Expr {
} }
#[inline(always)] #[inline(always)]
fn call(symbol: Symbol, args: Vec<Expr>, var_store: &VarStore) -> Expr { fn call(symbol: Symbol, args: Vec<Expr>, var_store: &mut VarStore) -> Expr {
Expr::Call( Expr::Call(
Box::new(( Box::new((
var_store.fresh(), var_store.fresh(),
@ -542,7 +566,7 @@ fn call(symbol: Symbol, args: Vec<Expr>, var_store: &VarStore) -> Expr {
} }
#[inline(always)] #[inline(always)]
fn defn(fn_name: Symbol, args: Vec<Symbol>, var_store: &VarStore, body: Expr) -> Expr { fn defn(fn_name: Symbol, args: Vec<Symbol>, var_store: &mut VarStore, body: Expr) -> Expr {
use crate::expr::Expr::*; use crate::expr::Expr::*;
use crate::pattern::Pattern::*; use crate::pattern::Pattern::*;

View file

@ -17,14 +17,14 @@ pub enum Constraint {
} }
impl Constraint { impl Constraint {
pub fn instantiate_aliases(&mut self, var_store: &VarStore) { pub fn instantiate_aliases(&mut self, var_store: &mut VarStore) {
Self::instantiate_aliases_help(self, &ImMap::default(), var_store, &mut ImSet::default()) Self::instantiate_aliases_help(self, &ImMap::default(), var_store, &mut ImSet::default())
} }
fn instantiate_aliases_help( fn instantiate_aliases_help(
&mut self, &mut self,
aliases: &ImMap<Symbol, Alias>, aliases: &ImMap<Symbol, Alias>,
var_store: &VarStore, var_store: &mut VarStore,
introduced: &mut ImSet<Variable>, introduced: &mut ImSet<Variable>,
) { ) {
use Constraint::*; use Constraint::*;

View file

@ -110,7 +110,7 @@ impl Declaration {
pub fn canonicalize_defs<'a>( pub fn canonicalize_defs<'a>(
env: &mut Env<'a>, env: &mut Env<'a>,
mut output: Output, mut output: Output,
var_store: &VarStore, var_store: &mut VarStore,
original_scope: &Scope, original_scope: &Scope,
loc_defs: &'a bumpalo::collections::Vec<'a, &'a Located<ast::Def<'a>>>, loc_defs: &'a bumpalo::collections::Vec<'a, &'a Located<ast::Def<'a>>>,
pattern_type: PatternType, pattern_type: PatternType,
@ -253,7 +253,7 @@ pub fn canonicalize_defs<'a>(
} }
} }
correct_mutual_recursive_type_alias(env, &mut aliases, &var_store); correct_mutual_recursive_type_alias(env, &mut aliases, var_store);
// Now that we have the scope completely assembled, and shadowing resolved, // Now that we have the scope completely assembled, and shadowing resolved,
// we're ready to canonicalize any body exprs. // we're ready to canonicalize any body exprs.
@ -725,7 +725,7 @@ fn canonicalize_pending_def<'a>(
mut output: Output, mut output: Output,
scope: &mut Scope, scope: &mut Scope,
can_defs_by_symbol: &mut MutMap<Symbol, Def>, can_defs_by_symbol: &mut MutMap<Symbol, Def>,
var_store: &VarStore, var_store: &mut VarStore,
refs_by_symbol: &mut MutMap<Symbol, (Located<Ident>, References)>, refs_by_symbol: &mut MutMap<Symbol, (Located<Ident>, References)>,
aliases: &mut SendMap<Symbol, Alias>, aliases: &mut SendMap<Symbol, Alias>,
) -> Output { ) -> Output {
@ -1184,7 +1184,7 @@ fn canonicalize_pending_def<'a>(
#[inline(always)] #[inline(always)]
pub fn can_defs_with_return<'a>( pub fn can_defs_with_return<'a>(
env: &mut Env<'a>, env: &mut Env<'a>,
var_store: &VarStore, var_store: &mut VarStore,
scope: Scope, scope: Scope,
loc_defs: &'a bumpalo::collections::Vec<'a, &'a Located<ast::Def<'a>>>, loc_defs: &'a bumpalo::collections::Vec<'a, &'a Located<ast::Def<'a>>>,
loc_ret: &'a Located<ast::Expr<'a>>, loc_ret: &'a Located<ast::Expr<'a>>,
@ -1236,7 +1236,7 @@ pub fn can_defs_with_return<'a>(
} }
fn decl_to_let( fn decl_to_let(
var_store: &VarStore, var_store: &mut VarStore,
decl: Declaration, decl: Declaration,
loc_ret: Located<Expr>, loc_ret: Located<Expr>,
aliases: SendMap<Symbol, Alias>, aliases: SendMap<Symbol, Alias>,
@ -1294,7 +1294,7 @@ fn closure_recursivity(symbol: Symbol, closures: &MutMap<Symbol, References>) ->
fn to_pending_def<'a>( fn to_pending_def<'a>(
env: &mut Env<'a>, env: &mut Env<'a>,
var_store: &VarStore, var_store: &mut VarStore,
def: &'a ast::Def<'a>, def: &'a ast::Def<'a>,
scope: &mut Scope, scope: &mut Scope,
pattern_type: PatternType, pattern_type: PatternType,
@ -1399,7 +1399,7 @@ fn pending_typed_body<'a>(
loc_pattern: &'a Located<ast::Pattern<'a>>, loc_pattern: &'a Located<ast::Pattern<'a>>,
loc_ann: &'a Located<ast::TypeAnnotation<'a>>, loc_ann: &'a Located<ast::TypeAnnotation<'a>>,
loc_expr: &'a Located<ast::Expr<'a>>, loc_expr: &'a Located<ast::Expr<'a>>,
var_store: &VarStore, var_store: &mut VarStore,
scope: &mut Scope, scope: &mut Scope,
pattern_type: PatternType, pattern_type: PatternType,
) -> PendingDef<'a> { ) -> PendingDef<'a> {
@ -1420,7 +1420,7 @@ fn pending_typed_body<'a>(
fn correct_mutual_recursive_type_alias<'a>( fn correct_mutual_recursive_type_alias<'a>(
env: &mut Env<'a>, env: &mut Env<'a>,
aliases: &mut SendMap<Symbol, Alias>, aliases: &mut SendMap<Symbol, Alias>,
var_store: &VarStore, var_store: &mut VarStore,
) { ) {
let mut symbols_introduced = ImSet::default(); let mut symbols_introduced = ImSet::default();
@ -1516,7 +1516,7 @@ fn make_tag_union_recursive<'a>(
region: Region, region: Region,
others: Vec<Symbol>, others: Vec<Symbol>,
typ: &mut Type, typ: &mut Type,
var_store: &VarStore, var_store: &mut VarStore,
can_report_error: &mut bool, can_report_error: &mut bool,
) { ) {
match typ { match typ {

View file

@ -170,7 +170,7 @@ pub struct WhenBranch {
pub fn canonicalize_expr<'a>( pub fn canonicalize_expr<'a>(
env: &mut Env<'a>, env: &mut Env<'a>,
var_store: &VarStore, var_store: &mut VarStore,
scope: &mut Scope, scope: &mut Scope,
region: Region, region: Region,
expr: &'a ast::Expr<'a>, expr: &'a ast::Expr<'a>,
@ -692,7 +692,7 @@ pub fn canonicalize_expr<'a>(
#[inline(always)] #[inline(always)]
fn canonicalize_when_branch<'a>( fn canonicalize_when_branch<'a>(
env: &mut Env<'a>, env: &mut Env<'a>,
var_store: &VarStore, var_store: &mut VarStore,
scope: &mut Scope, scope: &mut Scope,
_region: Region, _region: Region,
branch: &'a ast::WhenBranch<'a>, branch: &'a ast::WhenBranch<'a>,
@ -887,7 +887,7 @@ where
fn canonicalize_fields<'a>( fn canonicalize_fields<'a>(
env: &mut Env<'a>, env: &mut Env<'a>,
var_store: &VarStore, var_store: &mut VarStore,
scope: &mut Scope, scope: &mut Scope,
region: Region, region: Region,
fields: &'a [Located<ast::AssignedField<'a, ast::Expr<'a>>>], fields: &'a [Located<ast::AssignedField<'a, ast::Expr<'a>>>],
@ -924,7 +924,7 @@ fn canonicalize_fields<'a>(
fn canonicalize_field<'a>( fn canonicalize_field<'a>(
env: &mut Env<'a>, env: &mut Env<'a>,
var_store: &VarStore, var_store: &mut VarStore,
scope: &mut Scope, scope: &mut Scope,
field: &'a ast::AssignedField<'a, ast::Expr<'a>>, field: &'a ast::AssignedField<'a, ast::Expr<'a>>,
region: Region, region: Region,

View file

@ -49,7 +49,7 @@ pub fn canonicalize_module_defs<'a>(
dep_idents: MutMap<ModuleId, IdentIds>, dep_idents: MutMap<ModuleId, IdentIds>,
exposed_imports: MutMap<Ident, (Symbol, Region)>, exposed_imports: MutMap<Ident, (Symbol, Region)>,
mut exposed_symbols: MutSet<Symbol>, mut exposed_symbols: MutSet<Symbol>,
var_store: &VarStore, var_store: &mut VarStore,
) -> Result<ModuleOutput, RuntimeError> { ) -> Result<ModuleOutput, RuntimeError> {
let mut can_exposed_imports = MutMap::default(); let mut can_exposed_imports = MutMap::default();
let mut scope = Scope::new(home); let mut scope = Scope::new(home);

View file

@ -8,7 +8,7 @@ use std::i64;
#[inline(always)] #[inline(always)]
pub fn num_expr_from_result( pub fn num_expr_from_result(
var_store: &VarStore, var_store: &mut VarStore,
result: Result<i64, &str>, result: Result<i64, &str>,
env: &mut Env, env: &mut Env,
) -> Expr { ) -> Expr {
@ -29,7 +29,7 @@ pub fn num_expr_from_result(
#[inline(always)] #[inline(always)]
pub fn int_expr_from_result( pub fn int_expr_from_result(
var_store: &VarStore, var_store: &mut VarStore,
result: Result<i64, &str>, result: Result<i64, &str>,
env: &mut Env, env: &mut Env,
) -> Expr { ) -> Expr {
@ -48,7 +48,7 @@ pub fn int_expr_from_result(
#[inline(always)] #[inline(always)]
pub fn float_expr_from_result( pub fn float_expr_from_result(
var_store: &VarStore, var_store: &mut VarStore,
result: Result<f64, &str>, result: Result<f64, &str>,
env: &mut Env, env: &mut Env,
) -> Expr { ) -> Expr {

View file

@ -84,7 +84,7 @@ pub fn symbols_from_pattern_help(pattern: &Pattern, symbols: &mut Vec<Symbol>) {
pub fn canonicalize_pattern<'a>( pub fn canonicalize_pattern<'a>(
env: &mut Env<'a>, env: &mut Env<'a>,
var_store: &VarStore, var_store: &mut VarStore,
scope: &mut Scope, scope: &mut Scope,
pattern_type: PatternType, pattern_type: PatternType,
pattern: &ast::Pattern<'a>, pattern: &ast::Pattern<'a>,

View file

@ -60,7 +60,7 @@ pub fn can_expr_with(arena: &Bump, home: ModuleId, expr_str: &str) -> CanExprOut
) )
}); });
let var_store = VarStore::default(); let mut var_store = VarStore::default();
let var = var_store.fresh(); let var = var_store.fresh();
let module_ids = ModuleIds::default(); let module_ids = ModuleIds::default();
@ -78,7 +78,7 @@ pub fn can_expr_with(arena: &Bump, home: ModuleId, expr_str: &str) -> CanExprOut
let mut env = Env::new(home, dep_idents, &module_ids, IdentIds::default()); let mut env = Env::new(home, dep_idents, &module_ids, IdentIds::default());
let (loc_expr, output) = canonicalize_expr( let (loc_expr, output) = canonicalize_expr(
&mut env, &mut env,
&var_store, &mut var_store,
&mut scope, &mut scope,
Region::zero(), Region::zero(),
&loc_expr.value, &loc_expr.value,

View file

@ -28,7 +28,7 @@ pub fn constrain_module(
module: &ModuleOutput, module: &ModuleOutput,
home: ModuleId, home: ModuleId,
mode: Mode, mode: Mode,
var_store: &VarStore, var_store: &mut VarStore,
) -> Constraint { ) -> Constraint {
use Mode::*; use Mode::*;
@ -42,7 +42,7 @@ pub fn constrain_module(
match mode { match mode {
Standard => constrain_decls(home, decls, send_aliases), Standard => constrain_decls(home, decls, send_aliases),
Uniqueness => crate::uniq::constrain_decls(home, decls, send_aliases, &var_store), Uniqueness => crate::uniq::constrain_decls(home, decls, send_aliases, var_store),
} }
} }
@ -55,7 +55,7 @@ pub struct Import {
pub fn constrain_imported_values( pub fn constrain_imported_values(
imports: Vec<Import>, imports: Vec<Import>,
body_con: Constraint, body_con: Constraint,
var_store: &VarStore, var_store: &mut VarStore,
) -> (Vec<Variable>, Constraint) { ) -> (Vec<Variable>, Constraint) {
use Constraint::*; use Constraint::*;
let mut def_types = SendMap::default(); let mut def_types = SendMap::default();
@ -111,7 +111,11 @@ pub fn constrain_imported_values(
) )
} }
pub fn load_builtin_aliases<I>(aliases: I, body_con: Constraint, var_store: &VarStore) -> Constraint pub fn load_builtin_aliases<I>(
aliases: I,
body_con: Constraint,
var_store: &mut VarStore,
) -> Constraint
where where
I: IntoIterator<Item = (Symbol, BuiltinAlias)>, I: IntoIterator<Item = (Symbol, BuiltinAlias)>,
{ {
@ -169,7 +173,7 @@ pub struct FreeVars {
pub wildcards: Vec<Variable>, pub wildcards: Vec<Variable>,
} }
fn to_type(solved_type: &SolvedType, free_vars: &mut FreeVars, var_store: &VarStore) -> Type { fn to_type(solved_type: &SolvedType, free_vars: &mut FreeVars, var_store: &mut VarStore) -> Type {
use roc_types::solved_types::SolvedType::*; use roc_types::solved_types::SolvedType::*;
match solved_type { match solved_type {
@ -293,7 +297,11 @@ fn to_type(solved_type: &SolvedType, free_vars: &mut FreeVars, var_store: &VarSt
} }
} }
pub fn to_atom(solved_atom: &SolvedAtom, free_vars: &mut FreeVars, var_store: &VarStore) -> Atom { pub fn to_atom(
solved_atom: &SolvedAtom,
free_vars: &mut FreeVars,
var_store: &mut VarStore,
) -> Atom {
match solved_atom { match solved_atom {
SolvedAtom::Zero => Atom::Zero, SolvedAtom::Zero => Atom::Zero,
SolvedAtom::One => Atom::One, SolvedAtom::One => Atom::One,
@ -313,7 +321,7 @@ pub fn to_atom(solved_atom: &SolvedAtom, free_vars: &mut FreeVars, var_store: &V
pub fn constrain_imported_aliases( pub fn constrain_imported_aliases(
aliases: MutMap<Symbol, Alias>, aliases: MutMap<Symbol, Alias>,
body_con: Constraint, body_con: Constraint,
var_store: &VarStore, var_store: &mut VarStore,
) -> Constraint { ) -> Constraint {
use Constraint::*; use Constraint::*;
let mut def_aliases = SendMap::default(); let mut def_aliases = SendMap::default();

View file

@ -28,7 +28,7 @@ pub struct Env {
pub fn constrain_declaration( pub fn constrain_declaration(
home: ModuleId, home: ModuleId,
var_store: &VarStore, var_store: &mut VarStore,
region: Region, region: Region,
loc_expr: &Located<Expr>, loc_expr: &Located<Expr>,
_declared_idents: &ImMap<Ident, (Symbol, Region)>, _declared_idents: &ImMap<Ident, (Symbol, Region)>,
@ -61,7 +61,7 @@ pub fn constrain_decls(
home: ModuleId, home: ModuleId,
decls: &[Declaration], decls: &[Declaration],
mut aliases: SendMap<Symbol, Alias>, mut aliases: SendMap<Symbol, Alias>,
var_store: &VarStore, var_store: &mut VarStore,
) -> Constraint { ) -> Constraint {
let mut constraint = Constraint::SaveTheEnvironment; let mut constraint = Constraint::SaveTheEnvironment;
@ -96,7 +96,7 @@ pub fn constrain_decls(
home, home,
rigids: ImMap::default(), rigids: ImMap::default(),
}, },
&var_store, var_store,
&var_usage, &var_usage,
&mut ImSet::default(), &mut ImSet::default(),
def, def,
@ -113,7 +113,7 @@ pub fn constrain_decls(
home, home,
rigids: ImMap::default(), rigids: ImMap::default(),
}, },
&var_store, var_store,
&var_usage, &var_usage,
&mut ImSet::default(), &mut ImSet::default(),
defs, defs,
@ -135,7 +135,7 @@ pub struct PatternState {
} }
fn constrain_pattern( fn constrain_pattern(
var_store: &VarStore, var_store: &mut VarStore,
state: &mut PatternState, state: &mut PatternState,
pattern: &Located<Pattern>, pattern: &Located<Pattern>,
expected: PExpected<Type>, expected: PExpected<Type>,
@ -347,7 +347,7 @@ fn constrain_pattern(
fn unique_unbound_num( fn unique_unbound_num(
inner_var: Variable, inner_var: Variable,
var_store: &VarStore, var_store: &mut VarStore,
) -> (Variable, Variable, Type, Variable) { ) -> (Variable, Variable, Type, Variable) {
let num_var = var_store.fresh(); let num_var = var_store.fresh();
let num_uvar = var_store.fresh(); let num_uvar = var_store.fresh();
@ -362,7 +362,7 @@ fn unique_unbound_num(
(num_uvar, val_uvar, num_type, num_var) (num_uvar, val_uvar, num_type, num_var)
} }
fn unique_num(var_store: &VarStore, symbol: Symbol) -> (Variable, Variable, Type) { fn unique_num(var_store: &mut VarStore, symbol: Symbol) -> (Variable, Variable, Type) {
let num_uvar = var_store.fresh(); let num_uvar = var_store.fresh();
let val_uvar = var_store.fresh(); let val_uvar = var_store.fresh();
@ -375,17 +375,17 @@ fn unique_num(var_store: &VarStore, symbol: Symbol) -> (Variable, Variable, Type
(num_uvar, val_uvar, num_type) (num_uvar, val_uvar, num_type)
} }
fn unique_int(var_store: &VarStore) -> (Variable, Variable, Type) { fn unique_int(var_store: &mut VarStore) -> (Variable, Variable, Type) {
unique_num(var_store, Symbol::INT_INTEGER) unique_num(var_store, Symbol::INT_INTEGER)
} }
fn unique_float(var_store: &VarStore) -> (Variable, Variable, Type) { fn unique_float(var_store: &mut VarStore) -> (Variable, Variable, Type) {
unique_num(var_store, Symbol::FLOAT_FLOATINGPOINT) unique_num(var_store, Symbol::FLOAT_FLOATINGPOINT)
} }
pub fn constrain_expr( pub fn constrain_expr(
env: &Env, env: &Env,
var_store: &VarStore, var_store: &mut VarStore,
var_usage: &VarUsage, var_usage: &VarUsage,
applied_usage_constraint: &mut ImSet<Symbol>, applied_usage_constraint: &mut ImSet<Symbol>,
region: Region, region: Region,
@ -1355,7 +1355,7 @@ pub fn constrain_expr(
} }
fn constrain_var( fn constrain_var(
var_store: &VarStore, var_store: &mut VarStore,
applied_usage_constraint: &mut ImSet<Symbol>, applied_usage_constraint: &mut ImSet<Symbol>,
symbol_for_lookup: Symbol, symbol_for_lookup: Symbol,
usage: Option<&Usage>, usage: Option<&Usage>,
@ -1420,7 +1420,7 @@ fn constrain_var(
fn constrain_by_usage( fn constrain_by_usage(
usage: &Usage, usage: &Usage,
var_store: &VarStore, var_store: &mut VarStore,
introduced: &mut Vec<Variable>, introduced: &mut Vec<Variable>,
) -> (Atom, Vec<Atom>, Type) { ) -> (Atom, Vec<Atom>, Type) {
use Mark::*; use Mark::*;
@ -1483,7 +1483,7 @@ fn constrain_by_usage_list(
fields: &FieldAccess, fields: &FieldAccess,
list_uniq_var: Atom, list_uniq_var: Atom,
introduced: &mut Vec<Variable>, introduced: &mut Vec<Variable>,
var_store: &VarStore, var_store: &mut VarStore,
) -> (Atom, Vec<Atom>, Type) { ) -> (Atom, Vec<Atom>, Type) {
let field_usage = fields let field_usage = fields
.get(&sharing::LIST_ELEM.into()) .get(&sharing::LIST_ELEM.into())
@ -1507,7 +1507,7 @@ fn constrain_by_usage_record(
record_uniq_var: Atom, record_uniq_var: Atom,
ext_type: Type, ext_type: Type,
introduced: &mut Vec<Variable>, introduced: &mut Vec<Variable>,
var_store: &VarStore, var_store: &mut VarStore,
) -> (Atom, Vec<Atom>, Type) { ) -> (Atom, Vec<Atom>, Type) {
let mut field_types = SendMap::default(); let mut field_types = SendMap::default();
@ -1552,7 +1552,7 @@ fn constrain_by_usage_record(
// NOTE enabling the inline pragma can blow the stack in debug mode // NOTE enabling the inline pragma can blow the stack in debug mode
// #[inline(always)] // #[inline(always)]
fn constrain_when_branch( fn constrain_when_branch(
var_store: &VarStore, var_store: &mut VarStore,
var_usage: &VarUsage, var_usage: &VarUsage,
applied_usage_constraint: &mut ImSet<Symbol>, applied_usage_constraint: &mut ImSet<Symbol>,
env: &Env, env: &Env,
@ -1633,7 +1633,7 @@ fn constrain_when_branch(
} }
fn constrain_def_pattern( fn constrain_def_pattern(
var_store: &VarStore, var_store: &mut VarStore,
loc_pattern: &Located<Pattern>, loc_pattern: &Located<Pattern>,
expr_type: Type, expr_type: Type,
) -> PatternState { ) -> PatternState {
@ -1654,7 +1654,7 @@ fn constrain_def_pattern(
/// Turn e.g. `Int` into `Attr.Attr * Int` /// Turn e.g. `Int` into `Attr.Attr * Int`
fn annotation_to_attr_type( fn annotation_to_attr_type(
var_store: &VarStore, var_store: &mut VarStore,
ann: &Type, ann: &Type,
rigids: &mut ImMap<Variable, Variable>, rigids: &mut ImMap<Variable, Variable>,
change_var_kind: bool, change_var_kind: bool,
@ -1843,7 +1843,7 @@ fn annotation_to_attr_type(
} }
fn annotation_to_attr_type_many( fn annotation_to_attr_type_many(
var_store: &VarStore, var_store: &mut VarStore,
anns: &[Type], anns: &[Type],
rigids: &mut ImMap<Variable, Variable>, rigids: &mut ImMap<Variable, Variable>,
change_var_kind: bool, change_var_kind: bool,
@ -1859,7 +1859,7 @@ fn annotation_to_attr_type_many(
}) })
} }
fn aliases_to_attr_type(var_store: &VarStore, aliases: &mut SendMap<Symbol, Alias>) { fn aliases_to_attr_type(var_store: &mut VarStore, aliases: &mut SendMap<Symbol, Alias>) {
for alias in aliases.iter_mut() { for alias in aliases.iter_mut() {
// ensure // ensure
// //
@ -1885,7 +1885,7 @@ fn aliases_to_attr_type(var_store: &VarStore, aliases: &mut SendMap<Symbol, Alia
fn constrain_def( fn constrain_def(
env: &Env, env: &Env,
var_store: &VarStore, var_store: &mut VarStore,
var_usage: &VarUsage, var_usage: &VarUsage,
applied_usage_constraint: &mut ImSet<Symbol>, applied_usage_constraint: &mut ImSet<Symbol>,
def: &Def, def: &Def,
@ -1978,7 +1978,7 @@ fn constrain_def(
} }
fn instantiate_rigids( fn instantiate_rigids(
var_store: &VarStore, var_store: &mut VarStore,
annotation: &Type, annotation: &Type,
introduced_vars: &IntroducedVariables, introduced_vars: &IntroducedVariables,
new_rigids: &mut Vec<Variable>, new_rigids: &mut Vec<Variable>,
@ -2046,7 +2046,7 @@ fn instantiate_rigids(
fn constrain_recursive_defs( fn constrain_recursive_defs(
env: &Env, env: &Env,
var_store: &VarStore, var_store: &mut VarStore,
var_usage: &VarUsage, var_usage: &VarUsage,
applied_usage_constraint: &mut ImSet<Symbol>, applied_usage_constraint: &mut ImSet<Symbol>,
defs: &[Def], defs: &[Def],
@ -2067,7 +2067,7 @@ fn constrain_recursive_defs(
#[allow(clippy::too_many_arguments)] #[allow(clippy::too_many_arguments)]
pub fn rec_defs_help( pub fn rec_defs_help(
env: &Env, env: &Env,
var_store: &VarStore, var_store: &mut VarStore,
var_usage: &VarUsage, var_usage: &VarUsage,
applied_usage_constraint: &mut ImSet<Symbol>, applied_usage_constraint: &mut ImSet<Symbol>,
defs: &[Def], defs: &[Def],
@ -2227,7 +2227,7 @@ pub fn rec_defs_help(
#[inline(always)] #[inline(always)]
fn constrain_field_update( fn constrain_field_update(
env: &Env, env: &Env,
var_store: &VarStore, var_store: &mut VarStore,
var_usage: &VarUsage, var_usage: &VarUsage,
applied_usage_constraint: &mut ImSet<Symbol>, applied_usage_constraint: &mut ImSet<Symbol>,
var: Variable, var: Variable,

View file

@ -149,19 +149,19 @@ pub fn uniq_expr_with(
loc_expr, loc_expr,
output, output,
problems, problems,
var_store: old_var_store, var_store: mut old_var_store,
var, var,
interns, interns,
.. ..
} = can_expr_with(arena, home, expr_str); } = can_expr_with(arena, home, expr_str);
// double check // double check
let var_store = VarStore::new(old_var_store.fresh()); let mut var_store = VarStore::new(old_var_store.fresh());
let expected2 = Expected::NoExpectation(Type::Variable(var)); let expected2 = Expected::NoExpectation(Type::Variable(var));
let constraint = roc_constrain::uniq::constrain_declaration( let constraint = roc_constrain::uniq::constrain_declaration(
home, home,
&var_store, &mut var_store,
Region::zero(), Region::zero(),
&loc_expr, &loc_expr,
declared_idents, declared_idents,
@ -183,12 +183,12 @@ pub fn uniq_expr_with(
// TODO what to do with those rigids? // TODO what to do with those rigids?
let (_introduced_rigids, constraint) = let (_introduced_rigids, constraint) =
constrain_imported_values(imports, constraint, &var_store); constrain_imported_values(imports, constraint, &mut var_store);
// load builtin types // load builtin types
let mut constraint = load_builtin_aliases(stdlib.aliases, constraint, &var_store); let mut constraint = load_builtin_aliases(stdlib.aliases, constraint, &mut var_store);
constraint.instantiate_aliases(&var_store); constraint.instantiate_aliases(&mut var_store);
let subs2 = Subs::new(var_store.into()); let subs2 = Subs::new(var_store.into());
@ -216,7 +216,7 @@ pub fn can_expr_with(arena: &Bump, home: ModuleId, expr_str: &str) -> CanExprOut
) )
}); });
let var_store = VarStore::default(); let mut var_store = VarStore::default();
let var = var_store.fresh(); let var = var_store.fresh();
let expected = Expected::NoExpectation(Type::Variable(var)); let expected = Expected::NoExpectation(Type::Variable(var));
let module_ids = ModuleIds::default(); let module_ids = ModuleIds::default();
@ -235,7 +235,7 @@ pub fn can_expr_with(arena: &Bump, home: ModuleId, expr_str: &str) -> CanExprOut
let mut env = Env::new(home, dep_idents, &module_ids, IdentIds::default()); let mut env = Env::new(home, dep_idents, &module_ids, IdentIds::default());
let (loc_expr, output) = canonicalize_expr( let (loc_expr, output) = canonicalize_expr(
&mut env, &mut env,
&var_store, &mut var_store,
&mut scope, &mut scope,
Region::zero(), Region::zero(),
&loc_expr.value, &loc_expr.value,
@ -245,7 +245,7 @@ pub fn can_expr_with(arena: &Bump, home: ModuleId, expr_str: &str) -> CanExprOut
// Add builtin defs (e.g. List.get) directly to the canonical Expr, // Add builtin defs (e.g. List.get) directly to the canonical Expr,
// since we aren't using modules here. // since we aren't using modules here.
let builtin_defs = roc_can::builtins::builtin_defs(&var_store); let builtin_defs = roc_can::builtins::builtin_defs(&mut var_store);
for (symbol, expr) in builtin_defs { for (symbol, expr) in builtin_defs {
if output.references.lookups.contains(&symbol) || output.references.calls.contains(&symbol) if output.references.lookups.contains(&symbol) || output.references.calls.contains(&symbol)
@ -301,7 +301,7 @@ pub fn can_expr_with(arena: &Bump, home: ModuleId, expr_str: &str) -> CanExprOut
// load builtin values // load builtin values
let (_introduced_rigids, constraint) = let (_introduced_rigids, constraint) =
constrain_imported_values(imports, constraint, &var_store); constrain_imported_values(imports, constraint, &mut var_store);
// TODO determine what to do with those rigids // TODO determine what to do with those rigids
// for var in introduced_rigids { // for var in introduced_rigids {
@ -309,9 +309,10 @@ pub fn can_expr_with(arena: &Bump, home: ModuleId, expr_str: &str) -> CanExprOut
// } // }
//load builtin types //load builtin types
let mut constraint = load_builtin_aliases(roc_builtins::std::aliases(), constraint, &var_store); let mut constraint =
load_builtin_aliases(roc_builtins::std::aliases(), constraint, &mut var_store);
constraint.instantiate_aliases(&var_store); constraint.instantiate_aliases(&mut var_store);
let mut all_ident_ids = MutMap::default(); let mut all_ident_ids = MutMap::default();

View file

@ -800,7 +800,7 @@ fn spawn_solve_module(
module: Module, module: Module,
src: Box<str>, src: Box<str>,
constraint: Constraint, constraint: Constraint,
var_store: VarStore, mut var_store: VarStore,
imported_modules: MutSet<ModuleId>, imported_modules: MutSet<ModuleId>,
msg_tx: MsgSender, msg_tx: MsgSender,
exposed_types: &mut SubsByModule, exposed_types: &mut SubsByModule,
@ -922,12 +922,12 @@ fn spawn_solve_module(
// in the ones we just computed. We can do this off the main thread. // in the ones we just computed. We can do this off the main thread.
// TODO what to do with the introduced rigids? // TODO what to do with the introduced rigids?
let (_introduced_rigids, constraint) = let (_introduced_rigids, constraint) =
constrain_imported_values(imported_symbols, constraint, &var_store); constrain_imported_values(imported_symbols, constraint, &mut var_store);
let constraint = constrain_imported_aliases(imported_aliases, constraint, &var_store); let constraint = constrain_imported_aliases(imported_aliases, constraint, &mut var_store);
let mut constraint = load_builtin_aliases(aliases, constraint, &var_store); let mut constraint = load_builtin_aliases(aliases, constraint, &mut var_store);
// Turn Apply into Alias // Turn Apply into Alias
constraint.instantiate_aliases(&var_store); constraint.instantiate_aliases(&mut var_store);
let (solved_subs, solved_module) = let (solved_subs, solved_module) =
roc_solve::module::solve_module(module, constraint, var_store); roc_solve::module::solve_module(module, constraint, var_store);
@ -1029,7 +1029,7 @@ fn parse_and_constrain(
msg_tx: MsgSender, msg_tx: MsgSender,
) { ) {
let module_id = header.module_id; let module_id = header.module_id;
let var_store = VarStore::default(); let mut var_store = VarStore::default();
let arena = Bump::new(); let arena = Bump::new();
let state = State::new(&header.src, Attempting::Module); let state = State::new(&header.src, Attempting::Module);
@ -1046,10 +1046,10 @@ fn parse_and_constrain(
dep_idents, dep_idents,
header.exposed_imports, header.exposed_imports,
exposed_symbols, exposed_symbols,
&var_store, &mut var_store,
) { ) {
Ok(module_output) => { Ok(module_output) => {
let constraint = constrain_module(&module_output, module_id, mode, &var_store); let constraint = constrain_module(&module_output, module_id, mode, &mut var_store);
let module = Module { let module = Module {
module_id, module_id,
exposed_imports: module_output.exposed_imports, exposed_imports: module_output.exposed_imports,

View file

@ -144,19 +144,19 @@ pub fn uniq_expr_with(
loc_expr, loc_expr,
output, output,
problems, problems,
var_store: old_var_store, var_store: mut old_var_store,
var, var,
interns, interns,
.. ..
} = can_expr_with(arena, home, expr_str); } = can_expr_with(arena, home, expr_str);
// double check // double check
let var_store = VarStore::new(old_var_store.fresh()); let mut var_store = VarStore::new(old_var_store.fresh());
let expected2 = Expected::NoExpectation(Type::Variable(var)); let expected2 = Expected::NoExpectation(Type::Variable(var));
let constraint = roc_constrain::uniq::constrain_declaration( let constraint = roc_constrain::uniq::constrain_declaration(
home, home,
&var_store, &mut var_store,
Region::zero(), Region::zero(),
&loc_expr, &loc_expr,
declared_idents, declared_idents,
@ -176,12 +176,12 @@ pub fn uniq_expr_with(
// load builtin values // load builtin values
let (_introduced_rigids, constraint) = let (_introduced_rigids, constraint) =
constrain_imported_values(imports, constraint, &var_store); constrain_imported_values(imports, constraint, &mut var_store);
// load builtin types // load builtin types
let mut constraint = load_builtin_aliases(stdlib.aliases, constraint, &var_store); let mut constraint = load_builtin_aliases(stdlib.aliases, constraint, &mut var_store);
constraint.instantiate_aliases(&var_store); constraint.instantiate_aliases(&mut var_store);
let subs2 = Subs::new(var_store.into()); let subs2 = Subs::new(var_store.into());
@ -210,7 +210,7 @@ pub fn can_expr_with(arena: &Bump, home: ModuleId, expr_str: &str) -> CanExprOut
) )
}); });
let var_store = VarStore::default(); let mut var_store = VarStore::default();
let var = var_store.fresh(); let var = var_store.fresh();
let expected = Expected::NoExpectation(Type::Variable(var)); let expected = Expected::NoExpectation(Type::Variable(var));
let module_ids = ModuleIds::default(); let module_ids = ModuleIds::default();
@ -229,7 +229,7 @@ pub fn can_expr_with(arena: &Bump, home: ModuleId, expr_str: &str) -> CanExprOut
let mut env = Env::new(home, dep_idents, &module_ids, IdentIds::default()); let mut env = Env::new(home, dep_idents, &module_ids, IdentIds::default());
let (loc_expr, output) = canonicalize_expr( let (loc_expr, output) = canonicalize_expr(
&mut env, &mut env,
&var_store, &mut var_store,
&mut scope, &mut scope,
Region::zero(), Region::zero(),
&loc_expr.value, &loc_expr.value,
@ -257,7 +257,7 @@ pub fn can_expr_with(arena: &Bump, home: ModuleId, expr_str: &str) -> CanExprOut
//load builtin values //load builtin values
let (_introduced_rigids, constraint) = let (_introduced_rigids, constraint) =
constrain_imported_values(imports, constraint, &var_store); constrain_imported_values(imports, constraint, &mut var_store);
// TODO include only the aliases actually used in this module // TODO include only the aliases actually used in this module
let aliases = roc_builtins::std::aliases() let aliases = roc_builtins::std::aliases()
@ -266,9 +266,9 @@ pub fn can_expr_with(arena: &Bump, home: ModuleId, expr_str: &str) -> CanExprOut
.collect::<Vec<(Symbol, BuiltinAlias)>>(); .collect::<Vec<(Symbol, BuiltinAlias)>>();
//load builtin types //load builtin types
let mut constraint = load_builtin_aliases(aliases.into_iter(), constraint, &var_store); let mut constraint = load_builtin_aliases(aliases.into_iter(), constraint, &mut var_store);
constraint.instantiate_aliases(&var_store); constraint.instantiate_aliases(&mut var_store);
let mut all_ident_ids = MutMap::default(); let mut all_ident_ids = MutMap::default();

View file

@ -124,19 +124,19 @@ pub fn uniq_expr_with(
loc_expr, loc_expr,
output, output,
problems, problems,
var_store: old_var_store, var_store: mut old_var_store,
var, var,
interns, interns,
.. ..
} = can_expr_with(arena, home, expr_str); } = can_expr_with(arena, home, expr_str);
// double check // double check
let var_store = VarStore::new(old_var_store.fresh()); let mut var_store = VarStore::new(old_var_store.fresh());
let expected2 = Expected::NoExpectation(Type::Variable(var)); let expected2 = Expected::NoExpectation(Type::Variable(var));
let constraint = roc_constrain::uniq::constrain_declaration( let constraint = roc_constrain::uniq::constrain_declaration(
home, home,
&var_store, &mut var_store,
Region::zero(), Region::zero(),
&loc_expr, &loc_expr,
declared_idents, declared_idents,
@ -158,12 +158,12 @@ pub fn uniq_expr_with(
// TODO what to do with those rigids? // TODO what to do with those rigids?
let (_introduced_rigids, constraint) = let (_introduced_rigids, constraint) =
constrain_imported_values(imports, constraint, &var_store); constrain_imported_values(imports, constraint, &mut var_store);
// load builtin types // load builtin types
let mut constraint = load_builtin_aliases(stdlib.aliases, constraint, &var_store); let mut constraint = load_builtin_aliases(stdlib.aliases, constraint, &mut var_store);
constraint.instantiate_aliases(&var_store); constraint.instantiate_aliases(&mut var_store);
let subs2 = Subs::new(var_store.into()); let subs2 = Subs::new(var_store.into());
@ -192,7 +192,7 @@ pub fn can_expr_with(arena: &Bump, home: ModuleId, expr_str: &str) -> CanExprOut
) )
}); });
let var_store = VarStore::default(); let mut var_store = VarStore::default();
let var = var_store.fresh(); let var = var_store.fresh();
let expected = Expected::NoExpectation(Type::Variable(var)); let expected = Expected::NoExpectation(Type::Variable(var));
let module_ids = ModuleIds::default(); let module_ids = ModuleIds::default();
@ -211,7 +211,7 @@ pub fn can_expr_with(arena: &Bump, home: ModuleId, expr_str: &str) -> CanExprOut
let mut env = Env::new(home, dep_idents, &module_ids, IdentIds::default()); let mut env = Env::new(home, dep_idents, &module_ids, IdentIds::default());
let (loc_expr, output) = canonicalize_expr( let (loc_expr, output) = canonicalize_expr(
&mut env, &mut env,
&var_store, &mut var_store,
&mut scope, &mut scope,
Region::zero(), Region::zero(),
&loc_expr.value, &loc_expr.value,
@ -239,12 +239,13 @@ pub fn can_expr_with(arena: &Bump, home: ModuleId, expr_str: &str) -> CanExprOut
//load builtin values //load builtin values
let (_introduced_rigids, constraint) = let (_introduced_rigids, constraint) =
constrain_imported_values(imports, constraint, &var_store); constrain_imported_values(imports, constraint, &mut var_store);
//load builtin types //load builtin types
let mut constraint = load_builtin_aliases(roc_builtins::std::aliases(), constraint, &var_store); let mut constraint =
load_builtin_aliases(roc_builtins::std::aliases(), constraint, &mut var_store);
constraint.instantiate_aliases(&var_store); constraint.instantiate_aliases(&mut var_store);
let mut all_ident_ids = MutMap::default(); let mut all_ident_ids = MutMap::default();

View file

@ -145,7 +145,7 @@ pub fn can_expr_with(
} }
}; };
let var_store = VarStore::default(); let mut var_store = VarStore::default();
let var = var_store.fresh(); let var = var_store.fresh();
let expected = Expected::NoExpectation(Type::Variable(var)); let expected = Expected::NoExpectation(Type::Variable(var));
let module_ids = ModuleIds::default(); let module_ids = ModuleIds::default();
@ -164,7 +164,7 @@ pub fn can_expr_with(
let mut env = Env::new(home, dep_idents, &module_ids, IdentIds::default()); let mut env = Env::new(home, dep_idents, &module_ids, IdentIds::default());
let (loc_expr, output) = canonicalize_expr( let (loc_expr, output) = canonicalize_expr(
&mut env, &mut env,
&var_store, &mut var_store,
&mut scope, &mut scope,
loc_expr.region, loc_expr.region,
&loc_expr.value, &loc_expr.value,
@ -192,12 +192,13 @@ pub fn can_expr_with(
//load builtin values //load builtin values
let (_introduced_rigids, constraint) = let (_introduced_rigids, constraint) =
constrain_imported_values(imports, constraint, &var_store); constrain_imported_values(imports, constraint, &mut var_store);
//load builtin types //load builtin types
let mut constraint = load_builtin_aliases(roc_builtins::std::aliases(), constraint, &var_store); let mut constraint =
load_builtin_aliases(roc_builtins::std::aliases(), constraint, &mut var_store);
constraint.instantiate_aliases(&var_store); constraint.instantiate_aliases(&mut var_store);
let mut all_ident_ids = MutMap::default(); let mut all_ident_ids = MutMap::default();

View file

@ -145,19 +145,19 @@ pub fn uniq_expr_with(
loc_expr, loc_expr,
output, output,
problems, problems,
var_store: old_var_store, var_store: mut old_var_store,
var, var,
interns, interns,
.. ..
} = can_expr_with(arena, home, expr_str); } = can_expr_with(arena, home, expr_str);
// double check // double check
let var_store = VarStore::new(old_var_store.fresh()); let mut var_store = VarStore::new(old_var_store.fresh());
let expected2 = Expected::NoExpectation(Type::Variable(var)); let expected2 = Expected::NoExpectation(Type::Variable(var));
let constraint = roc_constrain::uniq::constrain_declaration( let constraint = roc_constrain::uniq::constrain_declaration(
home, home,
&var_store, &mut var_store,
Region::zero(), Region::zero(),
&loc_expr, &loc_expr,
declared_idents, declared_idents,
@ -179,12 +179,12 @@ pub fn uniq_expr_with(
// TODO what to do with those rigids? // TODO what to do with those rigids?
let (_introduced_rigids, constraint) = let (_introduced_rigids, constraint) =
constrain_imported_values(imports, constraint, &var_store); constrain_imported_values(imports, constraint, &mut var_store);
// load builtin types // load builtin types
let mut constraint = load_builtin_aliases(stdlib.aliases, constraint, &var_store); let mut constraint = load_builtin_aliases(stdlib.aliases, constraint, &mut var_store);
constraint.instantiate_aliases(&var_store); constraint.instantiate_aliases(&mut var_store);
let subs2 = Subs::new(var_store.into()); let subs2 = Subs::new(var_store.into());
@ -213,7 +213,7 @@ pub fn can_expr_with(arena: &Bump, home: ModuleId, expr_str: &str) -> CanExprOut
) )
}); });
let var_store = VarStore::default(); let mut var_store = VarStore::default();
let var = var_store.fresh(); let var = var_store.fresh();
let expected = Expected::NoExpectation(Type::Variable(var)); let expected = Expected::NoExpectation(Type::Variable(var));
let module_ids = ModuleIds::default(); let module_ids = ModuleIds::default();
@ -232,7 +232,7 @@ pub fn can_expr_with(arena: &Bump, home: ModuleId, expr_str: &str) -> CanExprOut
let mut env = Env::new(home, dep_idents, &module_ids, IdentIds::default()); let mut env = Env::new(home, dep_idents, &module_ids, IdentIds::default());
let (loc_expr, output) = canonicalize_expr( let (loc_expr, output) = canonicalize_expr(
&mut env, &mut env,
&var_store, &mut var_store,
&mut scope, &mut scope,
Region::zero(), Region::zero(),
&loc_expr.value, &loc_expr.value,
@ -260,16 +260,16 @@ pub fn can_expr_with(arena: &Bump, home: ModuleId, expr_str: &str) -> CanExprOut
//load builtin values //load builtin values
let (_introduced_rigids, constraint) = let (_introduced_rigids, constraint) =
constrain_imported_values(imports, constraint, &var_store); constrain_imported_values(imports, constraint, &mut var_store);
//load builtin types //load builtin types
let mut constraint = load_builtin_aliases( let mut constraint = load_builtin_aliases(
roc_builtins::std::aliases().into_iter(), roc_builtins::std::aliases().into_iter(),
constraint, constraint,
&var_store, &mut var_store,
); );
constraint.instantiate_aliases(&var_store); constraint.instantiate_aliases(&mut var_store);
let mut all_ident_ids = MutMap::default(); let mut all_ident_ids = MutMap::default();

View file

@ -5,7 +5,6 @@ use roc_module::ident::{Lowercase, TagName};
use roc_module::symbol::Symbol; use roc_module::symbol::Symbol;
use std::fmt; use std::fmt;
use std::iter::{once, Iterator}; use std::iter::{once, Iterator};
use std::sync::atomic::{AtomicU32, Ordering};
use ven_ena::unify::{InPlace, Snapshot, UnificationTable, UnifyKey}; use ven_ena::unify::{InPlace, Snapshot, UnificationTable, UnifyKey};
#[derive(Clone, Copy, Hash, PartialEq, Eq)] #[derive(Clone, Copy, Hash, PartialEq, Eq)]
@ -56,7 +55,7 @@ impl fmt::Debug for Subs {
#[derive(Debug)] #[derive(Debug)]
pub struct VarStore { pub struct VarStore {
next: AtomicU32, next: u32,
} }
impl Default for VarStore { impl Default for VarStore {
@ -70,24 +69,22 @@ impl VarStore {
pub fn new(next_var: Variable) -> Self { pub fn new(next_var: Variable) -> Self {
debug_assert!(next_var.0 >= Variable::FIRST_USER_SPACE_VAR.0); debug_assert!(next_var.0 >= Variable::FIRST_USER_SPACE_VAR.0);
VarStore { VarStore { next: next_var.0 }
next: AtomicU32::new(next_var.0),
}
} }
pub fn fresh(&self) -> Variable { pub fn fresh(&mut self) -> Variable {
// Increment the counter and return the previous value. // Increment the counter and return the value it had before it was incremented.
// let answer = self.next;
// Since the counter starts at 0, this will return 0 on first invocation,
// and var_store.into() will return the number of Variables distributed self.next += 1;
// (in this case, 1).
Variable(AtomicU32::fetch_add(&self.next, 1, Ordering::Relaxed)) Variable(answer)
} }
} }
impl Into<Variable> for VarStore { impl Into<Variable> for VarStore {
fn into(self) -> Variable { fn into(self) -> Variable {
Variable(self.next.into_inner()) Variable(self.next)
} }
} }

View file

@ -397,7 +397,7 @@ impl Type {
&mut self, &mut self,
region: Region, region: Region,
aliases: &ImMap<Symbol, Alias>, aliases: &ImMap<Symbol, Alias>,
var_store: &VarStore, var_store: &mut VarStore,
introduced: &mut ImSet<Variable>, introduced: &mut ImSet<Variable>,
) { ) {
use Type::*; use Type::*;

View file

@ -145,19 +145,19 @@ pub fn uniq_expr_with(
loc_expr, loc_expr,
output, output,
problems, problems,
var_store: old_var_store, var_store: mut old_var_store,
var, var,
interns, interns,
.. ..
} = can_expr_with(arena, home, expr_str); } = can_expr_with(arena, home, expr_str);
// double check // double check
let var_store = VarStore::new(old_var_store.fresh()); let mut var_store = VarStore::new(old_var_store.fresh());
let expected2 = Expected::NoExpectation(Type::Variable(var)); let expected2 = Expected::NoExpectation(Type::Variable(var));
let constraint = roc_constrain::uniq::constrain_declaration( let constraint = roc_constrain::uniq::constrain_declaration(
home, home,
&var_store, &mut var_store,
Region::zero(), Region::zero(),
&loc_expr, &loc_expr,
declared_idents, declared_idents,
@ -179,12 +179,12 @@ pub fn uniq_expr_with(
// TODO what to do with those rigids? // TODO what to do with those rigids?
let (_introduced_rigids, constraint) = let (_introduced_rigids, constraint) =
constrain_imported_values(imports, constraint, &var_store); constrain_imported_values(imports, constraint, &mut var_store);
// load builtin types // load builtin types
let mut constraint = load_builtin_aliases(stdlib.aliases, constraint, &var_store); let mut constraint = load_builtin_aliases(stdlib.aliases, constraint, &mut var_store);
constraint.instantiate_aliases(&var_store); constraint.instantiate_aliases(&mut var_store);
let subs2 = Subs::new(var_store.into()); let subs2 = Subs::new(var_store.into());
@ -213,7 +213,7 @@ pub fn can_expr_with(arena: &Bump, home: ModuleId, expr_str: &str) -> CanExprOut
) )
}); });
let var_store = VarStore::default(); let mut var_store = VarStore::default();
let var = var_store.fresh(); let var = var_store.fresh();
let expected = Expected::NoExpectation(Type::Variable(var)); let expected = Expected::NoExpectation(Type::Variable(var));
let module_ids = ModuleIds::default(); let module_ids = ModuleIds::default();
@ -232,7 +232,7 @@ pub fn can_expr_with(arena: &Bump, home: ModuleId, expr_str: &str) -> CanExprOut
let mut env = Env::new(home, dep_idents, &module_ids, IdentIds::default()); let mut env = Env::new(home, dep_idents, &module_ids, IdentIds::default());
let (loc_expr, output) = canonicalize_expr( let (loc_expr, output) = canonicalize_expr(
&mut env, &mut env,
&var_store, &mut var_store,
&mut scope, &mut scope,
Region::zero(), Region::zero(),
&loc_expr.value, &loc_expr.value,
@ -260,12 +260,13 @@ pub fn can_expr_with(arena: &Bump, home: ModuleId, expr_str: &str) -> CanExprOut
//load builtin values //load builtin values
let (_introduced_rigids, constraint) = let (_introduced_rigids, constraint) =
constrain_imported_values(imports, constraint, &var_store); constrain_imported_values(imports, constraint, &mut var_store);
//load builtin types //load builtin types
let mut constraint = load_builtin_aliases(roc_builtins::std::aliases(), constraint, &var_store); let mut constraint =
load_builtin_aliases(roc_builtins::std::aliases(), constraint, &mut var_store);
constraint.instantiate_aliases(&var_store); constraint.instantiate_aliases(&mut var_store);
let mut all_ident_ids = MutMap::default(); let mut all_ident_ids = MutMap::default();

View file

@ -548,7 +548,7 @@ impl Module {
fn single_backspace_1_caret() { fn single_backspace_1_caret() {
use roc_types::subs::VarStore; use roc_types::subs::VarStore;
let var_store = VarStore::default(); let mut var_store = VarStore::default();
let int_var = var_store.fresh(); let int_var = var_store.fresh();
let int_node_id; let int_node_id;
let caret_node_id; let caret_node_id;
@ -628,7 +628,7 @@ fn single_backspace_1_caret() {
fn double_backspace_1_caret() { fn double_backspace_1_caret() {
use roc_types::subs::VarStore; use roc_types::subs::VarStore;
let var_store = VarStore::default(); let mut var_store = VarStore::default();
let int_var = var_store.fresh(); let int_var = var_store.fresh();
let int_node_id; let int_node_id;
let caret_node_id; let caret_node_id;