Rename Located -> Loc

This commit is contained in:
Joshua Warner 2021-12-22 19:18:22 -08:00
parent c66c845cd2
commit f19220473a
55 changed files with 680 additions and 683 deletions

View file

@ -4,7 +4,7 @@ use roc_collections::all::{ImMap, MutMap, MutSet, SendMap};
use roc_module::ident::{Ident, Lowercase, TagName};
use roc_module::symbol::Symbol;
use roc_parse::ast::{AssignedField, Tag, TypeAnnotation};
use roc_region::all::{Located, Region};
use roc_region::all::{Loc, Region};
use roc_types::subs::{VarStore, Variable};
use roc_types::types::{Alias, LambdaSet, Problem, RecordField, Type};
@ -311,14 +311,14 @@ fn can_annotation_help(
if let Some(var) = introduced_variables.var_by_name(&var_name) {
vars.push((var_name.clone(), Type::Variable(*var)));
lowercase_vars.push(Located::at(loc_var.region, (var_name, *var)));
lowercase_vars.push(Loc::at(loc_var.region, (var_name, *var)));
} else {
let var = var_store.fresh();
introduced_variables.insert_named(var_name.clone(), var);
vars.push((var_name.clone(), Type::Variable(var)));
lowercase_vars.push(Located::at(loc_var.region, (var_name, var)));
lowercase_vars.push(Loc::at(loc_var.region, (var_name, var)));
}
}
_ => {
@ -530,7 +530,7 @@ where
#[allow(clippy::too_many_arguments)]
fn can_assigned_fields<'a>(
env: &mut Env,
fields: &&[Located<AssignedField<'a, TypeAnnotation<'a>>>],
fields: &&[Loc<AssignedField<'a, TypeAnnotation<'a>>>],
region: Region,
scope: &mut Scope,
var_store: &mut VarStore,
@ -640,7 +640,7 @@ fn can_assigned_fields<'a>(
#[allow(clippy::too_many_arguments)]
fn can_tags<'a>(
env: &mut Env,
tags: &'a [Located<Tag<'a>>],
tags: &'a [Loc<Tag<'a>>],
region: Region,
scope: &mut Scope,
var_store: &mut VarStore,

View file

@ -7,7 +7,7 @@ use roc_module::called_via::CalledVia;
use roc_module::ident::{Lowercase, TagName};
use roc_module::low_level::LowLevel;
use roc_module::symbol::Symbol;
use roc_region::all::{Located, Region};
use roc_region::all::{Loc, Region};
use roc_types::subs::{VarStore, Variable};
macro_rules! macro_magic {
@ -361,8 +361,8 @@ fn num_max_int(symbol: Symbol, var_store: &mut VarStore) -> Def {
Def {
annotation: None,
expr_var: int_var,
loc_expr: Located::at_zero(body),
loc_pattern: Located::at_zero(Pattern::Identifier(symbol)),
loc_expr: Loc::at_zero(body),
loc_pattern: Loc::at_zero(Pattern::Identifier(symbol)),
pattern_vars: SendMap::default(),
}
}
@ -376,8 +376,8 @@ fn num_min_int(symbol: Symbol, var_store: &mut VarStore) -> Def {
Def {
annotation: None,
expr_var: int_var,
loc_expr: Located::at_zero(body),
loc_pattern: Located::at_zero(Pattern::Identifier(symbol)),
loc_expr: Loc::at_zero(body),
loc_pattern: Loc::at_zero(Pattern::Identifier(symbol)),
pattern_vars: SendMap::default(),
}
}
@ -1245,8 +1245,8 @@ fn num_max_i128(symbol: Symbol, var_store: &mut VarStore) -> Def {
Def {
annotation: Some(annotation),
expr_var: int_var,
loc_expr: Located::at_zero(body),
loc_pattern: Located::at_zero(Pattern::Identifier(symbol)),
loc_expr: Loc::at_zero(body),
loc_pattern: Loc::at_zero(Pattern::Identifier(symbol)),
pattern_vars: SendMap::default(),
}
}
@ -3249,8 +3249,8 @@ fn dict_empty(symbol: Symbol, var_store: &mut VarStore) -> Def {
Def {
annotation: None,
expr_var: dict_var,
loc_expr: Located::at_zero(body),
loc_pattern: Located::at_zero(Pattern::Identifier(symbol)),
loc_expr: Loc::at_zero(body),
loc_pattern: Loc::at_zero(Pattern::Identifier(symbol)),
pattern_vars: SendMap::default(),
}
}
@ -3331,8 +3331,8 @@ fn dict_get(symbol: Symbol, var_store: &mut VarStore) -> Def {
let def = Def {
annotation: None,
expr_var: temp_record_var,
loc_expr: Located::at_zero(def_body),
loc_pattern: Located::at_zero(Pattern::Identifier(temp_record)),
loc_expr: Loc::at_zero(def_body),
loc_pattern: Loc::at_zero(Pattern::Identifier(temp_record)),
pattern_vars: Default::default(),
};
@ -3424,8 +3424,8 @@ fn set_empty(symbol: Symbol, var_store: &mut VarStore) -> Def {
Def {
annotation: None,
expr_var: set_var,
loc_expr: Located::at_zero(body),
loc_pattern: Located::at_zero(Pattern::Identifier(symbol)),
loc_expr: Loc::at_zero(body),
loc_pattern: Loc::at_zero(Pattern::Identifier(symbol)),
pattern_vars: SendMap::default(),
}
}
@ -4570,8 +4570,8 @@ fn result_after(symbol: Symbol, var_store: &mut VarStore) -> Def {
}
#[inline(always)]
fn no_region<T>(value: T) -> Located<T> {
Located {
fn no_region<T>(value: T) -> Loc<T> {
Loc {
region: Region::zero(),
value,
}
@ -4586,7 +4586,7 @@ fn tag(name: &'static str, args: Vec<Expr>, var_store: &mut VarStore) -> Expr {
arguments: args
.into_iter()
.map(|expr| (var_store.fresh(), no_region(expr)))
.collect::<Vec<(Variable, Located<Expr>)>>(),
.collect::<Vec<(Variable, Loc<Expr>)>>(),
}
}
@ -4613,11 +4613,11 @@ fn defn(
let expr = defn_help(fn_name, args, var_store, body, ret_var);
Def {
loc_pattern: Located {
loc_pattern: Loc {
region: Region::zero(),
value: Pattern::Identifier(fn_name),
},
loc_expr: Located {
loc_expr: Loc {
region: Region::zero(),
value: expr,
},

View file

@ -1,7 +1,7 @@
use crate::expected::{Expected, PExpected};
use roc_collections::all::{MutSet, SendMap};
use roc_module::symbol::Symbol;
use roc_region::all::{Located, Region};
use roc_region::all::{Loc, Region};
use roc_types::types::{Category, PatternCategory, Type};
use roc_types::{subs::Variable, types::VariableDetail};
@ -21,7 +21,7 @@ pub enum Constraint {
pub struct LetConstraint {
pub rigid_vars: Vec<Variable>,
pub flex_vars: Vec<Variable>,
pub def_types: SendMap<Symbol, Located<Type>>,
pub def_types: SendMap<Symbol, Loc<Type>>,
pub defs_constraint: Constraint,
pub ret_constraint: Constraint,
}

View file

@ -16,7 +16,7 @@ use roc_module::symbol::Symbol;
use roc_parse::ast;
use roc_parse::pattern::PatternType;
use roc_problem::can::{CycleEntry, Problem, RuntimeError};
use roc_region::all::{Located, Region};
use roc_region::all::{Loc, Region};
use roc_types::subs::{VarStore, Variable};
use roc_types::types::{Alias, Type};
use std::collections::HashMap;
@ -25,8 +25,8 @@ use ven_graph::{strongly_connected_components, topological_sort_into_groups};
#[derive(Clone, Debug, PartialEq)]
pub struct Def {
pub loc_pattern: Located<Pattern>,
pub loc_expr: Located<Expr>,
pub loc_pattern: Loc<Pattern>,
pub loc_expr: Loc<Expr>,
pub expr_var: Variable,
pub pattern_vars: SendMap<Symbol, Variable>,
pub annotation: Option<Annotation>,
@ -53,29 +53,29 @@ pub struct CanDefs {
enum PendingDef<'a> {
/// A standalone annotation with no body
AnnotationOnly(
&'a Located<ast::Pattern<'a>>,
Located<Pattern>,
&'a Located<ast::TypeAnnotation<'a>>,
&'a Loc<ast::Pattern<'a>>,
Loc<Pattern>,
&'a Loc<ast::TypeAnnotation<'a>>,
),
/// A body with no type annotation
Body(
&'a Located<ast::Pattern<'a>>,
Located<Pattern>,
&'a Located<ast::Expr<'a>>,
&'a Loc<ast::Pattern<'a>>,
Loc<Pattern>,
&'a Loc<ast::Expr<'a>>,
),
/// A body with a type annotation
TypedBody(
&'a Located<ast::Pattern<'a>>,
Located<Pattern>,
&'a Located<ast::TypeAnnotation<'a>>,
&'a Located<ast::Expr<'a>>,
&'a Loc<ast::Pattern<'a>>,
Loc<Pattern>,
&'a Loc<ast::TypeAnnotation<'a>>,
&'a Loc<ast::Expr<'a>>,
),
/// A type alias, e.g. `Ints : List Int`
Alias {
name: Located<Symbol>,
vars: Vec<Located<Lowercase>>,
ann: &'a Located<ast::TypeAnnotation<'a>>,
name: Loc<Symbol>,
vars: Vec<Loc<Lowercase>>,
ann: &'a Loc<ast::TypeAnnotation<'a>>,
},
/// An invalid alias, that is ignored in the rest of the pipeline
@ -112,7 +112,7 @@ pub fn canonicalize_defs<'a>(
mut output: Output,
var_store: &mut VarStore,
original_scope: &Scope,
loc_defs: &'a [&'a Located<ast::Def<'a>>],
loc_defs: &'a [&'a Loc<ast::Def<'a>>],
pattern_type: PatternType,
) -> (CanDefs, Scope, Output, MutMap<Symbol, Region>) {
// Canonicalizing defs while detecting shadowing involves a multi-step process:
@ -192,7 +192,7 @@ pub fn canonicalize_defs<'a>(
output.references.referenced_aliases.insert(symbol);
}
let mut can_vars: Vec<Located<(Lowercase, Variable)>> =
let mut can_vars: Vec<Loc<(Lowercase, Variable)>> =
Vec::with_capacity(vars.len());
let mut is_phantom = false;
@ -202,7 +202,7 @@ pub fn canonicalize_defs<'a>(
.var_by_name(&loc_lowercase.value)
{
// This is a valid lowercase rigid var for the alias.
can_vars.push(Located {
can_vars.push(Loc {
value: (loc_lowercase.value.clone(), *var),
region: loc_lowercase.region,
});
@ -813,7 +813,7 @@ fn canonicalize_pending_def<'a>(
let value = Expr::RuntimeError(problem);
let is_closure = arity > 0;
let loc_can_expr = if !is_closure {
Located {
Loc {
value,
region: loc_ann.region,
}
@ -825,7 +825,7 @@ fn canonicalize_pending_def<'a>(
let mut underscores = Vec::with_capacity(arity);
for _ in 0..arity {
let underscore: Located<Pattern> = Located {
let underscore: Loc<Pattern> = Loc {
value: Pattern::Underscore,
region: Region::zero(),
};
@ -833,12 +833,12 @@ fn canonicalize_pending_def<'a>(
underscores.push((var_store.fresh(), underscore));
}
let body_expr = Located {
let body_expr = Loc {
value,
region: loc_ann.region,
};
Located {
Loc {
value: Closure(ClosureData {
function_type: var_store.fresh(),
closure_type: var_store.fresh(),
@ -867,7 +867,7 @@ fn canonicalize_pending_def<'a>(
expr_var,
// TODO try to remove this .clone()!
loc_pattern: loc_can_pattern.clone(),
loc_expr: Located {
loc_expr: Loc {
region: loc_can_expr.region,
// TODO try to remove this .clone()!
value: loc_can_expr.value.clone(),
@ -897,7 +897,7 @@ fn canonicalize_pending_def<'a>(
output.references.referenced_aliases.insert(symbol);
}
let mut can_vars: Vec<Located<(Lowercase, Variable)>> = Vec::with_capacity(vars.len());
let mut can_vars: Vec<Loc<(Lowercase, Variable)>> = Vec::with_capacity(vars.len());
for loc_lowercase in vars {
if let Some(var) = can_ann
@ -905,7 +905,7 @@ fn canonicalize_pending_def<'a>(
.var_by_name(&loc_lowercase.value)
{
// This is a valid lowercase rigid var for the alias.
can_vars.push(Located {
can_vars.push(Loc {
value: (loc_lowercase.value.clone(), *var),
region: loc_lowercase.region,
});
@ -1088,7 +1088,7 @@ fn canonicalize_pending_def<'a>(
expr_var,
// TODO try to remove this .clone()!
loc_pattern: loc_can_pattern.clone(),
loc_expr: Located {
loc_expr: Loc {
region: loc_can_expr.region,
// TODO try to remove this .clone()!
value: loc_can_expr.value.clone(),
@ -1226,7 +1226,7 @@ fn canonicalize_pending_def<'a>(
expr_var,
// TODO try to remove this .clone()!
loc_pattern: loc_can_pattern.clone(),
loc_expr: Located {
loc_expr: Loc {
// TODO try to remove this .clone()!
region: loc_can_expr.region,
value: loc_can_expr.value.clone(),
@ -1249,8 +1249,8 @@ pub fn can_defs_with_return<'a>(
env: &mut Env<'a>,
var_store: &mut VarStore,
scope: Scope,
loc_defs: &'a [&'a Located<ast::Def<'a>>],
loc_ret: &'a Located<ast::Expr<'a>>,
loc_defs: &'a [&'a Loc<ast::Def<'a>>],
loc_ret: &'a Loc<ast::Expr<'a>>,
) -> (Expr, Output) {
let (unsorted, mut scope, defs_output, symbols_introduced) = canonicalize_defs(
env,
@ -1283,10 +1283,10 @@ pub fn can_defs_with_return<'a>(
match can_defs {
Ok(decls) => {
let mut loc_expr: Located<Expr> = ret_expr;
let mut loc_expr: Loc<Expr> = ret_expr;
for declaration in decls.into_iter().rev() {
loc_expr = Located {
loc_expr = Loc {
region: Region::zero(),
value: decl_to_let(var_store, declaration, loc_expr),
};
@ -1298,7 +1298,7 @@ pub fn can_defs_with_return<'a>(
}
}
fn decl_to_let(var_store: &mut VarStore, decl: Declaration, loc_ret: Located<Expr>) -> Expr {
fn decl_to_let(var_store: &mut VarStore, decl: Declaration, loc_ret: Loc<Expr>) -> Expr {
match decl {
Declaration::Declare(def) => {
Expr::LetNonRec(Box::new(def), Box::new(loc_ret), var_store.fresh())
@ -1439,7 +1439,7 @@ fn to_pending_def<'a>(
region,
) {
Ok(symbol) => {
let mut can_rigids: Vec<Located<Lowercase>> = Vec::with_capacity(vars.len());
let mut can_rigids: Vec<Loc<Lowercase>> = Vec::with_capacity(vars.len());
for loc_var in vars.iter() {
match loc_var.value {
@ -1447,7 +1447,7 @@ fn to_pending_def<'a>(
if name.chars().next().unwrap().is_lowercase() =>
{
let lowercase = Lowercase::from(name);
can_rigids.push(Located {
can_rigids.push(Loc {
value: lowercase,
region: loc_var.region,
});
@ -1467,7 +1467,7 @@ fn to_pending_def<'a>(
Some((
Output::default(),
PendingDef::Alias {
name: Located {
name: Loc {
region: name.region,
value: symbol,
},
@ -1500,9 +1500,9 @@ fn to_pending_def<'a>(
fn pending_typed_body<'a>(
env: &mut Env<'a>,
loc_pattern: &'a Located<ast::Pattern<'a>>,
loc_ann: &'a Located<ast::TypeAnnotation<'a>>,
loc_expr: &'a Located<ast::Expr<'a>>,
loc_pattern: &'a Loc<ast::Pattern<'a>>,
loc_ann: &'a Loc<ast::TypeAnnotation<'a>>,
loc_expr: &'a Loc<ast::Expr<'a>>,
var_store: &mut VarStore,
scope: &mut Scope,
pattern_type: PatternType,

View file

@ -3,7 +3,7 @@ use roc_collections::all::{MutMap, MutSet};
use roc_module::ident::{Ident, Lowercase, ModuleName};
use roc_module::symbol::{IdentIds, ModuleId, ModuleIds, Symbol};
use roc_problem::can::{Problem, RuntimeError};
use roc_region::all::{Located, Region};
use roc_region::all::{Loc, Region};
/// The canonicalization environment for a particular module.
pub struct Env<'a> {
@ -88,7 +88,7 @@ impl<'a> Env<'a> {
Ok(symbol)
}
None => Err(RuntimeError::LookupNotInScope(
Located {
Loc {
value: ident,
region,
},

View file

@ -1,11 +1,11 @@
use crate::pattern::Pattern;
use roc_region::all::{Located, Region};
use roc_region::all::{Loc, Region};
use roc_types::types::{AnnotationSource, PReason, Reason};
#[derive(Debug, Clone, PartialEq)]
pub enum Expected<T> {
NoExpectation(T),
FromAnnotation(Located<Pattern>, usize, AnnotationSource, T),
FromAnnotation(Loc<Pattern>, usize, AnnotationSource, T),
ForReason(Reason, T, Region),
}

View file

@ -17,7 +17,7 @@ use roc_module::symbol::Symbol;
use roc_parse::ast::{self, EscapedChar, StrLiteral};
use roc_parse::pattern::PatternType::*;
use roc_problem::can::{PrecedenceProblem, Problem, RuntimeError};
use roc_region::all::{Located, Region};
use roc_region::all::{Loc, Region};
use roc_types::subs::{VarStore, Variable};
use roc_types::types::Alias;
use std::fmt::Debug;
@ -60,7 +60,7 @@ pub enum Expr {
Str(Box<str>),
List {
elem_var: Variable,
loc_elems: Vec<Located<Expr>>,
loc_elems: Vec<Loc<Expr>>,
},
// Lookups
@ -70,25 +70,25 @@ pub enum Expr {
cond_var: Variable,
expr_var: Variable,
region: Region,
loc_cond: Box<Located<Expr>>,
loc_cond: Box<Loc<Expr>>,
branches: Vec<WhenBranch>,
},
If {
cond_var: Variable,
branch_var: Variable,
branches: Vec<(Located<Expr>, Located<Expr>)>,
final_else: Box<Located<Expr>>,
branches: Vec<(Loc<Expr>, Loc<Expr>)>,
final_else: Box<Loc<Expr>>,
},
// Let
LetRec(Vec<Def>, Box<Located<Expr>>, Variable),
LetNonRec(Box<Def>, Box<Located<Expr>>, Variable),
LetRec(Vec<Def>, Box<Loc<Expr>>, Variable),
LetNonRec(Box<Def>, Box<Loc<Expr>>, Variable),
/// This is *only* for calling functions, not for tag application.
/// The Tag variant contains any applied values inside it.
Call(
Box<(Variable, Located<Expr>, Variable, Variable)>,
Vec<(Variable, Located<Expr>)>,
Box<(Variable, Loc<Expr>, Variable, Variable)>,
Vec<(Variable, Loc<Expr>)>,
CalledVia,
),
RunLowLevel {
@ -118,7 +118,7 @@ pub enum Expr {
record_var: Variable,
ext_var: Variable,
field_var: Variable,
loc_expr: Box<Located<Expr>>,
loc_expr: Box<Loc<Expr>>,
field: Lowercase,
},
/// field accessor as a function, e.g. (.foo) expr
@ -146,7 +146,7 @@ pub enum Expr {
variant_var: Variable,
ext_var: Variable,
name: TagName,
arguments: Vec<(Variable, Located<Expr>)>,
arguments: Vec<(Variable, Loc<Expr>)>,
},
ZeroArgumentTag {
@ -154,11 +154,11 @@ pub enum Expr {
variant_var: Variable,
ext_var: Variable,
name: TagName,
arguments: Vec<(Variable, Located<Expr>)>,
arguments: Vec<(Variable, Loc<Expr>)>,
},
// Test
Expect(Box<Located<Expr>>, Box<Located<Expr>>),
Expect(Box<Loc<Expr>>, Box<Loc<Expr>>),
// Compiles, but will crash if reached
RuntimeError(RuntimeError),
@ -172,8 +172,8 @@ pub struct ClosureData {
pub name: Symbol,
pub captured_symbols: Vec<(Symbol, Variable)>,
pub recursive: Recursive,
pub arguments: Vec<(Variable, Located<Pattern>)>,
pub loc_body: Box<Located<Expr>>,
pub arguments: Vec<(Variable, Loc<Pattern>)>,
pub loc_body: Box<Loc<Expr>>,
}
#[derive(Clone, Debug, PartialEq)]
@ -181,7 +181,7 @@ pub struct Field {
pub var: Variable,
// The region of the full `foo: f bar`, rather than just `f bar`
pub region: Region,
pub loc_expr: Box<Located<Expr>>,
pub loc_expr: Box<Loc<Expr>>,
}
#[derive(Clone, Debug, PartialEq)]
@ -193,9 +193,9 @@ pub enum Recursive {
#[derive(Clone, Debug, PartialEq)]
pub struct WhenBranch {
pub patterns: Vec<Located<Pattern>>,
pub value: Located<Expr>,
pub guard: Option<Located<Expr>>,
pub patterns: Vec<Loc<Pattern>>,
pub value: Loc<Expr>,
pub guard: Option<Loc<Expr>>,
}
pub fn canonicalize_expr<'a>(
@ -204,7 +204,7 @@ pub fn canonicalize_expr<'a>(
scope: &mut Scope,
region: Region,
expr: &'a ast::Expr<'a>,
) -> (Located<Expr>, Output) {
) -> (Loc<Expr>, Output) {
use Expr::*;
let (expr, output) = match expr {
@ -762,7 +762,7 @@ pub fn canonicalize_expr<'a>(
binop1_position.col,
binop1_position.col + binop1.width(),
);
let loc_binop1 = Located::at(region1, *binop1);
let loc_binop1 = Loc::at(region1, *binop1);
let region2 = Region::new(
binop2_position.row,
@ -770,7 +770,7 @@ pub fn canonicalize_expr<'a>(
binop2_position.col,
binop2_position.col + binop2.width(),
);
let loc_binop2 = Located::at(region2, *binop2);
let loc_binop2 = Loc::at(region2, *binop2);
let problem =
PrecedenceProblem::BothNonAssociative(*whole_region, loc_binop1, loc_binop2);
@ -859,7 +859,7 @@ pub fn canonicalize_expr<'a>(
// a rounding error anyway (especially given that they'll be surfaced as warnings), LLVM will
// DCE them in optimized builds, and it's not worth the bookkeeping for dev builds.
(
Located {
Loc {
region,
value: expr,
},
@ -1076,7 +1076,7 @@ fn canonicalize_fields<'a>(
var_store: &mut VarStore,
scope: &mut Scope,
region: Region,
fields: &'a [Located<ast::AssignedField<'a, ast::Expr<'a>>>],
fields: &'a [Loc<ast::AssignedField<'a, ast::Expr<'a>>>],
) -> Result<(SendMap<Lowercase, Field>, Output), CanonicalizeRecordProblem> {
let mut can_fields = SendMap::default();
let mut output = Output::default();
@ -1136,7 +1136,7 @@ fn canonicalize_field<'a>(
scope: &mut Scope,
field: &'a ast::AssignedField<'a, ast::Expr<'a>>,
region: Region,
) -> Result<(Lowercase, Located<Expr>, Output, Variable), CanonicalizeFieldProblem> {
) -> Result<(Lowercase, Loc<Expr>, Output, Variable), CanonicalizeFieldProblem> {
use roc_parse::ast::AssignedField::*;
match field {
@ -1251,7 +1251,7 @@ pub fn inline_calls(var_store: &mut VarStore, scope: &mut Scope, expr: Expr) ->
for loc_elem in loc_elems {
let value = inline_calls(var_store, scope, loc_elem.value);
new_elems.push(Located {
new_elems.push(Loc {
value,
region: loc_elem.region,
});
@ -1270,7 +1270,7 @@ pub fn inline_calls(var_store: &mut VarStore, scope: &mut Scope, expr: Expr) ->
loc_cond,
branches,
} => {
let loc_cond = Box::new(Located {
let loc_cond = Box::new(Loc {
region: loc_cond.region,
value: inline_calls(var_store, scope, loc_cond.value),
});
@ -1278,12 +1278,12 @@ pub fn inline_calls(var_store: &mut VarStore, scope: &mut Scope, expr: Expr) ->
let mut new_branches = Vec::with_capacity(branches.len());
for branch in branches {
let value = Located {
let value = Loc {
value: inline_calls(var_store, scope, branch.value.value),
region: branch.value.region,
};
let guard = match branch.guard {
Some(loc_expr) => Some(Located {
Some(loc_expr) => Some(Loc {
region: loc_expr.region,
value: inline_calls(var_store, scope, loc_expr.value),
}),
@ -1315,12 +1315,12 @@ pub fn inline_calls(var_store: &mut VarStore, scope: &mut Scope, expr: Expr) ->
let mut new_branches = Vec::with_capacity(branches.len());
for (loc_cond, loc_expr) in branches {
let loc_cond = Located {
let loc_cond = Loc {
value: inline_calls(var_store, scope, loc_cond.value),
region: loc_cond.region,
};
let loc_expr = Located {
let loc_expr = Loc {
value: inline_calls(var_store, scope, loc_expr.value),
region: loc_expr.region,
};
@ -1328,7 +1328,7 @@ pub fn inline_calls(var_store: &mut VarStore, scope: &mut Scope, expr: Expr) ->
new_branches.push((loc_cond, loc_expr));
}
let final_else = Box::new(Located {
let final_else = Box::new(Loc {
region: final_else.region,
value: inline_calls(var_store, scope, final_else.value),
});
@ -1342,12 +1342,12 @@ pub fn inline_calls(var_store: &mut VarStore, scope: &mut Scope, expr: Expr) ->
}
Expect(loc_condition, loc_expr) => {
let loc_condition = Located {
let loc_condition = Loc {
region: loc_condition.region,
value: inline_calls(var_store, scope, loc_condition.value),
};
let loc_expr = Located {
let loc_expr = Loc {
region: loc_expr.region,
value: inline_calls(var_store, scope, loc_expr.value),
};
@ -1361,7 +1361,7 @@ pub fn inline_calls(var_store: &mut VarStore, scope: &mut Scope, expr: Expr) ->
for def in defs {
new_defs.push(Def {
loc_pattern: def.loc_pattern,
loc_expr: Located {
loc_expr: Loc {
region: def.loc_expr.region,
value: inline_calls(var_store, scope, def.loc_expr.value),
},
@ -1371,7 +1371,7 @@ pub fn inline_calls(var_store: &mut VarStore, scope: &mut Scope, expr: Expr) ->
});
}
let loc_expr = Located {
let loc_expr = Loc {
region: loc_expr.region,
value: inline_calls(var_store, scope, loc_expr.value),
};
@ -1382,7 +1382,7 @@ pub fn inline_calls(var_store: &mut VarStore, scope: &mut Scope, expr: Expr) ->
LetNonRec(def, loc_expr, var) => {
let def = Def {
loc_pattern: def.loc_pattern,
loc_expr: Located {
loc_expr: Loc {
region: def.loc_expr.region,
value: inline_calls(var_store, scope, def.loc_expr.value),
},
@ -1391,7 +1391,7 @@ pub fn inline_calls(var_store: &mut VarStore, scope: &mut Scope, expr: Expr) ->
annotation: def.annotation,
};
let loc_expr = Located {
let loc_expr = Loc {
region: loc_expr.region,
value: inline_calls(var_store, scope, loc_expr.value),
};
@ -1411,7 +1411,7 @@ pub fn inline_calls(var_store: &mut VarStore, scope: &mut Scope, expr: Expr) ->
loc_body,
}) => {
let loc_expr = *loc_body;
let loc_expr = Located {
let loc_expr = Loc {
value: inline_calls(var_store, scope, loc_expr.value),
region: loc_expr.region,
};
@ -1486,7 +1486,7 @@ pub fn inline_calls(var_store: &mut VarStore, scope: &mut Scope, expr: Expr) ->
Var(symbol) if symbol.is_builtin() => match builtin_defs_map(symbol, var_store) {
Some(Def {
loc_expr:
Located {
Loc {
value:
Closure(ClosureData {
recursive,
@ -1526,7 +1526,7 @@ pub fn inline_calls(var_store: &mut VarStore, scope: &mut Scope, expr: Expr) ->
annotation: None,
};
loc_answer = Located {
loc_answer = Loc {
region: Region::zero(),
value: LetNonRec(
Box::new(def),
@ -1585,7 +1585,7 @@ pub fn is_valid_interpolation(expr: &ast::Expr<'_>) -> bool {
}
enum StrSegment {
Interpolation(Located<Expr>),
Interpolation(Loc<Expr>),
Plaintext(Box<str>),
}
@ -1684,22 +1684,22 @@ fn desugar_str_segments(var_store: &mut VarStore, segments: Vec<StrSegment>) ->
let mut iter = segments.into_iter().rev();
let mut loc_expr = match iter.next() {
Some(Plaintext(string)) => Located::new(0, 0, 0, 0, Expr::Str(string)),
Some(Plaintext(string)) => Loc::new(0, 0, 0, 0, Expr::Str(string)),
Some(Interpolation(loc_expr)) => loc_expr,
None => {
// No segments? Empty string!
Located::new(0, 0, 0, 0, Expr::Str("".into()))
Loc::new(0, 0, 0, 0, Expr::Str("".into()))
}
};
for seg in iter {
let loc_new_expr = match seg {
Plaintext(string) => Located::new(0, 0, 0, 0, Expr::Str(string)),
Plaintext(string) => Loc::new(0, 0, 0, 0, Expr::Str(string)),
Interpolation(loc_interpolated_expr) => loc_interpolated_expr,
};
let fn_expr = Located::new(0, 0, 0, 0, Expr::Var(Symbol::STR_CONCAT));
let fn_expr = Loc::new(0, 0, 0, 0, Expr::Var(Symbol::STR_CONCAT));
let expr = Expr::Call(
Box::new((
var_store.fresh(),
@ -1714,7 +1714,7 @@ fn desugar_str_segments(var_store: &mut VarStore, segments: Vec<StrSegment>) ->
CalledVia::StringInterpolation,
);
loc_expr = Located::new(0, 0, 0, 0, expr);
loc_expr = Loc::new(0, 0, 0, 0, expr);
}
loc_expr.value

View file

@ -12,7 +12,7 @@ use roc_module::symbol::{IdentIds, ModuleId, ModuleIds, Symbol};
use roc_parse::ast;
use roc_parse::pattern::PatternType;
use roc_problem::can::{Problem, RuntimeError};
use roc_region::all::{Located, Region};
use roc_region::all::{Loc, Region};
use roc_types::subs::{VarStore, Variable};
use roc_types::types::Alias;
@ -43,7 +43,7 @@ pub struct ModuleOutput {
#[allow(clippy::too_many_arguments)]
pub fn canonicalize_module_defs<'a, F>(
arena: &Bump,
loc_defs: &'a [Located<ast::Def<'a>>],
loc_defs: &'a [Loc<ast::Def<'a>>],
home: ModuleId,
module_ids: &ModuleIds,
exposed_ident_ids: IdentIds,
@ -76,7 +76,7 @@ where
bumpalo::collections::Vec::with_capacity_in(loc_defs.len() + num_deps, arena);
for loc_def in loc_defs.iter() {
desugared.push(&*arena.alloc(Located {
desugared.push(&*arena.alloc(Loc {
value: desugar_def(arena, &loc_def.value),
region: loc_def.region,
}));
@ -263,8 +263,8 @@ where
let runtime_error = RuntimeError::ExposedButNotDefined(symbol);
let def = Def {
loc_pattern: Located::new(0, 0, 0, 0, Pattern::Identifier(symbol)),
loc_expr: Located::new(0, 0, 0, 0, Expr::RuntimeError(runtime_error)),
loc_pattern: Loc::new(0, 0, 0, 0, Pattern::Identifier(symbol)),
loc_expr: Loc::new(0, 0, 0, 0, Expr::RuntimeError(runtime_error)),
expr_var: var_store.fresh(),
pattern_vars,
annotation: None,

View file

@ -7,7 +7,7 @@ use roc_module::called_via::{BinOp, CalledVia};
use roc_module::ident::ModuleName;
use roc_parse::ast::Expr::{self, *};
use roc_parse::ast::{AssignedField, Def, WhenBranch};
use roc_region::all::{Located, Region};
use roc_region::all::{Loc, Region};
// BinOp precedence logic adapted from Gluon by Markus Westerlind
// https://github.com/gluon-lang/gluon - license information can be found in
@ -17,10 +17,10 @@ use roc_region::all::{Located, Region};
fn new_op_call_expr<'a>(
arena: &'a Bump,
left: &'a Located<Expr<'a>>,
loc_op: Located<BinOp>,
right: &'a Located<Expr<'a>>,
) -> Located<Expr<'a>> {
left: &'a Loc<Expr<'a>>,
loc_op: Loc<BinOp>,
right: &'a Loc<Expr<'a>>,
) -> Loc<Expr<'a>> {
let region = Region::span_across(&left.region, &right.region);
let value = match loc_op.value {
@ -51,7 +51,7 @@ fn new_op_call_expr<'a>(
let args = arena.alloc([left, right]);
let loc_expr = arena.alloc(Located {
let loc_expr = arena.alloc(Loc {
value: Expr::Var { module_name, ident },
region: loc_op.region,
});
@ -60,19 +60,19 @@ fn new_op_call_expr<'a>(
}
};
Located { region, value }
Loc { region, value }
}
fn desugar_def_helps<'a>(
arena: &'a Bump,
region: Region,
defs: &'a [&'a Located<Def<'a>>],
loc_ret: &'a Located<Expr<'a>>,
) -> &'a Located<Expr<'a>> {
defs: &'a [&'a Loc<Def<'a>>],
loc_ret: &'a Loc<Expr<'a>>,
) -> &'a Loc<Expr<'a>> {
let mut desugared_defs = Vec::with_capacity_in(defs.len(), arena);
for loc_def in defs.iter() {
let loc_def = Located {
let loc_def = Loc {
value: desugar_def(arena, &loc_def.value),
region: loc_def.region,
};
@ -82,7 +82,7 @@ fn desugar_def_helps<'a>(
let desugared_defs = desugared_defs.into_bump_slice();
arena.alloc(Located {
arena.alloc(Loc {
value: Defs(desugared_defs, desugar_expr(arena, loc_ret)),
region,
})
@ -119,7 +119,7 @@ pub fn desugar_def<'a>(arena: &'a Bump, def: &'a Def<'a>) -> Def<'a> {
/// Reorder the expression tree based on operator precedence and associativity rules,
/// then replace the BinOp nodes with Apply nodes. Also drop SpaceBefore and SpaceAfter nodes.
pub fn desugar_expr<'a>(arena: &'a Bump, loc_expr: &'a Located<Expr<'a>>) -> &'a Located<Expr<'a>> {
pub fn desugar_expr<'a>(arena: &'a Bump, loc_expr: &'a Loc<Expr<'a>>) -> &'a Loc<Expr<'a>> {
match &loc_expr.value {
Float(_)
| Num(_)
@ -136,13 +136,13 @@ pub fn desugar_expr<'a>(arena: &'a Bump, loc_expr: &'a Located<Expr<'a>>) -> &'a
Access(sub_expr, paths) => {
let region = loc_expr.region;
let loc_sub_expr = Located {
let loc_sub_expr = Loc {
region,
value: **sub_expr,
};
let value = Access(&desugar_expr(arena, arena.alloc(loc_sub_expr)).value, paths);
arena.alloc(Located { region, value })
arena.alloc(Loc { region, value })
}
List(items) => {
let mut new_items = Vec::with_capacity_in(items.len(), arena);
@ -153,16 +153,16 @@ pub fn desugar_expr<'a>(arena: &'a Bump, loc_expr: &'a Located<Expr<'a>>) -> &'a
let new_items = new_items.into_bump_slice();
let value: Expr<'a> = List(items.replace_items(new_items));
arena.alloc(Located {
arena.alloc(Loc {
region: loc_expr.region,
value,
})
}
Record(fields) => arena.alloc(Located {
Record(fields) => arena.alloc(Loc {
region: loc_expr.region,
value: Record(fields.map_items(arena, |field| {
let value = desugar_field(arena, &field.value);
Located {
Loc {
value,
region: field.region,
}
@ -173,13 +173,13 @@ pub fn desugar_expr<'a>(arena: &'a Bump, loc_expr: &'a Located<Expr<'a>>) -> &'a
// NOTE the `update` field is always a `Var { .. }` and does not need to be desugared
let new_fields = fields.map_items(arena, |field| {
let value = desugar_field(arena, &field.value);
Located {
Loc {
value,
region: field.region,
}
});
arena.alloc(Located {
arena.alloc(Loc {
region: loc_expr.region,
value: RecordUpdate {
update: *update,
@ -187,7 +187,7 @@ pub fn desugar_expr<'a>(arena: &'a Bump, loc_expr: &'a Located<Expr<'a>>) -> &'a
},
})
}
Closure(loc_patterns, loc_ret) => arena.alloc(Located {
Closure(loc_patterns, loc_ret) => arena.alloc(Loc {
region: loc_expr.region,
value: Closure(loc_patterns, desugar_expr(arena, loc_ret)),
}),
@ -201,17 +201,17 @@ pub fn desugar_expr<'a>(arena: &'a Bump, loc_expr: &'a Located<Expr<'a>>) -> &'a
let desugared_ret = desugar_expr(arena, loc_ret);
let closure = Expr::Closure(loc_patterns, desugared_ret);
let loc_closure = Located::at(loc_expr.region, closure);
let loc_closure = Loc::at(loc_expr.region, closure);
match &desugared_body.value {
Expr::Apply(function, arguments, called_via) => {
let mut new_arguments: Vec<'a, &'a Located<Expr<'a>>> =
let mut new_arguments: Vec<'a, &'a Loc<Expr<'a>>> =
Vec::with_capacity_in(arguments.len() + 1, arena);
new_arguments.extend(arguments.iter());
new_arguments.push(arena.alloc(loc_closure));
let call = Expr::Apply(function, new_arguments.into_bump_slice(), *called_via);
let loc_call = Located::at(loc_expr.region, call);
let loc_call = Loc::at(loc_expr.region, call);
arena.alloc(loc_call)
}
@ -222,7 +222,7 @@ pub fn desugar_expr<'a>(arena: &'a Bump, loc_expr: &'a Located<Expr<'a>>) -> &'a
arena.alloc([&*arena.alloc(loc_closure)]),
CalledVia::Space,
);
let loc_call = Located::at(loc_expr.region, call);
let loc_call = Loc::at(loc_expr.region, call);
arena.alloc(loc_call)
}
@ -239,7 +239,7 @@ pub fn desugar_expr<'a>(arena: &'a Bump, loc_expr: &'a Located<Expr<'a>>) -> &'a
let desugared_args = desugared_args.into_bump_slice();
arena.alloc(Located {
arena.alloc(Loc {
value: Apply(desugar_expr(arena, loc_fn), desugared_args, *called_via),
region: loc_expr.region,
})
@ -271,7 +271,7 @@ pub fn desugar_expr<'a>(arena: &'a Bump, loc_expr: &'a Located<Expr<'a>>) -> &'a
let desugared_branches = desugared_branches.into_bump_slice();
arena.alloc(Located {
arena.alloc(Loc {
value: When(loc_desugared_cond, desugared_branches),
region: loc_expr.region,
})
@ -294,10 +294,10 @@ pub fn desugar_expr<'a>(arena: &'a Bump, loc_expr: &'a Located<Expr<'a>>) -> &'a
ident: "not",
},
};
let loc_fn_var = arena.alloc(Located { region, value });
let loc_fn_var = arena.alloc(Loc { region, value });
let desugared_args = arena.alloc([desugar_expr(arena, loc_arg)]);
arena.alloc(Located {
arena.alloc(Loc {
value: Apply(loc_fn_var, desugared_args, CalledVia::UnaryOp(op)),
region: loc_expr.region,
})
@ -307,7 +307,7 @@ pub fn desugar_expr<'a>(arena: &'a Bump, loc_expr: &'a Located<Expr<'a>>) -> &'a
// are no longer needed and should be dropped.
desugar_expr(
arena,
arena.alloc(Located {
arena.alloc(Loc {
value: **expr,
region: loc_expr.region,
}),
@ -326,7 +326,7 @@ pub fn desugar_expr<'a>(arena: &'a Bump, loc_expr: &'a Located<Expr<'a>>) -> &'a
));
}
arena.alloc(Located {
arena.alloc(Loc {
value: If(desugared_if_thens.into_bump_slice(), desugared_final_else),
region: loc_expr.region,
})
@ -334,7 +334,7 @@ pub fn desugar_expr<'a>(arena: &'a Bump, loc_expr: &'a Located<Expr<'a>>) -> &'a
Expect(condition, continuation) => {
let desugared_condition = &*arena.alloc(desugar_expr(arena, condition));
let desugared_continuation = &*arena.alloc(desugar_expr(arena, continuation));
arena.alloc(Located {
arena.alloc(Loc {
value: Expect(desugared_condition, desugared_continuation),
region: loc_expr.region,
})
@ -350,7 +350,7 @@ fn desugar_field<'a>(
match field {
RequiredValue(loc_str, spaces, loc_expr) => RequiredValue(
Located {
Loc {
value: loc_str.value,
region: loc_str.region,
},
@ -358,7 +358,7 @@ fn desugar_field<'a>(
desugar_expr(arena, loc_expr),
),
OptionalValue(loc_str, spaces, loc_expr) => OptionalValue(
Located {
Loc {
value: loc_str.value,
region: loc_str.region,
},
@ -367,7 +367,7 @@ fn desugar_field<'a>(
),
LabelOnly(loc_str) => {
// Desugar { x } into { x: x }
let loc_expr = Located {
let loc_expr = Loc {
value: Var {
module_name: "",
ident: loc_str.value,
@ -376,7 +376,7 @@ fn desugar_field<'a>(
};
RequiredValue(
Located {
Loc {
value: loc_str.value,
region: loc_str.region,
},
@ -423,11 +423,11 @@ fn binop_to_function(binop: BinOp) -> (&'static str, &'static str) {
fn desugar_bin_ops<'a>(
arena: &'a Bump,
whole_region: Region,
lefts: &'a [(Located<Expr<'_>>, Located<BinOp>)],
right: &'a Located<Expr<'_>>,
) -> &'a Located<Expr<'a>> {
let mut arg_stack: Vec<&'a Located<Expr>> = Vec::with_capacity_in(lefts.len() + 1, arena);
let mut op_stack: Vec<Located<BinOp>> = Vec::with_capacity_in(lefts.len(), arena);
lefts: &'a [(Loc<Expr<'_>>, Loc<BinOp>)],
right: &'a Loc<Expr<'_>>,
) -> &'a Loc<Expr<'a>> {
let mut arg_stack: Vec<&'a Loc<Expr>> = Vec::with_capacity_in(lefts.len() + 1, arena);
let mut op_stack: Vec<Loc<BinOp>> = Vec::with_capacity_in(lefts.len(), arena);
for (loc_expr, loc_op) in lefts {
arg_stack.push(desugar_expr(arena, loc_expr));
@ -447,18 +447,18 @@ fn desugar_bin_ops<'a>(
}
enum Step<'a> {
Error(&'a Located<Expr<'a>>),
Push(Located<BinOp>),
Error(&'a Loc<Expr<'a>>),
Push(Loc<BinOp>),
Skip,
}
fn run_binop_step<'a>(
arena: &'a Bump,
whole_region: Region,
arg_stack: &mut Vec<&'a Located<Expr<'a>>>,
op_stack: &mut Vec<Located<BinOp>>,
next_op: Located<BinOp>,
) -> Result<(), &'a Located<Expr<'a>>> {
arg_stack: &mut Vec<&'a Loc<Expr<'a>>>,
op_stack: &mut Vec<Loc<BinOp>>,
next_op: Loc<BinOp>,
) -> Result<(), &'a Loc<Expr<'a>>> {
use Step::*;
match binop_step(arena, whole_region, arg_stack, op_stack, next_op) {
@ -471,9 +471,9 @@ fn run_binop_step<'a>(
fn binop_step<'a>(
arena: &'a Bump,
whole_region: Region,
arg_stack: &mut Vec<&'a Located<Expr<'a>>>,
op_stack: &mut Vec<Located<BinOp>>,
next_op: Located<BinOp>,
arg_stack: &mut Vec<&'a Loc<Expr<'a>>>,
op_stack: &mut Vec<Loc<BinOp>>,
next_op: Loc<BinOp>,
) -> Step<'a> {
use roc_module::called_via::Associativity::*;
use std::cmp::Ordering;
@ -542,7 +542,7 @@ fn binop_step<'a>(
};
let value = Expr::PrecedenceConflict(arena.alloc(data));
Step::Error(arena.alloc(Located { region, value }))
Step::Error(arena.alloc(Loc { region, value }))
}
_ => {

View file

@ -7,7 +7,7 @@ use roc_module::symbol::Symbol;
use roc_parse::ast::{self, StrLiteral, StrSegment};
use roc_parse::pattern::PatternType;
use roc_problem::can::{MalformedPatternProblem, Problem, RuntimeError};
use roc_region::all::{Located, Region};
use roc_region::all::{Loc, Region};
use roc_types::subs::{VarStore, Variable};
/// A pattern, including possible problems (e.g. shadowing) so that
/// codegen can generate a runtime error if this pattern is reached.
@ -18,12 +18,12 @@ pub enum Pattern {
whole_var: Variable,
ext_var: Variable,
tag_name: TagName,
arguments: Vec<(Variable, Located<Pattern>)>,
arguments: Vec<(Variable, Loc<Pattern>)>,
},
RecordDestructure {
whole_var: Variable,
ext_var: Variable,
destructs: Vec<Located<RecordDestruct>>,
destructs: Vec<Loc<RecordDestruct>>,
},
IntLiteral(Variable, Box<str>, i64),
NumLiteral(Variable, Box<str>, i64),
@ -32,7 +32,7 @@ pub enum Pattern {
Underscore,
// Runtime Exceptions
Shadowed(Region, Located<Ident>),
Shadowed(Region, Loc<Ident>),
// Example: (5 = 1 + 2) is an unsupported pattern in an assignment; Int patterns aren't allowed in assignments!
UnsupportedPattern(Region),
// parse error patterns
@ -50,8 +50,8 @@ pub struct RecordDestruct {
#[derive(Clone, Debug, PartialEq)]
pub enum DestructType {
Required,
Optional(Variable, Located<Expr>),
Guard(Variable, Located<Pattern>),
Optional(Variable, Loc<Expr>),
Guard(Variable, Loc<Pattern>),
}
pub fn symbols_from_pattern(pattern: &Pattern) -> Vec<Symbol> {
@ -104,7 +104,7 @@ pub fn canonicalize_pattern<'a>(
pattern_type: PatternType,
pattern: &ast::Pattern<'a>,
region: Region,
) -> (Output, Located<Pattern>) {
) -> (Output, Loc<Pattern>) {
use roc_parse::ast::Pattern::*;
use PatternType::*;
@ -258,7 +258,7 @@ pub fn canonicalize_pattern<'a>(
Ok(symbol) => {
output.references.bound_symbols.insert(symbol);
destructs.push(Located {
destructs.push(Loc {
region: loc_pattern.region,
value: RecordDestruct {
var: var_store.fresh(),
@ -297,7 +297,7 @@ pub fn canonicalize_pattern<'a>(
output.union(new_output);
destructs.push(Located {
destructs.push(Loc {
region: loc_pattern.region,
value: RecordDestruct {
var: var_store.fresh(),
@ -329,7 +329,7 @@ pub fn canonicalize_pattern<'a>(
output.union(expr_output);
destructs.push(Located {
destructs.push(Loc {
region: loc_pattern.region,
value: RecordDestruct {
var: var_store.fresh(),
@ -391,7 +391,7 @@ pub fn canonicalize_pattern<'a>(
(
output,
Located {
Loc {
region,
value: can_pattern,
},
@ -432,7 +432,7 @@ fn malformed_pattern(env: &mut Env, problem: MalformedPatternProblem, region: Re
pub fn bindings_from_patterns<'a, I>(loc_patterns: I) -> Vec<(Symbol, Region)>
where
I: Iterator<Item = &'a Located<Pattern>>,
I: Iterator<Item = &'a Loc<Pattern>>,
{
let mut answer = Vec::new();
@ -464,7 +464,7 @@ fn add_bindings_from_patterns(
}
}
RecordDestructure { destructs, .. } => {
for Located {
for Loc {
region,
value: RecordDestruct { symbol, .. },
} in destructs

View file

@ -2,7 +2,7 @@ use crate::expr::Expr;
use crate::pattern::Pattern;
use roc_collections::all::ImSet;
use roc_module::symbol::Symbol;
use roc_region::all::{Located, Region};
use roc_region::all::{Loc, Region};
use roc_types::subs::Variable;
#[derive(Clone, Debug, PartialEq)]
@ -10,8 +10,8 @@ pub struct Procedure {
pub name: Option<Box<str>>,
pub is_self_tail_recursive: bool,
pub definition: Region,
pub args: Vec<Located<Pattern>>,
pub body: Located<Expr>,
pub args: Vec<Loc<Pattern>>,
pub body: Loc<Expr>,
pub references: References,
pub var: Variable,
pub ret_var: Variable,
@ -20,8 +20,8 @@ pub struct Procedure {
impl Procedure {
pub fn new(
definition: Region,
args: Vec<Located<Pattern>>,
body: Located<Expr>,
args: Vec<Loc<Pattern>>,
body: Loc<Expr>,
references: References,
var: Variable,
ret_var: Variable,

View file

@ -2,7 +2,7 @@ use roc_collections::all::{MutSet, SendMap};
use roc_module::ident::{Ident, Lowercase};
use roc_module::symbol::{IdentIds, ModuleId, Symbol};
use roc_problem::can::RuntimeError;
use roc_region::all::{Located, Region};
use roc_region::all::{Loc, Region};
use roc_types::subs::{VarStore, Variable};
use roc_types::types::{Alias, Type};
@ -41,7 +41,7 @@ impl Scope {
let mut type_variables: Vec<_> = free_vars.unnamed_vars.into_iter().collect();
type_variables.sort();
for (loc_name, (_, var)) in vars.iter().zip(type_variables) {
variables.push(Located::at(loc_name.region, (loc_name.value.clone(), var)));
variables.push(Loc::at(loc_name.region, (loc_name.value.clone(), var)));
}
let alias = Alias {
@ -87,7 +87,7 @@ impl Scope {
match self.idents.get(ident) {
Some((symbol, _)) => Ok(*symbol),
None => Err(RuntimeError::LookupNotInScope(
Located {
Loc {
region,
value: ident.clone(),
},
@ -110,10 +110,10 @@ impl Scope {
exposed_ident_ids: &IdentIds,
all_ident_ids: &mut IdentIds,
region: Region,
) -> Result<Symbol, (Region, Located<Ident>)> {
) -> Result<Symbol, (Region, Loc<Ident>)> {
match self.idents.get(&ident) {
Some((_, original_region)) => {
let shadow = Located {
let shadow = Loc {
value: ident,
region,
};
@ -172,7 +172,7 @@ impl Scope {
&mut self,
name: Symbol,
region: Region,
vars: Vec<Located<(Lowercase, Variable)>>,
vars: Vec<Loc<(Lowercase, Variable)>>,
typ: Type,
) {
let roc_types::types::VariableDetail {

View file

@ -118,7 +118,7 @@ pub fn canonical_string_literal<'a>(_arena: &Bump, _raw: &'a str, _region: Regio
// }
// }
// fn loc_char<'a, V>(value: V, state: &State<'a>, buf_len: usize) -> Loc<V> {
// fn loc_char<'a, V>(value: V, state: &State<'a>, buf_len: usize) -> Located<V> {
// let start_line = state.line;
// let start_col = state.column + buf_len as u16;
// let end_line = start_line;
@ -135,7 +135,7 @@ pub fn canonical_string_literal<'a>(_arena: &Bump, _raw: &'a str, _region: Regio
// Loc { region, value }
// }
// fn loc_escaped_char<'a, V>(value: V, state: &State<'a>, buf_len: usize) -> Loc<V> {
// fn loc_escaped_char<'a, V>(value: V, state: &State<'a>, buf_len: usize) -> Located<V> {
// let start_line = state.line;
// let start_col = state.column + buf_len as u16;
// let end_line = start_line;
@ -157,7 +157,7 @@ pub fn canonical_string_literal<'a>(_arena: &Bump, _raw: &'a str, _region: Regio
// state: &State<'a>,
// buf_len: usize,
// hex_str_len: usize,
// ) -> Loc<V> {
// ) -> Located<V> {
// let start_line = state.line;
// // +1 due to the `"` which precedes buf.
// let start_col = state.column + buf_len as u16 + 1;