mirror of
https://github.com/roc-lang/roc.git
synced 2025-08-04 12:18:19 +00:00
Merge branch 'main' into return-keyword
This commit is contained in:
commit
294f0c0d1f
197 changed files with 2124 additions and 1678 deletions
|
@ -1,7 +1,7 @@
|
|||
#![allow(clippy::too_many_arguments)]
|
||||
|
||||
use crate::subs::{
|
||||
self, AliasVariables, Content, FlatType, GetSubsSlice, Label, Subs, SubsIndex, UnionLabels,
|
||||
self, AliasVariables, Content, FlatType, GetSubsSlice, Label, Subs, UnionLabels,
|
||||
UnsortedUnionLabels, Variable,
|
||||
};
|
||||
use crate::types::{
|
||||
|
@ -152,7 +152,7 @@ fn find_names_needed(
|
|||
|
||||
// User-defined names are already taken.
|
||||
// We must not accidentally generate names that collide with them!
|
||||
let name = subs.field_names[name_index.index as usize].clone();
|
||||
let name = subs.field_names[name_index.index()].clone();
|
||||
match names_taken.get(&name) {
|
||||
Some(var) if *var == root => {}
|
||||
Some(_) => {
|
||||
|
@ -535,12 +535,12 @@ fn set_root_name(root: Variable, name: Lowercase, subs: &mut Subs) {
|
|||
|
||||
match old_content {
|
||||
FlexVar(_) => {
|
||||
let name_index = SubsIndex::push_new(&mut subs.field_names, name);
|
||||
let name_index = subs.push_field_name(name);
|
||||
let content = FlexVar(Some(name_index));
|
||||
subs.set_content(root, content);
|
||||
}
|
||||
&FlexAbleVar(_, ability) => {
|
||||
let name_index = SubsIndex::push_new(&mut subs.field_names, name);
|
||||
let name_index = subs.push_field_name(name);
|
||||
let content = FlexAbleVar(Some(name_index), ability);
|
||||
subs.set_content(root, content);
|
||||
}
|
||||
|
@ -549,7 +549,7 @@ fn set_root_name(root: Variable, name: Lowercase, subs: &mut Subs) {
|
|||
structure,
|
||||
} => {
|
||||
let structure = *structure;
|
||||
let name_index = SubsIndex::push_new(&mut subs.field_names, name);
|
||||
let name_index = subs.push_field_name(name);
|
||||
let content = RecursionVar {
|
||||
structure,
|
||||
opt_name: Some(name_index),
|
||||
|
@ -680,24 +680,24 @@ fn write_content<'a>(
|
|||
|
||||
match subs.get_content_without_compacting(var) {
|
||||
FlexVar(Some(name_index)) => {
|
||||
let name = &subs.field_names[name_index.index as usize];
|
||||
let name = &subs.field_names[name_index.index()];
|
||||
buf.push_str(name.as_str())
|
||||
}
|
||||
FlexVar(None) => buf.push_str(WILDCARD),
|
||||
RigidVar(name_index) => {
|
||||
let name = &subs.field_names[name_index.index as usize];
|
||||
let name = &subs.field_names[name_index.index()];
|
||||
buf.push_str(name.as_str())
|
||||
}
|
||||
FlexAbleVar(opt_name_index, abilities) => {
|
||||
let name = opt_name_index
|
||||
.map(|name_index| subs.field_names[name_index.index as usize].as_str())
|
||||
.map(|name_index| subs.field_names[name_index.index()].as_str())
|
||||
.unwrap_or(WILDCARD);
|
||||
let abilities = AbilitySet::from_iter(subs.get_subs_slice(*abilities).iter().copied());
|
||||
ctx.able_variables.push((name, abilities));
|
||||
buf.push_str(name);
|
||||
}
|
||||
RigidAbleVar(name_index, abilities) => {
|
||||
let name = subs.field_names[name_index.index as usize].as_str();
|
||||
let name = subs.field_names[name_index.index()].as_str();
|
||||
let abilities = AbilitySet::from_iter(subs.get_subs_slice(*abilities).iter().copied());
|
||||
ctx.able_variables.push((name, abilities));
|
||||
buf.push_str(name);
|
||||
|
@ -713,7 +713,7 @@ fn write_content<'a>(
|
|||
|
||||
ctx.recursion_structs_to_expand.insert(structure_root);
|
||||
} else {
|
||||
let name = &subs.field_names[name_index.index as usize];
|
||||
let name = &subs.field_names[name_index.index()];
|
||||
buf.push_str(name.as_str())
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,7 +11,7 @@ use roc_module::ident::{Lowercase, TagName, Uppercase};
|
|||
use roc_module::symbol::{ModuleId, Symbol};
|
||||
use soa::{Index, Slice};
|
||||
use std::fmt;
|
||||
use std::iter::{once, Iterator};
|
||||
use std::iter::{self, Iterator};
|
||||
|
||||
// if your changes cause this number to go down, great!
|
||||
// please change it to the lower number.
|
||||
|
@ -150,8 +150,14 @@ impl Subs {
|
|||
let mut slices: Vec<SubsSlice<u8>> = Vec::new();
|
||||
|
||||
for field_name in lowercases {
|
||||
let slice =
|
||||
SubsSlice::extend_new(&mut buf, field_name.as_str().as_bytes().iter().copied());
|
||||
let bytes = field_name.as_str().as_bytes();
|
||||
let slice = {
|
||||
let start = buf.len() as u32;
|
||||
|
||||
buf.extend(bytes.iter().copied());
|
||||
|
||||
SubsSlice::new(start, bytes.len() as u16)
|
||||
};
|
||||
slices.push(slice);
|
||||
}
|
||||
|
||||
|
@ -170,8 +176,14 @@ impl Subs {
|
|||
let mut slices: Vec<SerializedTagName> = Vec::new();
|
||||
|
||||
for TagName(uppercase) in tag_names {
|
||||
let slice =
|
||||
SubsSlice::extend_new(&mut buf, uppercase.as_str().as_bytes().iter().copied());
|
||||
let bytes = uppercase.as_str().as_bytes();
|
||||
let slice = {
|
||||
let start = buf.len() as u32;
|
||||
|
||||
buf.extend(bytes.iter().copied());
|
||||
|
||||
SubsSlice::new(start, bytes.len() as u16)
|
||||
};
|
||||
let serialized = SerializedTagName(slice);
|
||||
slices.push(serialized);
|
||||
}
|
||||
|
@ -413,10 +425,10 @@ impl Default for Subs {
|
|||
}
|
||||
|
||||
/// A slice into the Vec<T> of subs
|
||||
pub type SubsSlice<T> = Slice<Subs, T>;
|
||||
pub type SubsSlice<T> = Slice<T>;
|
||||
|
||||
/// An index into the Vec<T> of subs
|
||||
pub type SubsIndex<T> = Index<Subs, T>;
|
||||
pub type SubsIndex<T> = Index<T>;
|
||||
|
||||
// make `subs[some_index]` work. The types/trait resolution make sure we get the
|
||||
// element from the right vector
|
||||
|
@ -425,13 +437,13 @@ impl std::ops::Index<SubsIndex<Variable>> for Subs {
|
|||
type Output = Variable;
|
||||
|
||||
fn index(&self, index: SubsIndex<Variable>) -> &Self::Output {
|
||||
&self.variables[index.index as usize]
|
||||
&self.variables[index.index()]
|
||||
}
|
||||
}
|
||||
|
||||
impl std::ops::IndexMut<SubsIndex<Variable>> for Subs {
|
||||
fn index_mut(&mut self, index: SubsIndex<Variable>) -> &mut Self::Output {
|
||||
&mut self.variables[index.index as usize]
|
||||
&mut self.variables[index.index()]
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -439,7 +451,7 @@ impl std::ops::Index<SubsIndex<Lowercase>> for Subs {
|
|||
type Output = Lowercase;
|
||||
|
||||
fn index(&self, index: SubsIndex<Lowercase>) -> &Self::Output {
|
||||
&self.field_names[index.index as usize]
|
||||
&self.field_names[index.index()]
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -447,7 +459,7 @@ impl std::ops::Index<SubsIndex<usize>> for Subs {
|
|||
type Output = usize;
|
||||
|
||||
fn index(&self, index: SubsIndex<usize>) -> &Self::Output {
|
||||
&self.tuple_elem_indices[index.index as usize]
|
||||
&self.tuple_elem_indices[index.index()]
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -455,13 +467,13 @@ impl std::ops::Index<SubsIndex<TagName>> for Subs {
|
|||
type Output = TagName;
|
||||
|
||||
fn index(&self, index: SubsIndex<TagName>) -> &Self::Output {
|
||||
&self.tag_names[index.index as usize]
|
||||
&self.tag_names[index.index()]
|
||||
}
|
||||
}
|
||||
|
||||
impl std::ops::IndexMut<SubsIndex<TagName>> for Subs {
|
||||
fn index_mut(&mut self, index: SubsIndex<TagName>) -> &mut Self::Output {
|
||||
&mut self.tag_names[index.index as usize]
|
||||
&mut self.tag_names[index.index()]
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -469,13 +481,13 @@ impl std::ops::Index<SubsIndex<Symbol>> for Subs {
|
|||
type Output = Symbol;
|
||||
|
||||
fn index(&self, index: SubsIndex<Symbol>) -> &Self::Output {
|
||||
&self.symbol_names[index.index as usize]
|
||||
&self.symbol_names[index.index()]
|
||||
}
|
||||
}
|
||||
|
||||
impl std::ops::IndexMut<SubsIndex<Symbol>> for Subs {
|
||||
fn index_mut(&mut self, index: SubsIndex<Symbol>) -> &mut Self::Output {
|
||||
&mut self.symbol_names[index.index as usize]
|
||||
&mut self.symbol_names[index.index()]
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -483,19 +495,19 @@ impl std::ops::Index<SubsIndex<Uls>> for Subs {
|
|||
type Output = Uls;
|
||||
|
||||
fn index(&self, index: SubsIndex<Uls>) -> &Self::Output {
|
||||
&self.unspecialized_lambda_sets[index.index as usize]
|
||||
&self.unspecialized_lambda_sets[index.index()]
|
||||
}
|
||||
}
|
||||
|
||||
impl std::ops::IndexMut<SubsIndex<Uls>> for Subs {
|
||||
fn index_mut(&mut self, index: SubsIndex<Uls>) -> &mut Self::Output {
|
||||
&mut self.unspecialized_lambda_sets[index.index as usize]
|
||||
&mut self.unspecialized_lambda_sets[index.index()]
|
||||
}
|
||||
}
|
||||
|
||||
impl std::ops::IndexMut<SubsIndex<Lowercase>> for Subs {
|
||||
fn index_mut(&mut self, index: SubsIndex<Lowercase>) -> &mut Self::Output {
|
||||
&mut self.field_names[index.index as usize]
|
||||
&mut self.field_names[index.index()]
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -503,13 +515,13 @@ impl std::ops::Index<SubsIndex<RecordField<()>>> for Subs {
|
|||
type Output = RecordField<()>;
|
||||
|
||||
fn index(&self, index: SubsIndex<RecordField<()>>) -> &Self::Output {
|
||||
&self.record_fields[index.index as usize]
|
||||
&self.record_fields[index.index()]
|
||||
}
|
||||
}
|
||||
|
||||
impl std::ops::IndexMut<SubsIndex<RecordField<()>>> for Subs {
|
||||
fn index_mut(&mut self, index: SubsIndex<RecordField<()>>) -> &mut Self::Output {
|
||||
&mut self.record_fields[index.index as usize]
|
||||
&mut self.record_fields[index.index()]
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -517,13 +529,13 @@ impl std::ops::Index<SubsIndex<VariableSubsSlice>> for Subs {
|
|||
type Output = VariableSubsSlice;
|
||||
|
||||
fn index(&self, index: SubsIndex<VariableSubsSlice>) -> &Self::Output {
|
||||
&self.variable_slices[index.index as usize]
|
||||
&self.variable_slices[index.index()]
|
||||
}
|
||||
}
|
||||
|
||||
impl std::ops::IndexMut<SubsIndex<VariableSubsSlice>> for Subs {
|
||||
fn index_mut(&mut self, index: SubsIndex<VariableSubsSlice>) -> &mut Self::Output {
|
||||
&mut self.variable_slices[index.index as usize]
|
||||
&mut self.variable_slices[index.index()]
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1613,7 +1625,7 @@ impl Subs {
|
|||
))
|
||||
});
|
||||
|
||||
let u8_slice = subs.insert_into_vars(std::iter::once(Variable::U8));
|
||||
let u8_slice = subs.insert_into_vars(iter::once(Variable::U8));
|
||||
subs.set_content(
|
||||
Variable::LIST_U8,
|
||||
Content::Structure(FlatType::Apply(Symbol::LIST_LIST, u8_slice)),
|
||||
|
@ -1634,7 +1646,64 @@ impl Subs {
|
|||
self.utable.reserve(entries);
|
||||
}
|
||||
|
||||
/// Reserve space for `length` variables in the subs.variables array
|
||||
pub fn push_field_name(&mut self, name: Lowercase) -> Index<Lowercase> {
|
||||
let index = SubsIndex::new(self.field_names.len() as u32);
|
||||
self.field_names.push(name);
|
||||
index
|
||||
}
|
||||
|
||||
pub fn push_tag_name(&mut self, name: TagName) -> Index<TagName> {
|
||||
let index = SubsIndex::new(self.tag_names.len() as u32);
|
||||
self.tag_names.push(name);
|
||||
index
|
||||
}
|
||||
|
||||
pub fn push_symbol_name(&mut self, name: Symbol) -> Index<Symbol> {
|
||||
let index = SubsIndex::new(self.symbol_names.len() as u32);
|
||||
self.symbol_names.push(name);
|
||||
index
|
||||
}
|
||||
|
||||
pub fn extend_tag_names<I>(&mut self, values: I) -> Slice<TagName>
|
||||
where
|
||||
I: IntoIterator<Item = TagName>,
|
||||
{
|
||||
let start = self.tag_names.len() as u32;
|
||||
|
||||
self.tag_names.extend(values);
|
||||
|
||||
let end = self.tag_names.len() as u32;
|
||||
|
||||
Slice::new(start, (end - start) as u16)
|
||||
}
|
||||
|
||||
pub fn extend_field_names<I>(&mut self, values: I) -> Slice<Lowercase>
|
||||
where
|
||||
I: IntoIterator<Item = Lowercase>,
|
||||
{
|
||||
let start = self.field_names.len() as u32;
|
||||
|
||||
self.field_names.extend(values);
|
||||
|
||||
let end = self.field_names.len() as u32;
|
||||
|
||||
Slice::new(start, (end - start) as u16)
|
||||
}
|
||||
|
||||
pub fn extend_symbol_names<I>(&mut self, values: I) -> Slice<Symbol>
|
||||
where
|
||||
I: IntoIterator<Item = Symbol>,
|
||||
{
|
||||
let start = self.symbol_names.len() as u32;
|
||||
|
||||
self.symbol_names.extend(values);
|
||||
|
||||
let end = self.symbol_names.len() as u32;
|
||||
|
||||
Slice::new(start, (end - start) as u16)
|
||||
}
|
||||
|
||||
/// Reserve space for `length` variables in our `variables`
|
||||
///
|
||||
/// This is useful when we know how many variables e.g. a loop will produce,
|
||||
/// but the loop itself also produces new variables. We often want to work
|
||||
|
@ -1709,7 +1778,7 @@ impl Subs {
|
|||
}
|
||||
|
||||
pub fn rigid_var(&mut self, var: Variable, name: Lowercase) {
|
||||
let name_index = SubsIndex::push_new(&mut self.field_names, name);
|
||||
let name_index = self.push_field_name(name);
|
||||
let content = Content::RigidVar(name_index);
|
||||
let desc = Descriptor::from(content);
|
||||
|
||||
|
@ -1717,8 +1786,8 @@ impl Subs {
|
|||
}
|
||||
|
||||
pub fn rigid_able_var(&mut self, var: Variable, name: Lowercase, abilities: AbilitySet) {
|
||||
let name_index = SubsIndex::push_new(&mut self.field_names, name);
|
||||
let abilities = SubsSlice::extend_new(&mut self.symbol_names, abilities.into_sorted_iter());
|
||||
let name_index = self.push_field_name(name);
|
||||
let abilities = self.extend_symbol_names(abilities.into_sorted_iter());
|
||||
let content = Content::RigidAbleVar(name_index, abilities);
|
||||
let desc = Descriptor::from(content);
|
||||
|
||||
|
@ -2561,13 +2630,13 @@ pub type UnionLambdas = UnionLabels<Symbol>;
|
|||
impl UnionTags {
|
||||
pub fn for_result(subs: &mut Subs, ok_payload: Variable, err_payload: Variable) -> Self {
|
||||
let ok_tuple = {
|
||||
let variables_slice = subs.insert_into_vars(std::iter::once(ok_payload));
|
||||
let variables_slice = subs.insert_into_vars(iter::once(ok_payload));
|
||||
|
||||
("Ok".into(), variables_slice)
|
||||
};
|
||||
|
||||
let err_tuple = {
|
||||
let variables_slice = subs.insert_into_vars(std::iter::once(err_payload));
|
||||
let variables_slice = subs.insert_into_vars(iter::once(err_payload));
|
||||
|
||||
("Err".into(), variables_slice)
|
||||
};
|
||||
|
@ -2584,10 +2653,10 @@ impl Label for TagName {
|
|||
subs.get_subs_slice(slice)
|
||||
}
|
||||
fn push_new(subs: &mut Subs, name: Self) -> SubsIndex<Self> {
|
||||
SubsIndex::push_new(&mut subs.tag_names, name)
|
||||
subs.push_tag_name(name)
|
||||
}
|
||||
fn extend_new(subs: &mut Subs, slice: impl IntoIterator<Item = Self>) -> SubsSlice<Self> {
|
||||
SubsSlice::extend_new(&mut subs.tag_names, slice)
|
||||
subs.extend_tag_names(slice)
|
||||
}
|
||||
fn reserve(subs: &mut Subs, size_hint: usize) -> u32 {
|
||||
let tag_names_start = subs.tag_names.len() as u32;
|
||||
|
@ -2603,10 +2672,10 @@ impl Label for Symbol {
|
|||
subs.get_subs_slice(slice)
|
||||
}
|
||||
fn push_new(subs: &mut Subs, name: Self) -> SubsIndex<Self> {
|
||||
SubsIndex::push_new(&mut subs.symbol_names, name)
|
||||
subs.push_symbol_name(name)
|
||||
}
|
||||
fn extend_new(subs: &mut Subs, slice: impl IntoIterator<Item = Self>) -> SubsSlice<Self> {
|
||||
SubsSlice::extend_new(&mut subs.symbol_names, slice)
|
||||
subs.extend_symbol_names(slice)
|
||||
}
|
||||
fn reserve(subs: &mut Subs, size_hint: usize) -> u32 {
|
||||
let symbol_names_start = subs.symbol_names.len() as u32;
|
||||
|
@ -2646,13 +2715,13 @@ where
|
|||
}
|
||||
|
||||
let slice = subs.variable_slices[self.values_start as usize];
|
||||
slice.length == 1
|
||||
slice.len() == 1
|
||||
}
|
||||
|
||||
pub fn from_tag_name_index(index: SubsIndex<L>) -> Self {
|
||||
Self::from_slices(
|
||||
SubsSlice::new(index.index, 1),
|
||||
SubsSlice::new(0, 1), // the first variablesubsslice is the empty slice
|
||||
index.as_slice(),
|
||||
SubsSlice::new(0, 1), // the first VariableSubsSlice is the empty slice
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -2665,8 +2734,8 @@ where
|
|||
|
||||
Self {
|
||||
length: labels.len() as u16,
|
||||
labels_start: labels.start,
|
||||
values_start: variables.start,
|
||||
labels_start: labels.start(),
|
||||
values_start: variables.start(),
|
||||
_marker: Default::default(),
|
||||
}
|
||||
}
|
||||
|
@ -2721,7 +2790,7 @@ where
|
|||
|
||||
Self {
|
||||
length: 1,
|
||||
labels_start: idx.index,
|
||||
labels_start: idx.index() as u32,
|
||||
values_start: 0,
|
||||
_marker: Default::default(),
|
||||
}
|
||||
|
@ -3375,22 +3444,22 @@ fn occurs(
|
|||
safe!([Variable], subs.get_subs_slice(*args)).iter(),
|
||||
),
|
||||
Func(arg_vars, closure_var, ret_var) => {
|
||||
let it = once(safe!(Variable, ret_var))
|
||||
.chain(once(safe!(Variable, closure_var)))
|
||||
let it = iter::once(safe!(Variable, ret_var))
|
||||
.chain(iter::once(safe!(Variable, closure_var)))
|
||||
.chain(safe!([Variable], subs.get_subs_slice(*arg_vars)).iter());
|
||||
short_circuit(subs, root_var, ctx, it)
|
||||
}
|
||||
Record(vars_by_field, ext) => {
|
||||
let slice =
|
||||
VariableSubsSlice::new(vars_by_field.variables_start, vars_by_field.length);
|
||||
let it = once(safe!(Variable, ext))
|
||||
let it = iter::once(safe!(Variable, ext))
|
||||
.chain(safe!([Variable], subs.get_subs_slice(slice)).iter());
|
||||
short_circuit(subs, root_var, ctx, it)
|
||||
}
|
||||
Tuple(vars_by_elem, ext) => {
|
||||
let slice =
|
||||
VariableSubsSlice::new(vars_by_elem.variables_start, vars_by_elem.length);
|
||||
let it = once(safe!(Variable, ext))
|
||||
let it = iter::once(safe!(Variable, ext))
|
||||
.chain(safe!([Variable], subs.get_subs_slice(slice)).iter());
|
||||
short_circuit(subs, root_var, ctx, it)
|
||||
}
|
||||
|
@ -3401,7 +3470,7 @@ fn occurs(
|
|||
short_circuit_help(subs, root_var, ctx, ext_var)
|
||||
}
|
||||
FunctionOrTagUnion(_, _, ext) => {
|
||||
short_circuit(subs, root_var, ctx, once(&ext.var()))
|
||||
short_circuit(subs, root_var, ctx, iter::once(&ext.var()))
|
||||
}
|
||||
RecursiveTagUnion(_, tags, ext) => {
|
||||
let ext_var = ext.var();
|
||||
|
@ -3854,7 +3923,7 @@ fn add_name<F>(
|
|||
where
|
||||
F: FnOnce(SubsIndex<Lowercase>) -> Content,
|
||||
{
|
||||
let given_name = subs.field_names[given_name_index.index as usize].clone();
|
||||
let given_name = subs.field_names[given_name_index.index()].clone();
|
||||
|
||||
let indexed_name = if index == 0 {
|
||||
given_name.clone()
|
||||
|
@ -3867,8 +3936,7 @@ where
|
|||
match taken_names.get(&indexed_name) {
|
||||
None => {
|
||||
if indexed_name != given_name {
|
||||
let indexed_name_index =
|
||||
SubsIndex::push_new(&mut subs.field_names, indexed_name.clone());
|
||||
let indexed_name_index = subs.push_field_name(indexed_name.clone());
|
||||
subs.set_content(var, content_from_name(indexed_name_index));
|
||||
}
|
||||
|
||||
|
@ -3930,11 +3998,11 @@ fn content_to_err_type(
|
|||
|
||||
FlexVar(opt_name) => {
|
||||
let name = match opt_name {
|
||||
Some(name_index) => subs.field_names[name_index.index as usize].clone(),
|
||||
Some(name_index) => subs.field_names[name_index.index()].clone(),
|
||||
None => {
|
||||
// set the name so when this variable occurs elsewhere in the type it gets the same name
|
||||
let name = get_fresh_error_var_name(state);
|
||||
let name_index = SubsIndex::push_new(&mut subs.field_names, name.clone());
|
||||
let name_index = subs.push_field_name(name.clone());
|
||||
|
||||
subs.set_content(var, FlexVar(Some(name_index)));
|
||||
|
||||
|
@ -3946,17 +4014,17 @@ fn content_to_err_type(
|
|||
}
|
||||
|
||||
RigidVar(name_index) => {
|
||||
let name = subs.field_names[name_index.index as usize].clone();
|
||||
let name = subs.field_names[name_index.index()].clone();
|
||||
ErrorType::RigidVar(name)
|
||||
}
|
||||
|
||||
FlexAbleVar(opt_name, abilities) => {
|
||||
let name = match opt_name {
|
||||
Some(name_index) => subs.field_names[name_index.index as usize].clone(),
|
||||
Some(name_index) => subs.field_names[name_index.index()].clone(),
|
||||
None => {
|
||||
// set the name so when this variable occurs elsewhere in the type it gets the same name
|
||||
let name = get_fresh_error_var_name(state);
|
||||
let name_index = SubsIndex::push_new(&mut subs.field_names, name.clone());
|
||||
let name_index = subs.push_field_name(name.clone());
|
||||
|
||||
subs.set_content(var, FlexVar(Some(name_index)));
|
||||
|
||||
|
@ -3969,7 +4037,7 @@ fn content_to_err_type(
|
|||
}
|
||||
|
||||
RigidAbleVar(name_index, abilities) => {
|
||||
let name = subs.field_names[name_index.index as usize].clone();
|
||||
let name = subs.field_names[name_index.index()].clone();
|
||||
let ability_set = AbilitySet::from_iter(subs.get_subs_slice(abilities).iter().copied());
|
||||
ErrorType::RigidAbleVar(name, ability_set)
|
||||
}
|
||||
|
@ -3979,10 +4047,10 @@ fn content_to_err_type(
|
|||
structure,
|
||||
} => {
|
||||
let name = match opt_name {
|
||||
Some(name_index) => subs.field_names[name_index.index as usize].clone(),
|
||||
Some(name_index) => subs.field_names[name_index.index()].clone(),
|
||||
None => {
|
||||
let name = get_fresh_error_var_name(state);
|
||||
let name_index = SubsIndex::push_new(&mut subs.field_names, name.clone());
|
||||
let name_index = subs.push_field_name(name.clone());
|
||||
|
||||
subs.set_content(var, FlexVar(Some(name_index)));
|
||||
|
||||
|
@ -4654,7 +4722,7 @@ impl StorageSubs {
|
|||
offsets: &StorageSubsOffsets,
|
||||
mut ability_names: SubsSlice<Symbol>,
|
||||
) -> SubsSlice<Symbol> {
|
||||
ability_names.start += offsets.symbol_names;
|
||||
ability_names.advance(offsets.symbol_names);
|
||||
|
||||
ability_names
|
||||
}
|
||||
|
@ -4691,7 +4759,7 @@ impl StorageSubs {
|
|||
offsets: &StorageSubsOffsets,
|
||||
mut tag_names: SubsSlice<TagName>,
|
||||
) -> SubsSlice<TagName> {
|
||||
tag_names.start += offsets.tag_names;
|
||||
tag_names.advance(offsets.tag_names);
|
||||
|
||||
tag_names
|
||||
}
|
||||
|
@ -4709,13 +4777,13 @@ impl StorageSubs {
|
|||
offsets: &StorageSubsOffsets,
|
||||
mut slice: VariableSubsSlice,
|
||||
) -> VariableSubsSlice {
|
||||
slice.start += offsets.variables;
|
||||
slice.advance(offsets.variables);
|
||||
|
||||
slice
|
||||
}
|
||||
|
||||
fn offset_uls_slice(offsets: &StorageSubsOffsets, mut slice: SubsSlice<Uls>) -> SubsSlice<Uls> {
|
||||
slice.start += offsets.unspecialized_lambda_sets;
|
||||
slice.advance(offsets.unspecialized_lambda_sets);
|
||||
|
||||
slice
|
||||
}
|
||||
|
@ -4907,9 +4975,9 @@ fn storage_copy_var_to_help(env: &mut StorageCopyVarToEnv<'_>, var: Variable) ->
|
|||
.extend(record_fields.iter().copied());
|
||||
|
||||
RecordFields {
|
||||
length: fields.len() as _,
|
||||
length: fields.len() as u16,
|
||||
field_names_start,
|
||||
variables_start: new_variables.start,
|
||||
variables_start: new_variables.start(),
|
||||
field_types_start,
|
||||
}
|
||||
};
|
||||
|
@ -4934,8 +5002,8 @@ fn storage_copy_var_to_help(env: &mut StorageCopyVarToEnv<'_>, var: Variable) ->
|
|||
env.target.tuple_elem_indices.extend(0..elems.len());
|
||||
|
||||
TupleElems {
|
||||
length: elems.len() as _,
|
||||
variables_start: new_variables.start,
|
||||
length: elems.len() as u16,
|
||||
variables_start: new_variables.start(),
|
||||
elem_index_start,
|
||||
}
|
||||
};
|
||||
|
@ -4951,15 +5019,13 @@ fn storage_copy_var_to_help(env: &mut StorageCopyVarToEnv<'_>, var: Variable) ->
|
|||
}
|
||||
|
||||
FunctionOrTagUnion(tag_names, symbols, ext) => {
|
||||
let new_tag_names = SubsSlice::extend_new(
|
||||
&mut env.target.tag_names,
|
||||
env.source.get_subs_slice(tag_names).iter().cloned(),
|
||||
);
|
||||
let new_tag_names = env
|
||||
.target
|
||||
.extend_tag_names(env.source.get_subs_slice(tag_names).iter().cloned());
|
||||
|
||||
let new_symbols = SubsSlice::extend_new(
|
||||
&mut env.target.symbol_names,
|
||||
env.source.get_subs_slice(symbols).iter().cloned(),
|
||||
);
|
||||
let new_symbols = env
|
||||
.target
|
||||
.extend_symbol_names(env.source.get_subs_slice(symbols).iter().cloned());
|
||||
|
||||
FunctionOrTagUnion(
|
||||
new_tag_names,
|
||||
|
@ -4985,8 +5051,8 @@ fn storage_copy_var_to_help(env: &mut StorageCopyVarToEnv<'_>, var: Variable) ->
|
|||
}
|
||||
|
||||
FlexVar(Some(name_index)) => {
|
||||
let name = env.source.field_names[name_index.index as usize].clone();
|
||||
let new_name_index = SubsIndex::push_new(&mut env.target.field_names, name);
|
||||
let name = env.source.field_names[name_index.index()].clone();
|
||||
let new_name_index = env.target.push_field_name(name);
|
||||
|
||||
let content = FlexVar(Some(new_name_index));
|
||||
env.target.set_content(copy, content);
|
||||
|
@ -5016,8 +5082,8 @@ fn storage_copy_var_to_help(env: &mut StorageCopyVarToEnv<'_>, var: Variable) ->
|
|||
}
|
||||
|
||||
RigidVar(name_index) => {
|
||||
let name = env.source.field_names[name_index.index as usize].clone();
|
||||
let new_name_index = SubsIndex::push_new(&mut env.target.field_names, name);
|
||||
let name = env.source.field_names[name_index.index()].clone();
|
||||
let new_name_index = env.target.push_field_name(name);
|
||||
env.target
|
||||
.set(copy, make_descriptor(FlexVar(Some(new_name_index))));
|
||||
|
||||
|
@ -5026,13 +5092,12 @@ fn storage_copy_var_to_help(env: &mut StorageCopyVarToEnv<'_>, var: Variable) ->
|
|||
|
||||
FlexAbleVar(opt_name_index, abilities) => {
|
||||
let new_name_index = opt_name_index.map(|name_index| {
|
||||
let name = env.source.field_names[name_index.index as usize].clone();
|
||||
SubsIndex::push_new(&mut env.target.field_names, name)
|
||||
let name = env.source.field_names[name_index.index()].clone();
|
||||
env.target.push_field_name(name)
|
||||
});
|
||||
let new_abilities_slice = SubsSlice::extend_new(
|
||||
&mut env.target.symbol_names,
|
||||
env.source.get_subs_slice(abilities).iter().copied(),
|
||||
);
|
||||
let new_abilities_slice = env
|
||||
.target
|
||||
.extend_symbol_names(env.source.get_subs_slice(abilities).iter().copied());
|
||||
|
||||
let content = FlexAbleVar(new_name_index, new_abilities_slice);
|
||||
env.target.set_content(copy, content);
|
||||
|
@ -5041,12 +5106,11 @@ fn storage_copy_var_to_help(env: &mut StorageCopyVarToEnv<'_>, var: Variable) ->
|
|||
}
|
||||
|
||||
RigidAbleVar(name_index, abilities) => {
|
||||
let name = env.source.field_names[name_index.index as usize].clone();
|
||||
let new_name_index = SubsIndex::push_new(&mut env.target.field_names, name);
|
||||
let new_abilities_slice = SubsSlice::extend_new(
|
||||
&mut env.target.symbol_names,
|
||||
env.source.get_subs_slice(abilities).iter().copied(),
|
||||
);
|
||||
let name = env.source.field_names[name_index.index()].clone();
|
||||
let new_name_index = env.target.push_field_name(name);
|
||||
let new_abilities_slice = env
|
||||
.target
|
||||
.extend_symbol_names(env.source.get_subs_slice(abilities).iter().copied());
|
||||
|
||||
env.target.set(
|
||||
copy,
|
||||
|
@ -5069,7 +5133,7 @@ fn storage_copy_var_to_help(env: &mut StorageCopyVarToEnv<'_>, var: Variable) ->
|
|||
}
|
||||
|
||||
let new_arguments = AliasVariables {
|
||||
variables_start: new_variables.start,
|
||||
variables_start: new_variables.start(),
|
||||
..arguments
|
||||
};
|
||||
|
||||
|
@ -5377,9 +5441,9 @@ fn copy_import_to_help(env: &mut CopyImportEnv<'_>, max_rank: Rank, var: Variabl
|
|||
.extend(record_fields.iter().copied());
|
||||
|
||||
RecordFields {
|
||||
length: fields.len() as _,
|
||||
length: fields.len() as u16,
|
||||
field_names_start,
|
||||
variables_start: new_variables.start,
|
||||
variables_start: new_variables.start(),
|
||||
field_types_start,
|
||||
}
|
||||
};
|
||||
|
@ -5404,8 +5468,8 @@ fn copy_import_to_help(env: &mut CopyImportEnv<'_>, max_rank: Rank, var: Variabl
|
|||
env.target.tuple_elem_indices.extend(0..elems.len());
|
||||
|
||||
TupleElems {
|
||||
length: elems.len() as _,
|
||||
variables_start: new_variables.start,
|
||||
length: elems.len() as u16,
|
||||
variables_start: new_variables.start(),
|
||||
elem_index_start,
|
||||
}
|
||||
};
|
||||
|
@ -5422,15 +5486,13 @@ fn copy_import_to_help(env: &mut CopyImportEnv<'_>, max_rank: Rank, var: Variabl
|
|||
}
|
||||
|
||||
FunctionOrTagUnion(tag_names, symbols, ext) => {
|
||||
let new_tag_names = SubsSlice::extend_new(
|
||||
&mut env.target.tag_names,
|
||||
env.source.get_subs_slice(tag_names).iter().cloned(),
|
||||
);
|
||||
let new_tag_names = env
|
||||
.target
|
||||
.extend_tag_names(env.source.get_subs_slice(tag_names).iter().cloned());
|
||||
|
||||
let new_symbols = SubsSlice::extend_new(
|
||||
&mut env.target.symbol_names,
|
||||
env.source.get_subs_slice(symbols).iter().cloned(),
|
||||
);
|
||||
let new_symbols = env
|
||||
.target
|
||||
.extend_symbol_names(env.source.get_subs_slice(symbols).iter().cloned());
|
||||
|
||||
let new_ext = ext.map(|v| copy_import_to_help(env, max_rank, v));
|
||||
|
||||
|
@ -5455,8 +5517,8 @@ fn copy_import_to_help(env: &mut CopyImportEnv<'_>, max_rank: Rank, var: Variabl
|
|||
|
||||
FlexVar(opt_name_index) => {
|
||||
if let Some(name_index) = opt_name_index {
|
||||
let name = env.source.field_names[name_index.index as usize].clone();
|
||||
let new_name_index = SubsIndex::push_new(&mut env.target.field_names, name);
|
||||
let name = env.source.field_names[name_index.index()].clone();
|
||||
let new_name_index = env.target.push_field_name(name);
|
||||
|
||||
let content = FlexVar(Some(new_name_index));
|
||||
env.target.set_content(copy, content);
|
||||
|
@ -5469,17 +5531,16 @@ fn copy_import_to_help(env: &mut CopyImportEnv<'_>, max_rank: Rank, var: Variabl
|
|||
|
||||
FlexAbleVar(opt_name_index, abilities) => {
|
||||
let new_opt_name_index = if let Some(name_index) = opt_name_index {
|
||||
let name = env.source.field_names[name_index.index as usize].clone();
|
||||
let new_name_index = SubsIndex::push_new(&mut env.target.field_names, name);
|
||||
let name = env.source.field_names[name_index.index()].clone();
|
||||
let new_name_index = env.target.push_field_name(name);
|
||||
Some(new_name_index)
|
||||
} else {
|
||||
None
|
||||
};
|
||||
|
||||
let new_abilities = SubsSlice::extend_new(
|
||||
&mut env.target.symbol_names,
|
||||
env.source.get_subs_slice(abilities).iter().copied(),
|
||||
);
|
||||
let new_abilities = env
|
||||
.target
|
||||
.extend_symbol_names(env.source.get_subs_slice(abilities).iter().copied());
|
||||
|
||||
let content = FlexAbleVar(new_opt_name_index, new_abilities);
|
||||
env.target.set_content(copy, content);
|
||||
|
@ -5498,8 +5559,8 @@ fn copy_import_to_help(env: &mut CopyImportEnv<'_>, max_rank: Rank, var: Variabl
|
|||
}
|
||||
|
||||
RigidVar(name_index) => {
|
||||
let name = env.source.field_names[name_index.index as usize].clone();
|
||||
let new_name_index = SubsIndex::push_new(&mut env.target.field_names, name);
|
||||
let name = env.source.field_names[name_index.index()].clone();
|
||||
let new_name_index = env.target.push_field_name(name);
|
||||
|
||||
// If we are copying the import as generalized, we can keep it as rigid.
|
||||
// Otherwise we must make it flex, as this is copying to a non-generalized site.
|
||||
|
@ -5520,13 +5581,11 @@ fn copy_import_to_help(env: &mut CopyImportEnv<'_>, max_rank: Rank, var: Variabl
|
|||
}
|
||||
|
||||
RigidAbleVar(name_index, abilities) => {
|
||||
let name = env.source.field_names[name_index.index as usize].clone();
|
||||
let new_name_index = SubsIndex::push_new(&mut env.target.field_names, name);
|
||||
|
||||
let new_abilities = SubsSlice::extend_new(
|
||||
&mut env.target.symbol_names,
|
||||
env.source.get_subs_slice(abilities).iter().copied(),
|
||||
);
|
||||
let name = env.source.field_names[name_index.index()].clone();
|
||||
let new_name_index = env.target.push_field_name(name);
|
||||
let new_abilities = env
|
||||
.target
|
||||
.extend_symbol_names(env.source.get_subs_slice(abilities).iter().copied());
|
||||
|
||||
// If we are copying the import as generalized, we can keep it as rigid.
|
||||
// Otherwise we must make it flex, as this is copying to a non-generalized site.
|
||||
|
@ -5578,7 +5637,7 @@ fn copy_import_to_help(env: &mut CopyImportEnv<'_>, max_rank: Rank, var: Variabl
|
|||
}
|
||||
|
||||
let new_arguments = AliasVariables {
|
||||
variables_start: new_variables.start,
|
||||
variables_start: new_variables.start(),
|
||||
..arguments
|
||||
};
|
||||
|
||||
|
@ -5751,7 +5810,7 @@ fn instantiate_rigids_help(subs: &mut Subs, max_rank: Rank, initial: Variable) {
|
|||
let ext = *ext;
|
||||
|
||||
for slice_index in tags.variables() {
|
||||
let slice = subs.variable_slices[slice_index.index as usize];
|
||||
let slice = subs.variable_slices[slice_index.index()];
|
||||
stack.extend(var_slice!(slice));
|
||||
}
|
||||
|
||||
|
@ -5767,7 +5826,7 @@ fn instantiate_rigids_help(subs: &mut Subs, max_rank: Rank, initial: Variable) {
|
|||
let rec_var = *rec_var;
|
||||
|
||||
for slice_index in tags.variables() {
|
||||
let slice = subs.variable_slices[slice_index.index as usize];
|
||||
let slice = subs.variable_slices[slice_index.index()];
|
||||
stack.extend(var_slice!(slice));
|
||||
}
|
||||
|
||||
|
@ -5790,7 +5849,7 @@ fn instantiate_rigids_help(subs: &mut Subs, max_rank: Rank, initial: Variable) {
|
|||
ambient_function: _,
|
||||
}) => {
|
||||
for slice_index in solved.variables() {
|
||||
let slice = subs.variable_slices[slice_index.index as usize];
|
||||
let slice = subs.variable_slices[slice_index.index()];
|
||||
stack.extend(var_slice!(slice));
|
||||
}
|
||||
|
||||
|
|
|
@ -5,7 +5,7 @@ use crate::subs::{
|
|||
VariableSubsSlice,
|
||||
};
|
||||
use roc_collections::all::{HumanIndex, ImMap, ImSet, MutMap, MutSet, SendMap};
|
||||
use roc_collections::soa::{Index, Slice};
|
||||
use roc_collections::soa::{index_push_new, slice_extend_new};
|
||||
use roc_collections::VecMap;
|
||||
use roc_error_macros::internal_error;
|
||||
use roc_module::called_via::CalledVia;
|
||||
|
@ -13,6 +13,7 @@ use roc_module::ident::{ForeignSymbol, Lowercase, TagName};
|
|||
use roc_module::low_level::LowLevel;
|
||||
use roc_module::symbol::{Interns, ModuleId, Symbol};
|
||||
use roc_region::all::{Loc, Region};
|
||||
use soa::{Index, Slice};
|
||||
use std::fmt;
|
||||
use std::fmt::Write;
|
||||
use std::path::PathBuf;
|
||||
|
@ -602,7 +603,7 @@ impl Types {
|
|||
self.tags_slices
|
||||
.extend(repeat(Slice::default()).take(length));
|
||||
|
||||
Slice::extend_new(&mut self.tags, repeat(TypeTag::EmptyRecord).take(length))
|
||||
slice_extend_new(&mut self.tags, repeat(TypeTag::EmptyRecord).take(length))
|
||||
}
|
||||
|
||||
fn reserve_type_tag(&mut self) -> Index<TypeTag> {
|
||||
|
@ -610,7 +611,7 @@ impl Types {
|
|||
|
||||
self.tags_slices.push(Slice::default());
|
||||
|
||||
Index::push_new(&mut self.tags, TypeTag::EmptyRecord)
|
||||
index_push_new(&mut self.tags, TypeTag::EmptyRecord)
|
||||
}
|
||||
|
||||
fn set_type_tag(&mut self, index: Index<TypeTag>, tag: TypeTag, type_slice: Slice<TypeTag>) {
|
||||
|
@ -644,10 +645,10 @@ impl Types {
|
|||
extension: &TypeExtension,
|
||||
) -> (UnionTags, Slice<TypeTag>) {
|
||||
let tag_names_slice =
|
||||
Slice::extend_new(&mut self.tag_names, tags.iter().map(|(n, _)| n.clone()));
|
||||
slice_extend_new(&mut self.tag_names, tags.iter().map(|(n, _)| n.clone()));
|
||||
|
||||
// Store the payload slices in the aside buffer
|
||||
let type_slices = Slice::extend_new(
|
||||
let type_slices = slice_extend_new(
|
||||
&mut self.aside_types_slices,
|
||||
std::iter::repeat(Slice::default()).take(tags.len()),
|
||||
);
|
||||
|
@ -698,7 +699,7 @@ impl Types {
|
|||
Slice::new(slice.start() as _, slice.len() as _)
|
||||
};
|
||||
|
||||
let type_argument_abilities = Slice::extend_new(
|
||||
let type_argument_abilities = slice_extend_new(
|
||||
&mut self.type_arg_abilities,
|
||||
type_arguments
|
||||
.iter()
|
||||
|
@ -706,7 +707,7 @@ impl Types {
|
|||
);
|
||||
|
||||
// TODO: populate correctly
|
||||
let type_argument_regions = Slice::extend_new(
|
||||
let type_argument_regions = slice_extend_new(
|
||||
&mut self.regions,
|
||||
std::iter::repeat(Region::zero()).take(type_arguments.len()),
|
||||
);
|
||||
|
@ -759,7 +760,7 @@ impl Types {
|
|||
}
|
||||
Type::Apply(symbol, arguments, region) => {
|
||||
let type_argument_regions =
|
||||
Slice::extend_new(&mut self.regions, arguments.iter().map(|t| t.region));
|
||||
slice_extend_new(&mut self.regions, arguments.iter().map(|t| t.region));
|
||||
|
||||
let type_slice = {
|
||||
let slice = self.reserve_type_tags(arguments.len());
|
||||
|
@ -835,17 +836,17 @@ impl Types {
|
|||
slice
|
||||
};
|
||||
|
||||
let field_types = Slice::extend_new(
|
||||
let field_types = slice_extend_new(
|
||||
&mut self.field_types,
|
||||
fields.values().map(|f| f.map(|_| ())),
|
||||
);
|
||||
|
||||
let field_names = Slice::extend_new(&mut self.field_names, fields.keys().cloned());
|
||||
let field_names = slice_extend_new(&mut self.field_names, fields.keys().cloned());
|
||||
|
||||
let record_fields = RecordFields {
|
||||
length: fields.len() as u16,
|
||||
field_names_start: field_names.start() as u32,
|
||||
variables_start: field_type_slice.start() as u32,
|
||||
variables_start: field_type_slice.start(),
|
||||
field_types_start: field_types.start() as u32,
|
||||
};
|
||||
|
||||
|
@ -870,11 +871,11 @@ impl Types {
|
|||
};
|
||||
|
||||
let elem_index_slice =
|
||||
Slice::extend_new(&mut self.tuple_elem_indices, elems.iter().map(|(i, _)| *i));
|
||||
slice_extend_new(&mut self.tuple_elem_indices, elems.iter().map(|(i, _)| *i));
|
||||
|
||||
let tuple_elems = TupleElems {
|
||||
length: elems.len() as u16,
|
||||
variables_start: elem_type_slice.start() as u32,
|
||||
variables_start: elem_type_slice.start(),
|
||||
elem_index_start: elem_index_slice.start() as u32,
|
||||
};
|
||||
|
||||
|
@ -902,7 +903,7 @@ impl Types {
|
|||
infer_ext_in_output_types,
|
||||
}) => {
|
||||
let type_argument_regions =
|
||||
Slice::extend_new(&mut self.regions, type_arguments.iter().map(|t| t.region));
|
||||
slice_extend_new(&mut self.regions, type_arguments.iter().map(|t| t.region));
|
||||
|
||||
let type_arguments_slice = {
|
||||
let slice = self.reserve_type_tags(type_arguments.len());
|
||||
|
@ -936,7 +937,7 @@ impl Types {
|
|||
Slice::new(slice.start() as _, slice.len() as _)
|
||||
};
|
||||
|
||||
let type_argument_abilities = Slice::extend_new(
|
||||
let type_argument_abilities = slice_extend_new(
|
||||
&mut self.type_arg_abilities,
|
||||
type_arguments
|
||||
.iter()
|
||||
|
@ -951,7 +952,7 @@ impl Types {
|
|||
infer_ext_in_output_variables: infer_ext_in_output_slice,
|
||||
};
|
||||
|
||||
let shared = Index::push_new(&mut self.aliases, alias_shared);
|
||||
let shared = index_push_new(&mut self.aliases, alias_shared);
|
||||
|
||||
let tag = TypeTag::DelayedAlias { shared };
|
||||
|
||||
|
@ -982,7 +983,7 @@ impl Types {
|
|||
infer_ext_in_output_types,
|
||||
);
|
||||
|
||||
let shared = Index::push_new(&mut self.aliases, alias_shared);
|
||||
let shared = index_push_new(&mut self.aliases, alias_shared);
|
||||
let actual = self.from_old_type(actual);
|
||||
|
||||
let tag = match kind {
|
||||
|
@ -1056,7 +1057,7 @@ impl Types {
|
|||
lambda_set_variables: new_lambda_set_variables,
|
||||
infer_ext_in_output_variables: new_infer_ext_in_output_variables,
|
||||
};
|
||||
Index::push_new(&mut self.aliases, new_shared)
|
||||
index_push_new(&mut self.aliases, new_shared)
|
||||
}};
|
||||
}
|
||||
|
||||
|
@ -1064,7 +1065,7 @@ impl Types {
|
|||
($union_tags:expr) => {{
|
||||
let (tags, payload_slices) = self.union_tag_slices($union_tags);
|
||||
|
||||
let new_payload_slices = Slice::extend_new(
|
||||
let new_payload_slices = slice_extend_new(
|
||||
&mut self.aside_types_slices,
|
||||
std::iter::repeat(Slice::default()).take(payload_slices.len()),
|
||||
);
|
||||
|
@ -1280,8 +1281,8 @@ mod debug_types {
|
|||
};
|
||||
|
||||
use super::{TypeTag, Types};
|
||||
use roc_collections::soa::{Index, Slice};
|
||||
use roc_module::ident::TagName;
|
||||
use soa::{Index, Slice};
|
||||
use ven_pretty::{text, Arena, DocAllocator, DocBuilder};
|
||||
|
||||
pub struct DebugTag<'a>(pub &'a Types, pub Index<TypeTag>);
|
||||
|
@ -1419,8 +1420,8 @@ mod debug_types {
|
|||
let (names, kind, tys) = types.record_fields_slices(fields);
|
||||
let fmt_fields = names
|
||||
.into_iter()
|
||||
.zip(kind.into_iter())
|
||||
.zip(tys.into_iter())
|
||||
.zip(kind)
|
||||
.zip(tys)
|
||||
.map(|((name, kind), ty)| {
|
||||
let (name, kind) = (&types[name], types[kind]);
|
||||
let fmt_kind = f.text(match kind {
|
||||
|
@ -1482,19 +1483,19 @@ mod debug_types {
|
|||
ext_slice: Slice<TypeTag>,
|
||||
) -> DocBuilder<'a, Arena<'a>> {
|
||||
let (tags, payload_slices) = types.union_tag_slices(tags);
|
||||
let fmt_tags =
|
||||
tags.into_iter()
|
||||
.zip(payload_slices.into_iter())
|
||||
.map(|(tag, payload_slice_index)| {
|
||||
let payload_slice = types[payload_slice_index];
|
||||
let fmt_payloads = payload_slice
|
||||
.into_iter()
|
||||
.map(|p| typ(types, f, TPrec::Arg, p));
|
||||
let iter = Some(f.text(types[tag].0.to_string()))
|
||||
.into_iter()
|
||||
.chain(fmt_payloads);
|
||||
f.intersperse(iter, f.text(" "))
|
||||
});
|
||||
let fmt_tags = tags
|
||||
.into_iter()
|
||||
.zip(payload_slices)
|
||||
.map(|(tag, payload_slice_index)| {
|
||||
let payload_slice = types[payload_slice_index];
|
||||
let fmt_payloads = payload_slice
|
||||
.into_iter()
|
||||
.map(|p| typ(types, f, TPrec::Arg, p));
|
||||
let iter = Some(f.text(types[tag].0.to_string()))
|
||||
.into_iter()
|
||||
.chain(fmt_payloads);
|
||||
f.intersperse(iter, f.text(" "))
|
||||
});
|
||||
|
||||
prefix.append(f.text("[")).append(
|
||||
f.intersperse(fmt_tags, f.reflow(", "))
|
||||
|
@ -1523,7 +1524,7 @@ mod debug_types {
|
|||
let args = types.get_type_arguments(tag);
|
||||
let fmt_args = args
|
||||
.into_iter()
|
||||
.zip(type_argument_abilities.into_iter())
|
||||
.zip(type_argument_abilities)
|
||||
.map(|(arg, abilities)| {
|
||||
let abilities = &types[abilities];
|
||||
let arg = typ(types, f, Arg, arg);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue