Merge remote-tracking branch 'remote/main' into rebuild-platform

This commit is contained in:
Luke Boswell 2024-10-24 10:21:08 +11:00
commit 926014518f
No known key found for this signature in database
GPG key ID: F6DB3C9DB47377B0
221 changed files with 2990 additions and 2303 deletions

10
Cargo.lock generated
View file

@ -2353,6 +2353,7 @@ dependencies = [
"roc_region", "roc_region",
"roc_serialize", "roc_serialize",
"roc_types", "roc_types",
"soa",
"static_assertions", "static_assertions",
"ven_pretty", "ven_pretty",
] ]
@ -2441,6 +2442,7 @@ dependencies = [
"im", "im",
"im-rc", "im-rc",
"smallvec", "smallvec",
"soa",
"wyhash", "wyhash",
] ]
@ -2461,6 +2463,7 @@ dependencies = [
"roc_problem", "roc_problem",
"roc_region", "roc_region",
"roc_types", "roc_types",
"soa",
] ]
[[package]] [[package]]
@ -2901,6 +2904,7 @@ dependencies = [
"roc_error_macros", "roc_error_macros",
"roc_module", "roc_module",
"roc_region", "roc_region",
"soa",
"tempfile", "tempfile",
] ]
@ -3113,6 +3117,7 @@ dependencies = [
"roc_target", "roc_target",
"roc_types", "roc_types",
"roc_unify", "roc_unify",
"soa",
"tempfile", "tempfile",
"test_solve_helpers", "test_solve_helpers",
] ]
@ -3204,6 +3209,7 @@ dependencies = [
"roc_parse", "roc_parse",
"roc_region", "roc_region",
"roc_serialize", "roc_serialize",
"soa",
"static_assertions", "static_assertions",
"ven_pretty", "ven_pretty",
] ]
@ -3609,6 +3615,10 @@ version = "1.11.1"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "942b4a808e05215192e39f4ab80813e599068285906cc91aa64f923db842bd5a" checksum = "942b4a808e05215192e39f4ab80813e599068285906cc91aa64f923db842bd5a"
[[package]]
name = "soa"
version = "0.0.1"
[[package]] [[package]]
name = "socket2" name = "socket2"
version = "0.4.9" version = "0.4.9"

View file

@ -22,6 +22,7 @@ members = [
"crates/valgrind_tests", "crates/valgrind_tests",
"crates/tracing", "crates/tracing",
"crates/utils/*", "crates/utils/*",
"crates/soa",
"crates/docs", "crates/docs",
"crates/docs_cli", "crates/docs_cli",
"crates/linker", "crates/linker",
@ -75,6 +76,8 @@ inkwell = { git = "https://github.com/roc-lang/inkwell", branch = "inkwell-llvm-
"llvm16-0", "llvm16-0",
] } ] }
soa = { path = "crates/soa" }
arrayvec = "0.7.2" # update roc_std/Cargo.toml on change arrayvec = "0.7.2" # update roc_std/Cargo.toml on change
backtrace = "0.3.67" backtrace = "0.3.67"
base64-url = "1.4.13" base64-url = "1.4.13"
@ -138,7 +141,10 @@ maplit = "1.0.2"
memmap2 = "0.5.10" memmap2 = "0.5.10"
mimalloc = { version = "0.1.34", default-features = false } mimalloc = { version = "0.1.34", default-features = false }
nonempty = "0.8.1" nonempty = "0.8.1"
object = { version = "0.32.2", default-features = false, features = ["read", "write"] } object = { version = "0.32.2", default-features = false, features = [
"read",
"write",
] }
packed_struct = "0.10.1" packed_struct = "0.10.1"
page_size = "0.5.0" page_size = "0.5.0"
palette = "0.6.1" palette = "0.6.1"

View file

@ -973,7 +973,15 @@ pub fn build(
// ManuallyDrop will leak the bytes because we don't drop manually // ManuallyDrop will leak the bytes because we don't drop manually
let bytes = &ManuallyDrop::new(std::fs::read(&binary_path).unwrap()); let bytes = &ManuallyDrop::new(std::fs::read(&binary_path).unwrap());
roc_run(&arena, opt_level, target, args, bytes, expect_metadata) roc_run(
&arena,
path,
opt_level,
target,
args,
bytes,
expect_metadata,
)
} }
BuildAndRunIfNoErrors => { BuildAndRunIfNoErrors => {
if problems.fatally_errored { if problems.fatally_errored {
@ -1008,7 +1016,15 @@ pub fn build(
// ManuallyDrop will leak the bytes because we don't drop manually // ManuallyDrop will leak the bytes because we don't drop manually
let bytes = &ManuallyDrop::new(std::fs::read(&binary_path).unwrap()); let bytes = &ManuallyDrop::new(std::fs::read(&binary_path).unwrap());
roc_run(&arena, opt_level, target, args, bytes, expect_metadata) roc_run(
&arena,
path,
opt_level,
target,
args,
bytes,
expect_metadata,
)
} }
} }
} }
@ -1021,6 +1037,7 @@ pub fn build(
fn roc_run<'a, I: IntoIterator<Item = &'a OsStr>>( fn roc_run<'a, I: IntoIterator<Item = &'a OsStr>>(
arena: &Bump, arena: &Bump,
script_path: &Path,
opt_level: OptLevel, opt_level: OptLevel,
target: Target, target: Target,
args: I, args: I,
@ -1060,7 +1077,14 @@ fn roc_run<'a, I: IntoIterator<Item = &'a OsStr>>(
Ok(0) Ok(0)
} }
_ => roc_run_native(arena, opt_level, args, binary_bytes, expect_metadata), _ => roc_run_native(
arena,
script_path,
opt_level,
args,
binary_bytes,
expect_metadata,
),
} }
} }
@ -1077,7 +1101,7 @@ fn os_str_as_utf8_bytes(os_str: &OsStr) -> &[u8] {
fn make_argv_envp<'a, I: IntoIterator<Item = S>, S: AsRef<OsStr>>( fn make_argv_envp<'a, I: IntoIterator<Item = S>, S: AsRef<OsStr>>(
arena: &'a Bump, arena: &'a Bump,
executable: &ExecutableFile, script_path: &Path,
args: I, args: I,
) -> ( ) -> (
bumpalo::collections::Vec<'a, CString>, bumpalo::collections::Vec<'a, CString>,
@ -1085,8 +1109,7 @@ fn make_argv_envp<'a, I: IntoIterator<Item = S>, S: AsRef<OsStr>>(
) { ) {
use bumpalo::collections::CollectIn; use bumpalo::collections::CollectIn;
let path = executable.as_path(); let path_cstring = CString::new(os_str_as_utf8_bytes(script_path.as_os_str())).unwrap();
let path_cstring = CString::new(os_str_as_utf8_bytes(path.as_os_str())).unwrap();
// argv is an array of pointers to strings passed to the new program // argv is an array of pointers to strings passed to the new program
// as its command-line arguments. By convention, the first of these // as its command-line arguments. By convention, the first of these
@ -1124,6 +1147,7 @@ fn make_argv_envp<'a, I: IntoIterator<Item = S>, S: AsRef<OsStr>>(
#[cfg(target_family = "unix")] #[cfg(target_family = "unix")]
fn roc_run_native<I: IntoIterator<Item = S>, S: AsRef<OsStr>>( fn roc_run_native<I: IntoIterator<Item = S>, S: AsRef<OsStr>>(
arena: &Bump, arena: &Bump,
script_path: &Path,
opt_level: OptLevel, opt_level: OptLevel,
args: I, args: I,
binary_bytes: &[u8], binary_bytes: &[u8],
@ -1132,7 +1156,7 @@ fn roc_run_native<I: IntoIterator<Item = S>, S: AsRef<OsStr>>(
use bumpalo::collections::CollectIn; use bumpalo::collections::CollectIn;
let executable = roc_run_executable_file_path(binary_bytes)?; let executable = roc_run_executable_file_path(binary_bytes)?;
let (argv_cstrings, envp_cstrings) = make_argv_envp(arena, &executable, args); let (argv_cstrings, envp_cstrings) = make_argv_envp(arena, script_path, args);
let argv: bumpalo::collections::Vec<*const c_char> = argv_cstrings let argv: bumpalo::collections::Vec<*const c_char> = argv_cstrings
.iter() .iter()
@ -1387,6 +1411,7 @@ fn roc_run_executable_file_path(binary_bytes: &[u8]) -> std::io::Result<Executab
#[cfg(not(target_family = "unix"))] #[cfg(not(target_family = "unix"))]
fn roc_run_native<I: IntoIterator<Item = S>, S: AsRef<OsStr>>( fn roc_run_native<I: IntoIterator<Item = S>, S: AsRef<OsStr>>(
arena: &Bump, // This should be passed an owned value, not a reference, so we can usefully mem::forget it! arena: &Bump, // This should be passed an owned value, not a reference, so we can usefully mem::forget it!
script_path: &Path,
opt_level: OptLevel, opt_level: OptLevel,
args: I, args: I,
binary_bytes: &[u8], binary_bytes: &[u8],
@ -1398,7 +1423,7 @@ fn roc_run_native<I: IntoIterator<Item = S>, S: AsRef<OsStr>>(
let executable = roc_run_executable_file_path(binary_bytes)?; let executable = roc_run_executable_file_path(binary_bytes)?;
// TODO forward the arguments // TODO forward the arguments
let (argv_cstrings, envp_cstrings) = make_argv_envp(&arena, &executable, args); let (argv_cstrings, envp_cstrings) = make_argv_envp(&arena, script_path, args);
let argv: bumpalo::collections::Vec<*const c_char> = argv_cstrings let argv: bumpalo::collections::Vec<*const c_char> = argv_cstrings
.iter() .iter()

View file

@ -17,10 +17,12 @@ use roc_load::{LoadingProblem, Threading};
use roc_packaging::cache::{self, RocCacheDir}; use roc_packaging::cache::{self, RocCacheDir};
use roc_target::Target; use roc_target::Target;
use std::fs::{self, FileType}; use std::fs::{self, FileType};
use std::io::BufRead;
use std::io::{self, Read, Write}; use std::io::{self, Read, Write};
use std::path::{Path, PathBuf}; use std::path::{Path, PathBuf};
use std::str::FromStr; use std::str::FromStr;
use target_lexicon::Triple; use target_lexicon::Triple;
use tempfile::Builder;
#[global_allocator] #[global_allocator]
static ALLOC: mimalloc::MiMalloc = mimalloc::MiMalloc; static ALLOC: mimalloc::MiMalloc = mimalloc::MiMalloc;
@ -205,26 +207,89 @@ fn main() -> io::Result<()> {
let opt_main_path = matches.get_one::<PathBuf>(FLAG_MAIN); let opt_main_path = matches.get_one::<PathBuf>(FLAG_MAIN);
match check_file( match roc_file_path.extension().and_then(OsStr::to_str) {
&arena, Some("md") => {
roc_file_path.to_owned(), // Extract the blocks of roc code
opt_main_path.cloned(), let file = fs::File::open(roc_file_path.as_path())?;
emit_timings, let markdown_file_reader = io::BufReader::new(file);
RocCacheDir::Persistent(cache::roc_cache_packages_dir().as_path()), let mut roc_blocks: Vec<String> = Vec::new();
threading, let mut in_roc_block: bool = false;
) { let mut current_block = String::new();
Ok((problems, total_time)) => {
problems.print_error_warning_count(total_time);
Ok(problems.exit_code())
}
Err(LoadingProblem::FormattedReport(report)) => { for line in markdown_file_reader.lines() {
print!("{report}"); let line = line.unwrap();
if line == "```roc" {
in_roc_block = true;
} else if (line == "```") & in_roc_block {
in_roc_block = false;
roc_blocks.push(current_block);
current_block = String::new();
} else if in_roc_block {
current_block.push_str(&line);
current_block.push_str("\n");
}
}
Ok(1) // now check each block, we exit early if any single block does not check
let mut exit_code = 0;
for block in roc_blocks.iter() {
let mut file = Builder::new().suffix(".roc").tempfile()?;
write!(file, "{}", block)?;
match check_file(
&arena,
file.path().to_owned(),
opt_main_path.cloned(),
emit_timings,
RocCacheDir::Persistent(cache::roc_cache_packages_dir().as_path()),
threading,
) {
Ok((problems, total_time)) => {
problems.print_error_warning_count(total_time);
exit_code = problems.exit_code();
}
Err(LoadingProblem::FormattedReport(report)) => {
print!("{report}");
exit_code = 1;
}
Err(other) => {
panic!("build_file failed with error:\n{other:?}");
}
}
if exit_code != 0 {
break;
}
}
Ok(exit_code)
} }
Err(other) => { _ => {
panic!("build_file failed with error:\n{other:?}"); match check_file(
&arena,
roc_file_path.to_owned(),
opt_main_path.cloned(),
emit_timings,
RocCacheDir::Persistent(cache::roc_cache_packages_dir().as_path()),
threading,
) {
Ok((problems, total_time)) => {
problems.print_error_warning_count(total_time);
Ok(problems.exit_code())
}
Err(LoadingProblem::FormattedReport(report)) => {
print!("{report}");
Ok(1)
}
Err(other) => {
panic!("build_file failed with error:\n{other:?}");
}
}
} }
} }
} }

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,17 @@
# A Simple Markdown Example
This file contains `form.roc` embedded as a block in Markdown. It lets us test that `roc check` works with Markdown.
```roc
module [foo]
foo = "Foo"
```
Excitingly, we can have another block of Roc code as well! (In this case it is the same one...)
```roc
module [bar]
bar = "Bar"
```

View file

@ -512,7 +512,7 @@ removeHelper = \buckets, bucketIndex, distAndFingerprint, data, key ->
## alterValue : Result Bool [Missing] -> Result Bool [Missing] ## alterValue : Result Bool [Missing] -> Result Bool [Missing]
## alterValue = \possibleValue -> ## alterValue = \possibleValue ->
## when possibleValue is ## when possibleValue is
## Err -> Ok Bool.false ## Err Missing -> Ok Bool.false
## Ok value -> if value then Err Missing else Ok Bool.true ## Ok value -> if value then Err Missing else Ok Bool.true
## ##
## expect Dict.update (Dict.empty {}) "a" alterValue == Dict.single "a" Bool.false ## expect Dict.update (Dict.empty {}) "a" alterValue == Dict.single "a" Bool.false

View file

@ -24,6 +24,8 @@ bitvec.workspace = true
bumpalo.workspace = true bumpalo.workspace = true
static_assertions.workspace = true static_assertions.workspace = true
soa.workspace = true
[dev-dependencies] [dev-dependencies]
indoc.workspace = true indoc.workspace = true
insta.workspace = true insta.workspace = true

View file

@ -683,7 +683,7 @@ impl IAbilitiesStore<Pending> {
} }
mod serialize { mod serialize {
use roc_collections::{MutMap, VecMap}; use roc_collections::{soa::slice_extend_new, MutMap, VecMap};
use roc_module::symbol::Symbol; use roc_module::symbol::Symbol;
use roc_region::all::Region; use roc_region::all::Region;
use roc_serialize::bytes; use roc_serialize::bytes;
@ -1034,11 +1034,11 @@ mod serialize {
specialization_lambda_sets, specialization_lambda_sets,
} in spec_info } in spec_info
{ {
let regions = SubsSlice::extend_new( let regions = slice_extend_new(
&mut spec_lambda_sets_regions, &mut spec_lambda_sets_regions,
specialization_lambda_sets.keys().copied(), specialization_lambda_sets.keys().copied(),
); );
let vars = SubsSlice::extend_new( let vars = slice_extend_new(
&mut spec_lambda_sets_vars, &mut spec_lambda_sets_vars,
specialization_lambda_sets.values().copied(), specialization_lambda_sets.values().copied(),
); );
@ -1168,11 +1168,11 @@ mod serialize {
symbol, symbol,
specialization_lambda_sets, specialization_lambda_sets,
}) => { }) => {
let regions = SubsSlice::extend_new( let regions = slice_extend_new(
&mut spec_lambda_sets_regions, &mut spec_lambda_sets_regions,
specialization_lambda_sets.keys().copied(), specialization_lambda_sets.keys().copied(),
); );
let vars = SubsSlice::extend_new( let vars = slice_extend_new(
&mut spec_lambda_sets_vars, &mut spec_lambda_sets_vars,
specialization_lambda_sets.values().copied(), specialization_lambda_sets.values().copied(),
); );

View file

@ -5,12 +5,13 @@ use std::sync::Arc;
use crate::abilities::SpecializationId; use crate::abilities::SpecializationId;
use crate::exhaustive::{ExhaustiveContext, SketchedRows}; use crate::exhaustive::{ExhaustiveContext, SketchedRows};
use crate::expected::{Expected, PExpected}; use crate::expected::{Expected, PExpected};
use roc_collections::soa::{EitherIndex, Index, Slice}; use roc_collections::soa::{index_push_new, slice_extend_new};
use roc_module::ident::TagName; use roc_module::ident::TagName;
use roc_module::symbol::{ModuleId, Symbol}; use roc_module::symbol::{ModuleId, Symbol};
use roc_region::all::{Loc, Region}; use roc_region::all::{Loc, Region};
use roc_types::subs::{ExhaustiveMark, IllegalCycleMark, Variable}; use roc_types::subs::{ExhaustiveMark, IllegalCycleMark, Variable};
use roc_types::types::{Category, PatternCategory, TypeTag, Types}; use roc_types::types::{Category, PatternCategory, TypeTag, Types};
use soa::{EitherIndex, Index, Slice};
pub struct Constraints { pub struct Constraints {
pub constraints: Vec<Constraint>, pub constraints: Vec<Constraint>,
@ -205,11 +206,11 @@ impl Constraints {
} }
pub fn push_expected_type(&mut self, expected: Expected<TypeOrVar>) -> ExpectedTypeIndex { pub fn push_expected_type(&mut self, expected: Expected<TypeOrVar>) -> ExpectedTypeIndex {
Index::push_new(&mut self.expectations, expected) index_push_new(&mut self.expectations, expected)
} }
pub fn push_pat_expected_type(&mut self, expected: PExpected<TypeOrVar>) -> PExpectedTypeIndex { pub fn push_pat_expected_type(&mut self, expected: PExpected<TypeOrVar>) -> PExpectedTypeIndex {
Index::push_new(&mut self.pattern_expectations, expected) index_push_new(&mut self.pattern_expectations, expected)
} }
#[inline(always)] #[inline(always)]
@ -229,7 +230,7 @@ impl Constraints {
Category::List => Self::CATEGORY_LIST, Category::List => Self::CATEGORY_LIST,
Category::Str => Self::CATEGORY_STR, Category::Str => Self::CATEGORY_STR,
Category::Character => Self::CATEGORY_CHARACTER, Category::Character => Self::CATEGORY_CHARACTER,
other => Index::push_new(&mut self.categories, other), other => index_push_new(&mut self.categories, other),
} }
} }
@ -247,7 +248,7 @@ impl Constraints {
PatternCategory::Int => Self::PCATEGORY_INT, PatternCategory::Int => Self::PCATEGORY_INT,
PatternCategory::Float => Self::PCATEGORY_FLOAT, PatternCategory::Float => Self::PCATEGORY_FLOAT,
PatternCategory::Character => Self::PCATEGORY_CHARACTER, PatternCategory::Character => Self::PCATEGORY_CHARACTER,
other => Index::push_new(&mut self.pattern_categories, other), other => index_push_new(&mut self.pattern_categories, other),
} }
} }
@ -320,7 +321,7 @@ impl Constraints {
category: PatternCategory, category: PatternCategory,
region: Region, region: Region,
) -> Constraint { ) -> Constraint {
let category_index = Index::push_new(&mut self.pattern_categories, category); let category_index = index_push_new(&mut self.pattern_categories, category);
Constraint::PatternPresence(type_index, expected_index, category_index, region) Constraint::PatternPresence(type_index, expected_index, category_index, region)
} }
@ -337,7 +338,7 @@ impl Constraints {
category: PatternCategory, category: PatternCategory,
region: Region, region: Region,
) -> Constraint { ) -> Constraint {
let category_index = Index::push_new(&mut self.pattern_categories, category); let category_index = index_push_new(&mut self.pattern_categories, category);
let includes_tag = IncludesTag { let includes_tag = IncludesTag {
type_index, type_index,
@ -347,7 +348,7 @@ impl Constraints {
region, region,
}; };
let includes_tag_index = Index::push_new(&mut self.includes_tags, includes_tag); let includes_tag_index = index_push_new(&mut self.includes_tags, includes_tag);
Constraint::IncludesTag(includes_tag_index) Constraint::IncludesTag(includes_tag_index)
} }
@ -614,7 +615,7 @@ impl Constraints {
filename: &'static str, filename: &'static str,
line_number: u32, line_number: u32,
) -> Constraint { ) -> Constraint {
let string_index = Index::push_new(&mut self.strings, filename); let string_index = index_push_new(&mut self.strings, filename);
Constraint::Store(type_index, variable, string_index, line_number) Constraint::Store(type_index, variable, string_index, line_number)
} }
@ -632,19 +633,19 @@ impl Constraints {
exhaustive: ExhaustiveMark, exhaustive: ExhaustiveMark,
) -> Constraint { ) -> Constraint {
let real_var = Self::push_type_variable(real_var); let real_var = Self::push_type_variable(real_var);
let sketched_rows = Index::push_new(&mut self.sketched_rows, sketched_rows); let sketched_rows = index_push_new(&mut self.sketched_rows, sketched_rows);
let equality = match category_and_expectation { let equality = match category_and_expectation {
Ok((category, expected)) => { Ok((category, expected)) => {
let category = Index::push_new(&mut self.categories, category); let category = index_push_new(&mut self.categories, category);
let equality = Eq(real_var, expected, category, real_region); let equality = Eq(real_var, expected, category, real_region);
let equality = Index::push_new(&mut self.eq, equality); let equality = index_push_new(&mut self.eq, equality);
Ok(equality) Ok(equality)
} }
Err((category, expected)) => { Err((category, expected)) => {
let category = Index::push_new(&mut self.pattern_categories, category); let category = index_push_new(&mut self.pattern_categories, category);
let equality = PatternEq(real_var, expected, category, real_region); let equality = PatternEq(real_var, expected, category, real_region);
let equality = Index::push_new(&mut self.pattern_eq, equality); let equality = index_push_new(&mut self.pattern_eq, equality);
Err(equality) Err(equality)
} }
}; };
@ -662,18 +663,18 @@ impl Constraints {
I: IntoIterator<Item = (Symbol, Region)>, I: IntoIterator<Item = (Symbol, Region)>,
I1: IntoIterator<Item = Region>, I1: IntoIterator<Item = Region>,
{ {
let def_names = Slice::extend_new(&mut self.loc_symbols, loc_symbols); let def_names = slice_extend_new(&mut self.loc_symbols, loc_symbols);
// we add a dummy symbol to these regions, so we can store the data in the loc_symbols vec // we add a dummy symbol to these regions, so we can store the data in the loc_symbols vec
let it = expr_regions.into_iter().map(|r| (Symbol::ATTR_ATTR, r)); let it = expr_regions.into_iter().map(|r| (Symbol::ATTR_ATTR, r));
let expr_regions = Slice::extend_new(&mut self.loc_symbols, it); let expr_regions = slice_extend_new(&mut self.loc_symbols, it);
let expr_regions = Slice::new(expr_regions.start() as _, expr_regions.len() as _); let expr_regions = Slice::new(expr_regions.start() as _, expr_regions.len() as _);
let cycle = Cycle { let cycle = Cycle {
def_names, def_names,
expr_regions, expr_regions,
}; };
let cycle_index = Index::push_new(&mut self.cycles, cycle); let cycle_index = index_push_new(&mut self.cycles, cycle);
Constraint::CheckCycle(cycle_index, cycle_mark) Constraint::CheckCycle(cycle_index, cycle_mark)
} }

View file

@ -5,6 +5,7 @@ use crate::{
}, },
pattern::{DestructType, ListPatterns, Pattern, RecordDestruct, TupleDestruct}, pattern::{DestructType, ListPatterns, Pattern, RecordDestruct, TupleDestruct},
}; };
use roc_collections::soa::{index_push_new, slice_extend_new};
use roc_module::{ use roc_module::{
ident::{Lowercase, TagName}, ident::{Lowercase, TagName},
symbol::Symbol, symbol::Symbol,
@ -12,7 +13,7 @@ use roc_module::{
use roc_types::{ use roc_types::{
subs::{ subs::{
self, AliasVariables, Descriptor, GetSubsSlice, OptVariable, RecordFields, Subs, SubsIndex, self, AliasVariables, Descriptor, GetSubsSlice, OptVariable, RecordFields, Subs, SubsIndex,
SubsSlice, TupleElems, UnionLambdas, UnionTags, Variable, VariableSubsSlice, SubsSlice, TupleElems, UnionLambdas, UnionTags, Variable,
}, },
types::{RecordField, Uls}, types::{RecordField, Uls},
}; };
@ -155,12 +156,12 @@ impl<'a> CopyEnv for AcrossSubs<'a> {
#[inline(always)] #[inline(always)]
fn clone_name(&mut self, name: SubsIndex<Lowercase>) -> SubsIndex<Lowercase> { fn clone_name(&mut self, name: SubsIndex<Lowercase>) -> SubsIndex<Lowercase> {
SubsIndex::push_new(&mut self.target.field_names, self.source[name].clone()) index_push_new(&mut self.target.field_names, self.source[name].clone())
} }
#[inline(always)] #[inline(always)]
fn clone_field_names(&mut self, field_names: SubsSlice<Lowercase>) -> SubsSlice<Lowercase> { fn clone_field_names(&mut self, field_names: SubsSlice<Lowercase>) -> SubsSlice<Lowercase> {
SubsSlice::extend_new( slice_extend_new(
&mut self.target.field_names, &mut self.target.field_names,
self.source.get_subs_slice(field_names).iter().cloned(), self.source.get_subs_slice(field_names).iter().cloned(),
) )
@ -171,7 +172,7 @@ impl<'a> CopyEnv for AcrossSubs<'a> {
&mut self, &mut self,
tuple_elem_indices: SubsSlice<usize>, tuple_elem_indices: SubsSlice<usize>,
) -> SubsSlice<usize> { ) -> SubsSlice<usize> {
SubsSlice::extend_new( slice_extend_new(
&mut self.target.tuple_elem_indices, &mut self.target.tuple_elem_indices,
self.source self.source
.get_subs_slice(tuple_elem_indices) .get_subs_slice(tuple_elem_indices)
@ -182,7 +183,7 @@ impl<'a> CopyEnv for AcrossSubs<'a> {
#[inline(always)] #[inline(always)]
fn clone_tag_names(&mut self, tag_names: SubsSlice<TagName>) -> SubsSlice<TagName> { fn clone_tag_names(&mut self, tag_names: SubsSlice<TagName>) -> SubsSlice<TagName> {
SubsSlice::extend_new( slice_extend_new(
&mut self.target.tag_names, &mut self.target.tag_names,
self.source.get_subs_slice(tag_names).iter().cloned(), self.source.get_subs_slice(tag_names).iter().cloned(),
) )
@ -190,7 +191,7 @@ impl<'a> CopyEnv for AcrossSubs<'a> {
#[inline(always)] #[inline(always)]
fn clone_lambda_names(&mut self, lambda_names: SubsSlice<Symbol>) -> SubsSlice<Symbol> { fn clone_lambda_names(&mut self, lambda_names: SubsSlice<Symbol>) -> SubsSlice<Symbol> {
SubsSlice::extend_new( slice_extend_new(
&mut self.target.symbol_names, &mut self.target.symbol_names,
self.source.get_subs_slice(lambda_names).iter().cloned(), self.source.get_subs_slice(lambda_names).iter().cloned(),
) )
@ -201,7 +202,7 @@ impl<'a> CopyEnv for AcrossSubs<'a> {
&mut self, &mut self,
record_fields: SubsSlice<RecordField<()>>, record_fields: SubsSlice<RecordField<()>>,
) -> SubsSlice<RecordField<()>> { ) -> SubsSlice<RecordField<()>> {
SubsSlice::extend_new( slice_extend_new(
&mut self.target.record_fields, &mut self.target.record_fields,
self.source.get_subs_slice(record_fields).iter().copied(), self.source.get_subs_slice(record_fields).iter().copied(),
) )
@ -919,8 +920,7 @@ fn deep_copy_type_vars<C: CopyEnv>(
macro_rules! clone_var_slice { macro_rules! clone_var_slice {
($slice:expr) => {{ ($slice:expr) => {{
let new_arguments = let new_arguments = env.target().reserve_into_vars($slice.len());
VariableSubsSlice::reserve_into_subs(env.target(), $slice.len());
for (target_index, var_index) in (new_arguments.indices()).zip($slice) { for (target_index, var_index) in (new_arguments.indices()).zip($slice) {
let var = env.source()[var_index]; let var = env.source()[var_index];
let copy_var = env.get_copy(var).into_variable().unwrap_or(var); let copy_var = env.get_copy(var).into_variable().unwrap_or(var);
@ -994,9 +994,9 @@ fn deep_copy_type_vars<C: CopyEnv>(
let new_fields = { let new_fields = {
RecordFields { RecordFields {
length: fields.length, length: fields.length,
field_names_start: new_field_names.start, field_names_start: new_field_names.start(),
variables_start: new_variables.start, variables_start: new_variables.start(),
field_types_start: new_record_fields.start, field_types_start: new_record_fields.start(),
} }
}; };
@ -1015,8 +1015,8 @@ fn deep_copy_type_vars<C: CopyEnv>(
let new_elems = { let new_elems = {
TupleElems { TupleElems {
length: elems.length, length: elems.length,
variables_start: new_variables.start, variables_start: new_variables.start(),
elem_index_start: new_elem_indices.start, elem_index_start: new_elem_indices.start(),
} }
}; };
@ -1032,8 +1032,7 @@ fn deep_copy_type_vars<C: CopyEnv>(
} }
perform_clone!({ perform_clone!({
let new_variable_slices = let new_variable_slices = env.target().reserve_variable_slices(tags.len());
SubsSlice::reserve_variable_slices(env.target(), tags.len());
let it = (new_variable_slices.indices()).zip(tags.variables()); let it = (new_variable_slices.indices()).zip(tags.variables());
for (target_index, index) in it { for (target_index, index) in it {
let slice = env.source()[index]; let slice = env.source()[index];
@ -1058,8 +1057,7 @@ fn deep_copy_type_vars<C: CopyEnv>(
} }
perform_clone!({ perform_clone!({
let new_variable_slices = let new_variable_slices = env.target().reserve_variable_slices(tags.len());
SubsSlice::reserve_variable_slices(env.target(), tags.len());
let it = (new_variable_slices.indices()).zip(tags.variables()); let it = (new_variable_slices.indices()).zip(tags.variables());
for (target_index, index) in it { for (target_index, index) in it {
let slice = env.source()[index]; let slice = env.source()[index];
@ -1109,7 +1107,7 @@ fn deep_copy_type_vars<C: CopyEnv>(
perform_clone!({ perform_clone!({
let new_variables = clone_var_slice!(arguments.all_variables()); let new_variables = clone_var_slice!(arguments.all_variables());
let new_arguments = AliasVariables { let new_arguments = AliasVariables {
variables_start: new_variables.start, variables_start: new_variables.start(),
..arguments ..arguments
}; };
@ -1135,8 +1133,7 @@ fn deep_copy_type_vars<C: CopyEnv>(
let new_ambient_function = descend_var!(ambient_function); let new_ambient_function = descend_var!(ambient_function);
perform_clone!({ perform_clone!({
let new_variable_slices = let new_variable_slices = env.target().reserve_variable_slices(solved.len());
SubsSlice::reserve_variable_slices(env.target(), solved.len());
let it = (new_variable_slices.indices()).zip(solved.variables()); let it = (new_variable_slices.indices()).zip(solved.variables());
for (target_index, index) in it { for (target_index, index) in it {
let slice = env.source()[index]; let slice = env.source()[index];
@ -1150,8 +1147,7 @@ fn deep_copy_type_vars<C: CopyEnv>(
let new_solved = let new_solved =
UnionLambdas::from_slices(new_solved_labels, new_variable_slices); UnionLambdas::from_slices(new_solved_labels, new_variable_slices);
let new_unspecialized = let new_unspecialized = env.target().reserve_uls_slice(unspecialized.len());
SubsSlice::reserve_uls_slice(env.target(), unspecialized.len());
for (target_index, uls_index) in for (target_index, uls_index) in
(new_unspecialized.into_iter()).zip(unspecialized.into_iter()) (new_unspecialized.into_iter()).zip(unspecialized.into_iter())
{ {
@ -1192,13 +1188,14 @@ mod test {
}; };
use super::{deep_copy_expr_across_subs, deep_copy_type_vars}; use super::{deep_copy_expr_across_subs, deep_copy_type_vars};
use roc_collections::soa::{index_push_new, slice_extend_new};
use roc_error_macros::internal_error; use roc_error_macros::internal_error;
use roc_module::{ident::TagName, symbol::Symbol}; use roc_module::{ident::TagName, symbol::Symbol};
use roc_region::all::Loc; use roc_region::all::Loc;
use roc_types::{ use roc_types::{
subs::{ subs::{
self, Content, Content::*, Descriptor, FlatType, GetSubsSlice, Mark, OptVariable, Rank, self, Content, Content::*, Descriptor, FlatType, GetSubsSlice, Mark, OptVariable, Rank,
Subs, SubsIndex, SubsSlice, Variable, Subs, Variable,
}, },
types::Uls, types::Uls,
}; };
@ -1217,7 +1214,7 @@ mod test {
fn copy_flex_var() { fn copy_flex_var() {
let mut subs = Subs::new(); let mut subs = Subs::new();
let field_name = SubsIndex::push_new(&mut subs.field_names, "a".into()); let field_name = index_push_new(&mut subs.field_names, "a".into());
let var = new_var(&mut subs, FlexVar(Some(field_name))); let var = new_var(&mut subs, FlexVar(Some(field_name)));
let mut copied = vec![]; let mut copied = vec![];
@ -1238,7 +1235,7 @@ mod test {
fn copy_rigid_var() { fn copy_rigid_var() {
let mut subs = Subs::new(); let mut subs = Subs::new();
let field_name = SubsIndex::push_new(&mut subs.field_names, "a".into()); let field_name = index_push_new(&mut subs.field_names, "a".into());
let var = new_var(&mut subs, RigidVar(field_name)); let var = new_var(&mut subs, RigidVar(field_name));
let mut copied = vec![]; let mut copied = vec![];
@ -1259,8 +1256,8 @@ mod test {
fn copy_flex_able_var() { fn copy_flex_able_var() {
let mut subs = Subs::new(); let mut subs = Subs::new();
let field_name = SubsIndex::push_new(&mut subs.field_names, "a".into()); let field_name = index_push_new(&mut subs.field_names, "a".into());
let abilities = SubsSlice::extend_new(&mut subs.symbol_names, [Symbol::UNDERSCORE]); let abilities = slice_extend_new(&mut subs.symbol_names, [Symbol::UNDERSCORE]);
let var = new_var(&mut subs, FlexAbleVar(Some(field_name), abilities)); let var = new_var(&mut subs, FlexAbleVar(Some(field_name), abilities));
let mut copied = vec![]; let mut copied = vec![];
@ -1282,8 +1279,8 @@ mod test {
fn copy_rigid_able_var() { fn copy_rigid_able_var() {
let mut subs = Subs::new(); let mut subs = Subs::new();
let field_name = SubsIndex::push_new(&mut subs.field_names, "a".into()); let field_name = index_push_new(&mut subs.field_names, "a".into());
let abilities = SubsSlice::extend_new(&mut subs.symbol_names, [Symbol::UNDERSCORE]); let abilities = slice_extend_new(&mut subs.symbol_names, [Symbol::UNDERSCORE]);
let var = new_var(&mut subs, RigidAbleVar(field_name, abilities)); let var = new_var(&mut subs, RigidAbleVar(field_name, abilities));
let mut copied = vec![]; let mut copied = vec![];
@ -1304,8 +1301,8 @@ mod test {
fn copy_deep_expr() { fn copy_deep_expr() {
let mut subs = Subs::new(); let mut subs = Subs::new();
let a = SubsIndex::push_new(&mut subs.field_names, "a".into()); let a = index_push_new(&mut subs.field_names, "a".into());
let b = SubsIndex::push_new(&mut subs.field_names, "b".into()); let b = index_push_new(&mut subs.field_names, "b".into());
let var1 = new_var(&mut subs, FlexVar(Some(a))); let var1 = new_var(&mut subs, FlexVar(Some(a)));
let var2 = new_var(&mut subs, FlexVar(Some(b))); let var2 = new_var(&mut subs, FlexVar(Some(b)));
@ -1390,8 +1387,8 @@ mod test {
let mut source = Subs::new(); let mut source = Subs::new();
let mut target = Subs::new(); let mut target = Subs::new();
let a = SubsIndex::push_new(&mut source.field_names, "a".into()); let a = index_push_new(&mut source.field_names, "a".into());
let b = SubsIndex::push_new(&mut source.field_names, "b".into()); let b = index_push_new(&mut source.field_names, "b".into());
let var1 = new_var(&mut source, FlexVar(Some(a))); let var1 = new_var(&mut source, FlexVar(Some(a)));
let var2 = new_var(&mut source, FlexVar(Some(b))); let var2 = new_var(&mut source, FlexVar(Some(b)));
@ -1472,7 +1469,7 @@ mod test {
let mut target = Subs::new(); let mut target = Subs::new();
let a = new_var(&mut source, FlexVar(None)); let a = new_var(&mut source, FlexVar(None));
let uls = SubsSlice::extend_new( let uls = slice_extend_new(
&mut source.unspecialized_lambda_sets, &mut source.unspecialized_lambda_sets,
vec![Uls(a, Symbol::UNDERSCORE, 3)], vec![Uls(a, Symbol::UNDERSCORE, 3)],
); );

View file

@ -1045,20 +1045,6 @@ fn desugar_str_segments<'a>(
StrSegment::Plaintext(_) | StrSegment::Unicode(_) | StrSegment::EscapedChar(_) => { StrSegment::Plaintext(_) | StrSegment::Unicode(_) | StrSegment::EscapedChar(_) => {
*segment *segment
} }
StrSegment::DeprecatedInterpolated(loc_expr) => {
let loc_desugared = desugar_expr(
env,
scope,
env.arena.alloc(Loc {
region: loc_expr.region,
value: *loc_expr.value,
}),
);
StrSegment::DeprecatedInterpolated(Loc {
region: loc_desugared.region,
value: env.arena.alloc(loc_desugared.value),
})
}
StrSegment::Interpolated(loc_expr) => { StrSegment::Interpolated(loc_expr) => {
let loc_desugared = desugar_expr( let loc_desugared = desugar_expr(
env, env,

View file

@ -12,7 +12,7 @@ use crate::pattern::{canonicalize_pattern, BindingsFromPattern, Pattern, PermitS
use crate::procedure::{QualifiedReference, References}; use crate::procedure::{QualifiedReference, References};
use crate::scope::{Scope, SymbolLookup}; use crate::scope::{Scope, SymbolLookup};
use crate::traverse::{walk_expr, Visitor}; use crate::traverse::{walk_expr, Visitor};
use roc_collections::soa::Index; use roc_collections::soa::index_push_new;
use roc_collections::{SendMap, VecMap, VecSet}; use roc_collections::{SendMap, VecMap, VecSet};
use roc_error_macros::internal_error; use roc_error_macros::internal_error;
use roc_module::called_via::CalledVia; use roc_module::called_via::CalledVia;
@ -27,6 +27,7 @@ use roc_region::all::{Loc, Region};
use roc_types::num::SingleQuoteBound; use roc_types::num::SingleQuoteBound;
use roc_types::subs::{ExhaustiveMark, IllegalCycleMark, RedundantMark, VarStore, Variable}; use roc_types::subs::{ExhaustiveMark, IllegalCycleMark, RedundantMark, VarStore, Variable};
use roc_types::types::{Alias, Category, IndexOrField, LambdaSet, OptAbleVar, Type}; use roc_types::types::{Alias, Category, IndexOrField, LambdaSet, OptAbleVar, Type};
use soa::Index;
use std::fmt::{Debug, Display}; use std::fmt::{Debug, Display};
use std::path::PathBuf; use std::path::PathBuf;
use std::sync::Arc; use std::sync::Arc;
@ -2515,9 +2516,7 @@ pub fn is_valid_interpolation(expr: &ast::Expr<'_>) -> bool {
| ast::StrSegment::Plaintext(_) => true, | ast::StrSegment::Plaintext(_) => true,
// Disallow nested interpolation. Alternatively, we could allow it but require // Disallow nested interpolation. Alternatively, we could allow it but require
// a comment above it apologizing to the next person who has to read the code. // a comment above it apologizing to the next person who has to read the code.
ast::StrSegment::Interpolated(_) | ast::StrSegment::DeprecatedInterpolated(_) => { ast::StrSegment::Interpolated(_) => false,
false
}
}) })
} }
ast::Expr::Record(fields) => fields.iter().all(|loc_field| match loc_field.value { ast::Expr::Record(fields) => fields.iter().all(|loc_field| match loc_field.value {
@ -2648,7 +2647,7 @@ fn flatten_str_lines<'a>(
); );
} }
}, },
Interpolated(loc_expr) | DeprecatedInterpolated(loc_expr) => { Interpolated(loc_expr) => {
if is_valid_interpolation(loc_expr.value) { if is_valid_interpolation(loc_expr.value) {
// Interpolations desugar to Str.concat calls // Interpolations desugar to Str.concat calls
output.references.insert_call(Symbol::STR_CONCAT); output.references.insert_call(Symbol::STR_CONCAT);
@ -2852,7 +2851,7 @@ impl Declarations {
let loc_function_def = Loc::at(loc_closure_data.region, function_def); let loc_function_def = Loc::at(loc_closure_data.region, function_def);
let function_def_index = Index::push_new(&mut self.function_bodies, loc_function_def); let function_def_index = index_push_new(&mut self.function_bodies, loc_function_def);
let tag = match loc_closure_data.value.recursive { let tag = match loc_closure_data.value.recursive {
Recursive::NotRecursive | Recursive::Recursive => { Recursive::NotRecursive | Recursive::Recursive => {
@ -2903,7 +2902,7 @@ impl Declarations {
let loc_function_def = Loc::at(loc_closure_data.region, function_def); let loc_function_def = Loc::at(loc_closure_data.region, function_def);
let function_def_index = Index::push_new(&mut self.function_bodies, loc_function_def); let function_def_index = index_push_new(&mut self.function_bodies, loc_function_def);
if let Some(annotation) = host_annotation { if let Some(annotation) = host_annotation {
self.host_exposed_annotations self.host_exposed_annotations
@ -3009,7 +3008,7 @@ impl Declarations {
pattern_vars, pattern_vars,
}; };
let destructure_def_index = Index::push_new(&mut self.destructs, destruct_def); let destructure_def_index = index_push_new(&mut self.destructs, destruct_def);
self.declarations self.declarations
.push(DeclarationTag::Destructure(destructure_def_index)); .push(DeclarationTag::Destructure(destructure_def_index));
@ -3081,7 +3080,7 @@ impl Declarations {
let loc_function_def = Loc::at(def.loc_expr.region, function_def); let loc_function_def = Loc::at(def.loc_expr.region, function_def);
let function_def_index = let function_def_index =
Index::push_new(&mut self.function_bodies, loc_function_def); index_push_new(&mut self.function_bodies, loc_function_def);
self.declarations[index] = DeclarationTag::Function(function_def_index); self.declarations[index] = DeclarationTag::Function(function_def_index);
self.expressions[index] = *closure_data.loc_body; self.expressions[index] = *closure_data.loc_body;
@ -3133,7 +3132,7 @@ impl Declarations {
let loc_function_def = Loc::at(region, function_def); let loc_function_def = Loc::at(region, function_def);
let function_def_index = let function_def_index =
Index::push_new(&mut self.function_bodies, loc_function_def); index_push_new(&mut self.function_bodies, loc_function_def);
if let Some(annotation) = &mut self.annotations[index] { if let Some(annotation) = &mut self.annotations[index] {
annotation.convert_to_fn(new_args_len, var_store); annotation.convert_to_fn(new_args_len, var_store);

View file

@ -1109,7 +1109,7 @@ fn flatten_str_lines(lines: &[&[StrSegment<'_>]]) -> Pattern {
Unicode(loc_digits) => { Unicode(loc_digits) => {
todo!("parse unicode digits {:?}", loc_digits); todo!("parse unicode digits {:?}", loc_digits);
} }
Interpolated(loc_expr) | DeprecatedInterpolated(loc_expr) => { Interpolated(loc_expr) => {
return Pattern::UnsupportedPattern(loc_expr.region); return Pattern::UnsupportedPattern(loc_expr.region);
} }
EscapedChar(escaped) => buf.push(escaped.unescape()), EscapedChar(escaped) => buf.push(escaped.unescape()),

View file

@ -4,16 +4,16 @@ expression: snapshot
--- ---
Defs { Defs {
tags: [ tags: [
Index(2147483648), EitherIndex(2147483648),
], ],
regions: [ regions: [
@0-28, @0-28,
], ],
space_before: [ space_before: [
Slice(start = 0, length = 0), Slice { start: 0, length: 0 },
], ],
space_after: [ space_after: [
Slice(start = 0, length = 1), Slice { start: 0, length: 1 },
], ],
spaces: [ spaces: [
Newline, Newline,
@ -59,16 +59,16 @@ Defs {
@15-22 Defs( @15-22 Defs(
Defs { Defs {
tags: [ tags: [
Index(2147483648), EitherIndex(2147483648),
], ],
regions: [ regions: [
@15-22, @15-22,
], ],
space_before: [ space_before: [
Slice(start = 0, length = 0), Slice { start: 0, length: 0 },
], ],
space_after: [ space_after: [
Slice(start = 0, length = 0), Slice { start: 0, length: 0 },
], ],
spaces: [], spaces: [],
type_defs: [], type_defs: [],

View file

@ -4,16 +4,16 @@ expression: snapshot
--- ---
Defs { Defs {
tags: [ tags: [
Index(2147483648), EitherIndex(2147483648),
], ],
regions: [ regions: [
@0-25, @0-25,
], ],
space_before: [ space_before: [
Slice(start = 0, length = 0), Slice { start: 0, length: 0 },
], ],
space_after: [ space_after: [
Slice(start = 0, length = 1), Slice { start: 0, length: 1 },
], ],
spaces: [ spaces: [
Newline, Newline,
@ -43,16 +43,16 @@ Defs {
@15-19 Defs( @15-19 Defs(
Defs { Defs {
tags: [ tags: [
Index(2147483648), EitherIndex(2147483648),
], ],
regions: [ regions: [
@15-19, @15-19,
], ],
space_before: [ space_before: [
Slice(start = 0, length = 0), Slice { start: 0, length: 0 },
], ],
space_after: [ space_after: [
Slice(start = 0, length = 0), Slice { start: 0, length: 0 },
], ],
spaces: [], spaces: [],
type_defs: [], type_defs: [],

View file

@ -4,16 +4,16 @@ expression: snapshot
--- ---
Defs { Defs {
tags: [ tags: [
Index(2147483648), EitherIndex(2147483648),
], ],
regions: [ regions: [
@0-43, @0-43,
], ],
space_before: [ space_before: [
Slice(start = 0, length = 0), Slice { start: 0, length: 0 },
], ],
space_after: [ space_after: [
Slice(start = 0, length = 1), Slice { start: 0, length: 1 },
], ],
spaces: [ spaces: [
Newline, Newline,
@ -53,16 +53,16 @@ Defs {
@15-33 Defs( @15-33 Defs(
Defs { Defs {
tags: [ tags: [
Index(2147483648), EitherIndex(2147483648),
], ],
regions: [ regions: [
@15-33, @15-33,
], ],
space_before: [ space_before: [
Slice(start = 0, length = 0), Slice { start: 0, length: 0 },
], ],
space_after: [ space_after: [
Slice(start = 0, length = 0), Slice { start: 0, length: 0 },
], ],
spaces: [], spaces: [],
type_defs: [], type_defs: [],

View file

@ -4,16 +4,16 @@ expression: snapshot
--- ---
Defs { Defs {
tags: [ tags: [
Index(2147483648), EitherIndex(2147483648),
], ],
regions: [ regions: [
@0-45, @0-45,
], ],
space_before: [ space_before: [
Slice(start = 0, length = 0), Slice { start: 0, length: 0 },
], ],
space_after: [ space_after: [
Slice(start = 0, length = 1), Slice { start: 0, length: 1 },
], ],
spaces: [ spaces: [
Newline, Newline,
@ -53,16 +53,16 @@ Defs {
@15-35 Defs( @15-35 Defs(
Defs { Defs {
tags: [ tags: [
Index(2147483648), EitherIndex(2147483648),
], ],
regions: [ regions: [
@15-35, @15-35,
], ],
space_before: [ space_before: [
Slice(start = 0, length = 0), Slice { start: 0, length: 0 },
], ],
space_after: [ space_after: [
Slice(start = 0, length = 0), Slice { start: 0, length: 0 },
], ],
spaces: [], spaces: [],
type_defs: [], type_defs: [],

View file

@ -4,16 +4,16 @@ expression: snapshot
--- ---
Defs { Defs {
tags: [ tags: [
Index(2147483648), EitherIndex(2147483648),
], ],
regions: [ regions: [
@0-28, @0-28,
], ],
space_before: [ space_before: [
Slice(start = 0, length = 0), Slice { start: 0, length: 0 },
], ],
space_after: [ space_after: [
Slice(start = 0, length = 1), Slice { start: 0, length: 1 },
], ],
spaces: [ spaces: [
Newline, Newline,
@ -43,16 +43,16 @@ Defs {
@15-22 Defs( @15-22 Defs(
Defs { Defs {
tags: [ tags: [
Index(2147483648), EitherIndex(2147483648),
], ],
regions: [ regions: [
@15-22, @15-22,
], ],
space_before: [ space_before: [
Slice(start = 0, length = 0), Slice { start: 0, length: 0 },
], ],
space_after: [ space_after: [
Slice(start = 0, length = 0), Slice { start: 0, length: 0 },
], ],
spaces: [], spaces: [],
type_defs: [], type_defs: [],

View file

@ -4,16 +4,16 @@ expression: snapshot
--- ---
Defs { Defs {
tags: [ tags: [
Index(2147483648), EitherIndex(2147483648),
], ],
regions: [ regions: [
@0-26, @0-26,
], ],
space_before: [ space_before: [
Slice(start = 0, length = 0), Slice { start: 0, length: 0 },
], ],
space_after: [ space_after: [
Slice(start = 0, length = 1), Slice { start: 0, length: 1 },
], ],
spaces: [ spaces: [
Newline, Newline,
@ -33,16 +33,16 @@ Defs {
@11-15 Defs( @11-15 Defs(
Defs { Defs {
tags: [ tags: [
Index(2147483648), EitherIndex(2147483648),
], ],
regions: [ regions: [
@11-15, @11-15,
], ],
space_before: [ space_before: [
Slice(start = 0, length = 0), Slice { start: 0, length: 0 },
], ],
space_after: [ space_after: [
Slice(start = 0, length = 0), Slice { start: 0, length: 0 },
], ],
spaces: [], spaces: [],
type_defs: [], type_defs: [],

View file

@ -4,16 +4,16 @@ expression: snapshot
--- ---
Defs { Defs {
tags: [ tags: [
Index(2147483648), EitherIndex(2147483648),
], ],
regions: [ regions: [
@0-42, @0-42,
], ],
space_before: [ space_before: [
Slice(start = 0, length = 0), Slice { start: 0, length: 0 },
], ],
space_after: [ space_after: [
Slice(start = 0, length = 1), Slice { start: 0, length: 1 },
], ],
spaces: [ spaces: [
Newline, Newline,
@ -43,16 +43,16 @@ Defs {
@16-35 Defs( @16-35 Defs(
Defs { Defs {
tags: [ tags: [
Index(2147483648), EitherIndex(2147483648),
], ],
regions: [ regions: [
@16-35, @16-35,
], ],
space_before: [ space_before: [
Slice(start = 0, length = 0), Slice { start: 0, length: 0 },
], ],
space_after: [ space_after: [
Slice(start = 0, length = 0), Slice { start: 0, length: 0 },
], ],
spaces: [], spaces: [],
type_defs: [], type_defs: [],

View file

@ -4,16 +4,16 @@ expression: snapshot
--- ---
Defs { Defs {
tags: [ tags: [
Index(2147483648), EitherIndex(2147483648),
], ],
regions: [ regions: [
@0-69, @0-69,
], ],
space_before: [ space_before: [
Slice(start = 0, length = 0), Slice { start: 0, length: 0 },
], ],
space_after: [ space_after: [
Slice(start = 0, length = 1), Slice { start: 0, length: 1 },
], ],
spaces: [ spaces: [
Newline, Newline,
@ -27,16 +27,16 @@ Defs {
@11-69 Defs( @11-69 Defs(
Defs { Defs {
tags: [ tags: [
Index(2147483648), EitherIndex(2147483648),
], ],
regions: [ regions: [
@15-57, @15-57,
], ],
space_before: [ space_before: [
Slice(start = 0, length = 0), Slice { start: 0, length: 0 },
], ],
space_after: [ space_after: [
Slice(start = 0, length = 0), Slice { start: 0, length: 0 },
], ],
spaces: [], spaces: [],
type_defs: [], type_defs: [],
@ -60,16 +60,16 @@ Defs {
@31-42 Defs( @31-42 Defs(
Defs { Defs {
tags: [ tags: [
Index(2147483648), EitherIndex(2147483648),
], ],
regions: [ regions: [
@31-42, @31-42,
], ],
space_before: [ space_before: [
Slice(start = 0, length = 0), Slice { start: 0, length: 0 },
], ],
space_after: [ space_after: [
Slice(start = 0, length = 0), Slice { start: 0, length: 0 },
], ],
spaces: [], spaces: [],
type_defs: [], type_defs: [],

View file

@ -4,16 +4,16 @@ expression: snapshot
--- ---
Defs { Defs {
tags: [ tags: [
Index(2147483648), EitherIndex(2147483648),
], ],
regions: [ regions: [
@0-114, @0-114,
], ],
space_before: [ space_before: [
Slice(start = 0, length = 0), Slice { start: 0, length: 0 },
], ],
space_after: [ space_after: [
Slice(start = 0, length = 1), Slice { start: 0, length: 1 },
], ],
spaces: [ spaces: [
Newline, Newline,
@ -27,16 +27,16 @@ Defs {
@11-114 Defs( @11-114 Defs(
Defs { Defs {
tags: [ tags: [
Index(2147483648), EitherIndex(2147483648),
], ],
regions: [ regions: [
@39-101, @39-101,
], ],
space_before: [ space_before: [
Slice(start = 0, length = 0), Slice { start: 0, length: 0 },
], ],
space_after: [ space_after: [
Slice(start = 0, length = 0), Slice { start: 0, length: 0 },
], ],
spaces: [], spaces: [],
type_defs: [], type_defs: [],
@ -77,16 +77,16 @@ Defs {
@56-91 Defs( @56-91 Defs(
Defs { Defs {
tags: [ tags: [
Index(2147483648), EitherIndex(2147483648),
], ],
regions: [ regions: [
@82-91, @82-91,
], ],
space_before: [ space_before: [
Slice(start = 0, length = 0), Slice { start: 0, length: 0 },
], ],
space_after: [ space_after: [
Slice(start = 0, length = 0), Slice { start: 0, length: 0 },
], ],
spaces: [], spaces: [],
type_defs: [], type_defs: [],

View file

@ -4,16 +4,16 @@ expression: snapshot
--- ---
Defs { Defs {
tags: [ tags: [
Index(2147483648), EitherIndex(2147483648),
], ],
regions: [ regions: [
@0-143, @0-143,
], ],
space_before: [ space_before: [
Slice(start = 0, length = 0), Slice { start: 0, length: 0 },
], ],
space_after: [ space_after: [
Slice(start = 0, length = 1), Slice { start: 0, length: 1 },
], ],
spaces: [ spaces: [
Newline, Newline,
@ -27,16 +27,16 @@ Defs {
@12-143 Defs( @12-143 Defs(
Defs { Defs {
tags: [ tags: [
Index(2147483648), EitherIndex(2147483648),
], ],
regions: [ regions: [
@56-119, @56-119,
], ],
space_before: [ space_before: [
Slice(start = 0, length = 0), Slice { start: 0, length: 0 },
], ],
space_after: [ space_after: [
Slice(start = 0, length = 0), Slice { start: 0, length: 0 },
], ],
spaces: [], spaces: [],
type_defs: [], type_defs: [],
@ -105,16 +105,16 @@ Defs {
@76-83 Defs( @76-83 Defs(
Defs { Defs {
tags: [ tags: [
Index(2147483648), EitherIndex(2147483648),
], ],
regions: [ regions: [
@76-83, @76-83,
], ],
space_before: [ space_before: [
Slice(start = 0, length = 0), Slice { start: 0, length: 0 },
], ],
space_after: [ space_after: [
Slice(start = 0, length = 0), Slice { start: 0, length: 0 },
], ],
spaces: [], spaces: [],
type_defs: [], type_defs: [],
@ -174,16 +174,16 @@ Defs {
@92-99 Defs( @92-99 Defs(
Defs { Defs {
tags: [ tags: [
Index(2147483648), EitherIndex(2147483648),
], ],
regions: [ regions: [
@92-99, @92-99,
], ],
space_before: [ space_before: [
Slice(start = 0, length = 0), Slice { start: 0, length: 0 },
], ],
space_after: [ space_after: [
Slice(start = 0, length = 0), Slice { start: 0, length: 0 },
], ],
spaces: [], spaces: [],
type_defs: [], type_defs: [],

View file

@ -1,20 +1,19 @@
--- ---
source: crates/compiler/can/tests/test_suffixed.rs source: crates/compiler/can/tests/test_suffixed.rs
assertion_line: 463
expression: snapshot expression: snapshot
--- ---
Defs { Defs {
tags: [ tags: [
Index(2147483648), EitherIndex(2147483648),
], ],
regions: [ regions: [
@0-26, @0-26,
], ],
space_before: [ space_before: [
Slice(start = 0, length = 0), Slice { start: 0, length: 0 },
], ],
space_after: [ space_after: [
Slice(start = 0, length = 1), Slice { start: 0, length: 1 },
], ],
spaces: [ spaces: [
Newline, Newline,
@ -28,16 +27,16 @@ Defs {
@11-26 Defs( @11-26 Defs(
Defs { Defs {
tags: [ tags: [
Index(2147483648), EitherIndex(2147483648),
], ],
regions: [ regions: [
@15-26, @15-26,
], ],
space_before: [ space_before: [
Slice(start = 0, length = 0), Slice { start: 0, length: 0 },
], ],
space_after: [ space_after: [
Slice(start = 0, length = 0), Slice { start: 0, length: 0 },
], ],
spaces: [], spaces: [],
type_defs: [], type_defs: [],
@ -50,16 +49,16 @@ Defs {
Defs( Defs(
Defs { Defs {
tags: [ tags: [
Index(2147483648), EitherIndex(2147483648),
], ],
regions: [ regions: [
@20-25, @20-25,
], ],
space_before: [ space_before: [
Slice(start = 0, length = 0), Slice { start: 0, length: 0 },
], ],
space_after: [ space_after: [
Slice(start = 0, length = 0), Slice { start: 0, length: 0 },
], ],
spaces: [], spaces: [],
type_defs: [], type_defs: [],

View file

@ -4,16 +4,16 @@ expression: snapshot
--- ---
Defs { Defs {
tags: [ tags: [
Index(2147483648), EitherIndex(2147483648),
], ],
regions: [ regions: [
@0-49, @0-49,
], ],
space_before: [ space_before: [
Slice(start = 0, length = 0), Slice { start: 0, length: 0 },
], ],
space_after: [ space_after: [
Slice(start = 0, length = 1), Slice { start: 0, length: 1 },
], ],
spaces: [ spaces: [
Newline, Newline,

View file

@ -4,16 +4,16 @@ expression: snapshot
--- ---
Defs { Defs {
tags: [ tags: [
Index(2147483648), EitherIndex(2147483648),
], ],
regions: [ regions: [
@0-24, @0-24,
], ],
space_before: [ space_before: [
Slice(start = 0, length = 0), Slice { start: 0, length: 0 },
], ],
space_after: [ space_after: [
Slice(start = 0, length = 1), Slice { start: 0, length: 1 },
], ],
spaces: [ spaces: [
Newline, Newline,

View file

@ -4,16 +4,16 @@ expression: snapshot
--- ---
Defs { Defs {
tags: [ tags: [
Index(2147483648), EitherIndex(2147483648),
], ],
regions: [ regions: [
@0-99, @0-99,
], ],
space_before: [ space_before: [
Slice(start = 0, length = 0), Slice { start: 0, length: 0 },
], ],
space_after: [ space_after: [
Slice(start = 0, length = 1), Slice { start: 0, length: 1 },
], ],
spaces: [ spaces: [
Newline, Newline,

View file

@ -4,20 +4,20 @@ expression: snapshot
--- ---
Defs { Defs {
tags: [ tags: [
Index(2147483648), EitherIndex(2147483648),
Index(2147483649), EitherIndex(2147483649),
], ],
regions: [ regions: [
@0-54, @0-54,
@56-98, @56-98,
], ],
space_before: [ space_before: [
Slice(start = 0, length = 0), Slice { start: 0, length: 0 },
Slice(start = 0, length = 2), Slice { start: 0, length: 2 },
], ],
space_after: [ space_after: [
Slice(start = 0, length = 0), Slice { start: 0, length: 0 },
Slice(start = 2, length = 1), Slice { start: 2, length: 1 },
], ],
spaces: [ spaces: [
Newline, Newline,
@ -33,16 +33,16 @@ Defs {
@11-54 Defs( @11-54 Defs(
Defs { Defs {
tags: [ tags: [
Index(2147483648), EitherIndex(2147483648),
], ],
regions: [ regions: [
@15-20, @15-20,
], ],
space_before: [ space_before: [
Slice(start = 0, length = 0), Slice { start: 0, length: 0 },
], ],
space_after: [ space_after: [
Slice(start = 0, length = 0), Slice { start: 0, length: 0 },
], ],
spaces: [], spaces: [],
type_defs: [], type_defs: [],
@ -68,16 +68,16 @@ Defs {
@25-39 Defs( @25-39 Defs(
Defs { Defs {
tags: [ tags: [
Index(2147483648), EitherIndex(2147483648),
], ],
regions: [ regions: [
@25-39, @25-39,
], ],
space_before: [ space_before: [
Slice(start = 0, length = 0), Slice { start: 0, length: 0 },
], ],
space_after: [ space_after: [
Slice(start = 0, length = 0), Slice { start: 0, length: 0 },
], ],
spaces: [], spaces: [],
type_defs: [], type_defs: [],
@ -145,16 +145,16 @@ Defs {
@71-98 Defs( @71-98 Defs(
Defs { Defs {
tags: [ tags: [
Index(2147483648), EitherIndex(2147483648),
], ],
regions: [ regions: [
@75-80, @75-80,
], ],
space_before: [ space_before: [
Slice(start = 0, length = 0), Slice { start: 0, length: 0 },
], ],
space_after: [ space_after: [
Slice(start = 0, length = 0), Slice { start: 0, length: 0 },
], ],
spaces: [], spaces: [],
type_defs: [], type_defs: [],

View file

@ -4,16 +4,16 @@ expression: snapshot
--- ---
Defs { Defs {
tags: [ tags: [
Index(2147483648), EitherIndex(2147483648),
], ],
regions: [ regions: [
@0-158, @0-158,
], ],
space_before: [ space_before: [
Slice(start = 0, length = 0), Slice { start: 0, length: 0 },
], ],
space_after: [ space_after: [
Slice(start = 0, length = 1), Slice { start: 0, length: 1 },
], ],
spaces: [ spaces: [
Newline, Newline,
@ -39,16 +39,16 @@ Defs {
value: @46-130 Defs( value: @46-130 Defs(
Defs { Defs {
tags: [ tags: [
Index(2147483648), EitherIndex(2147483648),
], ],
regions: [ regions: [
@50-52, @50-52,
], ],
space_before: [ space_before: [
Slice(start = 0, length = 0), Slice { start: 0, length: 0 },
], ],
space_after: [ space_after: [
Slice(start = 0, length = 0), Slice { start: 0, length: 0 },
], ],
spaces: [], spaces: [],
type_defs: [], type_defs: [],

View file

@ -4,16 +4,16 @@ expression: snapshot
--- ---
Defs { Defs {
tags: [ tags: [
Index(2147483648), EitherIndex(2147483648),
], ],
regions: [ regions: [
@0-31, @0-31,
], ],
space_before: [ space_before: [
Slice(start = 0, length = 0), Slice { start: 0, length: 0 },
], ],
space_after: [ space_after: [
Slice(start = 0, length = 1), Slice { start: 0, length: 1 },
], ],
spaces: [ spaces: [
Newline, Newline,
@ -27,16 +27,16 @@ Defs {
@11-31 Defs( @11-31 Defs(
Defs { Defs {
tags: [ tags: [
Index(2147483648), EitherIndex(2147483648),
], ],
regions: [ regions: [
@11-24, @11-24,
], ],
space_before: [ space_before: [
Slice(start = 0, length = 0), Slice { start: 0, length: 0 },
], ],
space_after: [ space_after: [
Slice(start = 0, length = 0), Slice { start: 0, length: 0 },
], ],
spaces: [], spaces: [],
type_defs: [], type_defs: [],

View file

@ -4,16 +4,16 @@ expression: snapshot
--- ---
Defs { Defs {
tags: [ tags: [
Index(2147483648), EitherIndex(2147483648),
], ],
regions: [ regions: [
@0-307, @0-307,
], ],
space_before: [ space_before: [
Slice(start = 0, length = 0), Slice { start: 0, length: 0 },
], ],
space_after: [ space_after: [
Slice(start = 0, length = 1), Slice { start: 0, length: 1 },
], ],
spaces: [ spaces: [
Newline, Newline,
@ -27,9 +27,9 @@ Defs {
@11-307 Defs( @11-307 Defs(
Defs { Defs {
tags: [ tags: [
Index(2147483648), EitherIndex(2147483648),
Index(2147483649), EitherIndex(2147483649),
Index(2147483650), EitherIndex(2147483650),
], ],
regions: [ regions: [
@20-37, @20-37,
@ -37,14 +37,14 @@ Defs {
@109-298, @109-298,
], ],
space_before: [ space_before: [
Slice(start = 0, length = 0), Slice { start: 0, length: 0 },
Slice(start = 0, length = 1), Slice { start: 0, length: 1 },
Slice(start = 1, length = 1), Slice { start: 1, length: 1 },
], ],
space_after: [ space_after: [
Slice(start = 0, length = 0), Slice { start: 0, length: 0 },
Slice(start = 1, length = 0), Slice { start: 1, length: 0 },
Slice(start = 2, length = 0), Slice { start: 2, length: 0 },
], ],
spaces: [ spaces: [
Newline, Newline,
@ -165,16 +165,16 @@ Defs {
@140-152 Defs( @140-152 Defs(
Defs { Defs {
tags: [ tags: [
Index(2147483648), EitherIndex(2147483648),
], ],
regions: [ regions: [
@140-152, @140-152,
], ],
space_before: [ space_before: [
Slice(start = 0, length = 0), Slice { start: 0, length: 0 },
], ],
space_after: [ space_after: [
Slice(start = 0, length = 0), Slice { start: 0, length: 0 },
], ],
spaces: [], spaces: [],
type_defs: [], type_defs: [],
@ -287,16 +287,16 @@ Defs {
@227-239 Defs( @227-239 Defs(
Defs { Defs {
tags: [ tags: [
Index(2147483648), EitherIndex(2147483648),
], ],
regions: [ regions: [
@227-239, @227-239,
], ],
space_before: [ space_before: [
Slice(start = 0, length = 0), Slice { start: 0, length: 0 },
], ],
space_after: [ space_after: [
Slice(start = 0, length = 0), Slice { start: 0, length: 0 },
], ],
spaces: [], spaces: [],
type_defs: [], type_defs: [],

View file

@ -4,16 +4,16 @@ expression: snapshot
--- ---
Defs { Defs {
tags: [ tags: [
Index(2147483648), EitherIndex(2147483648),
], ],
regions: [ regions: [
@0-189, @0-189,
], ],
space_before: [ space_before: [
Slice(start = 0, length = 0), Slice { start: 0, length: 0 },
], ],
space_after: [ space_after: [
Slice(start = 0, length = 1), Slice { start: 0, length: 1 },
], ],
spaces: [ spaces: [
Newline, Newline,
@ -27,20 +27,20 @@ Defs {
@11-189 Defs( @11-189 Defs(
Defs { Defs {
tags: [ tags: [
Index(2147483648), EitherIndex(2147483648),
Index(2147483649), EitherIndex(2147483649),
], ],
regions: [ regions: [
@20-37, @20-37,
@52-70, @52-70,
], ],
space_before: [ space_before: [
Slice(start = 0, length = 0), Slice { start: 0, length: 0 },
Slice(start = 0, length = 1), Slice { start: 0, length: 1 },
], ],
space_after: [ space_after: [
Slice(start = 0, length = 0), Slice { start: 0, length: 0 },
Slice(start = 1, length = 0), Slice { start: 1, length: 0 },
], ],
spaces: [ spaces: [
Newline, Newline,

View file

@ -4,9 +4,9 @@ expression: snapshot
--- ---
Defs { Defs {
tags: [ tags: [
Index(2147483648), EitherIndex(2147483648),
Index(2147483649), EitherIndex(2147483649),
Index(2147483650), EitherIndex(2147483650),
], ],
regions: [ regions: [
@0-80, @0-80,
@ -14,14 +14,14 @@ Defs {
@229-266, @229-266,
], ],
space_before: [ space_before: [
Slice(start = 0, length = 0), Slice { start: 0, length: 0 },
Slice(start = 0, length = 2), Slice { start: 0, length: 2 },
Slice(start = 2, length = 2), Slice { start: 2, length: 2 },
], ],
space_after: [ space_after: [
Slice(start = 0, length = 0), Slice { start: 0, length: 0 },
Slice(start = 2, length = 0), Slice { start: 2, length: 0 },
Slice(start = 4, length = 1), Slice { start: 4, length: 1 },
], ],
spaces: [ spaces: [
Newline, Newline,
@ -112,20 +112,20 @@ Defs {
condition: @93-227 Defs( condition: @93-227 Defs(
Defs { Defs {
tags: [ tags: [
Index(2147483648), EitherIndex(2147483648),
Index(2147483649), EitherIndex(2147483649),
], ],
regions: [ regions: [
@99-189, @99-189,
@203-208, @203-208,
], ],
space_before: [ space_before: [
Slice(start = 0, length = 0), Slice { start: 0, length: 0 },
Slice(start = 0, length = 1), Slice { start: 0, length: 1 },
], ],
space_after: [ space_after: [
Slice(start = 0, length = 0), Slice { start: 0, length: 0 },
Slice(start = 1, length = 0), Slice { start: 1, length: 0 },
], ],
spaces: [ spaces: [
Newline, Newline,

View file

@ -4,20 +4,20 @@ expression: snapshot
--- ---
Defs { Defs {
tags: [ tags: [
Index(2147483648), EitherIndex(2147483648),
Index(2147483649), EitherIndex(2147483649),
], ],
regions: [ regions: [
@0-33, @0-33,
@35-45, @35-45,
], ],
space_before: [ space_before: [
Slice(start = 0, length = 0), Slice { start: 0, length: 0 },
Slice(start = 0, length = 2), Slice { start: 0, length: 2 },
], ],
space_after: [ space_after: [
Slice(start = 0, length = 0), Slice { start: 0, length: 0 },
Slice(start = 2, length = 1), Slice { start: 2, length: 1 },
], ],
spaces: [ spaces: [
Newline, Newline,

View file

@ -4,16 +4,16 @@ expression: snapshot
--- ---
Defs { Defs {
tags: [ tags: [
Index(2147483648), EitherIndex(2147483648),
], ],
regions: [ regions: [
@0-26, @0-26,
], ],
space_before: [ space_before: [
Slice(start = 0, length = 0), Slice { start: 0, length: 0 },
], ],
space_after: [ space_after: [
Slice(start = 0, length = 1), Slice { start: 0, length: 1 },
], ],
spaces: [ spaces: [
Newline, Newline,
@ -27,16 +27,16 @@ Defs {
@11-26 Defs( @11-26 Defs(
Defs { Defs {
tags: [ tags: [
Index(2147483648), EitherIndex(2147483648),
], ],
regions: [ regions: [
@15-17, @15-17,
], ],
space_before: [ space_before: [
Slice(start = 0, length = 0), Slice { start: 0, length: 0 },
], ],
space_after: [ space_after: [
Slice(start = 0, length = 0), Slice { start: 0, length: 0 },
], ],
spaces: [], spaces: [],
type_defs: [], type_defs: [],

View file

@ -4,16 +4,16 @@ expression: snapshot
--- ---
Defs { Defs {
tags: [ tags: [
Index(2147483648), EitherIndex(2147483648),
], ],
regions: [ regions: [
@0-33, @0-33,
], ],
space_before: [ space_before: [
Slice(start = 0, length = 0), Slice { start: 0, length: 0 },
], ],
space_after: [ space_after: [
Slice(start = 0, length = 1), Slice { start: 0, length: 1 },
], ],
spaces: [ spaces: [
Newline, Newline,
@ -33,16 +33,16 @@ Defs {
@11-15 Defs( @11-15 Defs(
Defs { Defs {
tags: [ tags: [
Index(2147483648), EitherIndex(2147483648),
], ],
regions: [ regions: [
@11-15, @11-15,
], ],
space_before: [ space_before: [
Slice(start = 0, length = 0), Slice { start: 0, length: 0 },
], ],
space_after: [ space_after: [
Slice(start = 0, length = 0), Slice { start: 0, length: 0 },
], ],
spaces: [], spaces: [],
type_defs: [], type_defs: [],
@ -93,16 +93,16 @@ Defs {
@20-24 Defs( @20-24 Defs(
Defs { Defs {
tags: [ tags: [
Index(2147483648), EitherIndex(2147483648),
], ],
regions: [ regions: [
@20-24, @20-24,
], ],
space_before: [ space_before: [
Slice(start = 0, length = 0), Slice { start: 0, length: 0 },
], ],
space_after: [ space_after: [
Slice(start = 0, length = 0), Slice { start: 0, length: 0 },
], ],
spaces: [], spaces: [],
type_defs: [], type_defs: [],

View file

@ -4,16 +4,16 @@ expression: snapshot
--- ---
Defs { Defs {
tags: [ tags: [
Index(2147483648), EitherIndex(2147483648),
], ],
regions: [ regions: [
@0-26, @0-26,
], ],
space_before: [ space_before: [
Slice(start = 0, length = 0), Slice { start: 0, length: 0 },
], ],
space_after: [ space_after: [
Slice(start = 0, length = 1), Slice { start: 0, length: 1 },
], ],
spaces: [ spaces: [
Newline, Newline,

View file

@ -4,16 +4,16 @@ expression: snapshot
--- ---
Defs { Defs {
tags: [ tags: [
Index(2147483648), EitherIndex(2147483648),
], ],
regions: [ regions: [
@0-72, @0-72,
], ],
space_before: [ space_before: [
Slice(start = 0, length = 0), Slice { start: 0, length: 0 },
], ],
space_after: [ space_after: [
Slice(start = 0, length = 1), Slice { start: 0, length: 1 },
], ],
spaces: [ spaces: [
Newline, Newline,
@ -33,16 +33,16 @@ Defs {
@11-23 Defs( @11-23 Defs(
Defs { Defs {
tags: [ tags: [
Index(2147483648), EitherIndex(2147483648),
], ],
regions: [ regions: [
@11-23, @11-23,
], ],
space_before: [ space_before: [
Slice(start = 0, length = 0), Slice { start: 0, length: 0 },
], ],
space_after: [ space_after: [
Slice(start = 0, length = 0), Slice { start: 0, length: 0 },
], ],
spaces: [], spaces: [],
type_defs: [], type_defs: [],

View file

@ -4,16 +4,16 @@ expression: snapshot
--- ---
Defs { Defs {
tags: [ tags: [
Index(2147483648), EitherIndex(2147483648),
], ],
regions: [ regions: [
@0-51, @0-51,
], ],
space_before: [ space_before: [
Slice(start = 0, length = 0), Slice { start: 0, length: 0 },
], ],
space_after: [ space_after: [
Slice(start = 0, length = 1), Slice { start: 0, length: 1 },
], ],
spaces: [ spaces: [
Newline, Newline,
@ -27,16 +27,16 @@ Defs {
@11-51 Defs( @11-51 Defs(
Defs { Defs {
tags: [ tags: [
Index(2147483648), EitherIndex(2147483648),
], ],
regions: [ regions: [
@17-24, @17-24,
], ],
space_before: [ space_before: [
Slice(start = 0, length = 0), Slice { start: 0, length: 0 },
], ],
space_after: [ space_after: [
Slice(start = 0, length = 0), Slice { start: 0, length: 0 },
], ],
spaces: [], spaces: [],
type_defs: [], type_defs: [],

View file

@ -4,16 +4,16 @@ expression: snapshot
--- ---
Defs { Defs {
tags: [ tags: [
Index(2147483648), EitherIndex(2147483648),
], ],
regions: [ regions: [
@0-24, @0-24,
], ],
space_before: [ space_before: [
Slice(start = 0, length = 0), Slice { start: 0, length: 0 },
], ],
space_after: [ space_after: [
Slice(start = 0, length = 1), Slice { start: 0, length: 1 },
], ],
spaces: [ spaces: [
Newline, Newline,
@ -33,16 +33,16 @@ Defs {
@11-16 Defs( @11-16 Defs(
Defs { Defs {
tags: [ tags: [
Index(2147483648), EitherIndex(2147483648),
], ],
regions: [ regions: [
@11-16, @11-16,
], ],
space_before: [ space_before: [
Slice(start = 0, length = 0), Slice { start: 0, length: 0 },
], ],
space_after: [ space_after: [
Slice(start = 0, length = 0), Slice { start: 0, length: 0 },
], ],
spaces: [], spaces: [],
type_defs: [], type_defs: [],

View file

@ -4,16 +4,16 @@ expression: snapshot
--- ---
Defs { Defs {
tags: [ tags: [
Index(2147483648), EitherIndex(2147483648),
], ],
regions: [ regions: [
@0-61, @0-61,
], ],
space_before: [ space_before: [
Slice(start = 0, length = 0), Slice { start: 0, length: 0 },
], ],
space_after: [ space_after: [
Slice(start = 0, length = 1), Slice { start: 0, length: 1 },
], ],
spaces: [ spaces: [
Newline, Newline,

View file

@ -4,16 +4,16 @@ expression: snapshot
--- ---
Defs { Defs {
tags: [ tags: [
Index(2147483648), EitherIndex(2147483648),
], ],
regions: [ regions: [
@0-49, @0-49,
], ],
space_before: [ space_before: [
Slice(start = 0, length = 0), Slice { start: 0, length: 0 },
], ],
space_after: [ space_after: [
Slice(start = 0, length = 1), Slice { start: 0, length: 1 },
], ],
spaces: [ spaces: [
Newline, Newline,
@ -27,16 +27,16 @@ Defs {
@11-49 Defs( @11-49 Defs(
Defs { Defs {
tags: [ tags: [
Index(2147483648), EitherIndex(2147483648),
], ],
regions: [ regions: [
@23-42, @23-42,
], ],
space_before: [ space_before: [
Slice(start = 0, length = 0), Slice { start: 0, length: 0 },
], ],
space_after: [ space_after: [
Slice(start = 0, length = 0), Slice { start: 0, length: 0 },
], ],
spaces: [], spaces: [],
type_defs: [], type_defs: [],

View file

@ -4,16 +4,16 @@ expression: snapshot
--- ---
Defs { Defs {
tags: [ tags: [
Index(2147483648), EitherIndex(2147483648),
], ],
regions: [ regions: [
@0-22, @0-22,
], ],
space_before: [ space_before: [
Slice(start = 0, length = 0), Slice { start: 0, length: 0 },
], ],
space_after: [ space_after: [
Slice(start = 0, length = 1), Slice { start: 0, length: 1 },
], ],
spaces: [ spaces: [
Newline, Newline,

View file

@ -1,20 +1,19 @@
--- ---
source: crates/compiler/can/tests/test_suffixed.rs source: crates/compiler/can/tests/test_suffixed.rs
assertion_line: 473
expression: snapshot expression: snapshot
--- ---
Defs { Defs {
tags: [ tags: [
Index(2147483648), EitherIndex(2147483648),
], ],
regions: [ regions: [
@0-51, @0-51,
], ],
space_before: [ space_before: [
Slice(start = 0, length = 0), Slice { start: 0, length: 0 },
], ],
space_after: [ space_after: [
Slice(start = 0, length = 1), Slice { start: 0, length: 1 },
], ],
spaces: [ spaces: [
Newline, Newline,
@ -28,16 +27,16 @@ Defs {
@11-51 Defs( @11-51 Defs(
Defs { Defs {
tags: [ tags: [
Index(2147483648), EitherIndex(2147483648),
], ],
regions: [ regions: [
@11-40, @11-40,
], ],
space_before: [ space_before: [
Slice(start = 0, length = 0), Slice { start: 0, length: 0 },
], ],
space_after: [ space_after: [
Slice(start = 0, length = 0), Slice { start: 0, length: 0 },
], ],
spaces: [], spaces: [],
type_defs: [], type_defs: [],
@ -55,16 +54,16 @@ Defs {
@11-23 Defs( @11-23 Defs(
Defs { Defs {
tags: [ tags: [
Index(2147483648), EitherIndex(2147483648),
], ],
regions: [ regions: [
@11-12, @11-12,
], ],
space_before: [ space_before: [
Slice(start = 0, length = 0), Slice { start: 0, length: 0 },
], ],
space_after: [ space_after: [
Slice(start = 0, length = 0), Slice { start: 0, length: 0 },
], ],
spaces: [], spaces: [],
type_defs: [], type_defs: [],

View file

@ -4,16 +4,16 @@ expression: snapshot
--- ---
Defs { Defs {
tags: [ tags: [
Index(2147483648), EitherIndex(2147483648),
], ],
regions: [ regions: [
@0-73, @0-73,
], ],
space_before: [ space_before: [
Slice(start = 0, length = 0), Slice { start: 0, length: 0 },
], ],
space_after: [ space_after: [
Slice(start = 0, length = 1), Slice { start: 0, length: 1 },
], ],
spaces: [ spaces: [
Newline, Newline,
@ -33,16 +33,16 @@ Defs {
@11-56 Defs( @11-56 Defs(
Defs { Defs {
tags: [ tags: [
Index(2147483648), EitherIndex(2147483648),
], ],
regions: [ regions: [
@11-56, @11-56,
], ],
space_before: [ space_before: [
Slice(start = 0, length = 0), Slice { start: 0, length: 0 },
], ],
space_after: [ space_after: [
Slice(start = 0, length = 0), Slice { start: 0, length: 0 },
], ],
spaces: [], spaces: [],
type_defs: [], type_defs: [],

View file

@ -4,16 +4,16 @@ expression: snapshot
--- ---
Defs { Defs {
tags: [ tags: [
Index(2147483648), EitherIndex(2147483648),
], ],
regions: [ regions: [
@0-67, @0-67,
], ],
space_before: [ space_before: [
Slice(start = 0, length = 0), Slice { start: 0, length: 0 },
], ],
space_after: [ space_after: [
Slice(start = 0, length = 1), Slice { start: 0, length: 1 },
], ],
spaces: [ spaces: [
Newline, Newline,
@ -42,16 +42,16 @@ Defs {
@19-30 Defs( @19-30 Defs(
Defs { Defs {
tags: [ tags: [
Index(2147483648), EitherIndex(2147483648),
], ],
regions: [ regions: [
@19-30, @19-30,
], ],
space_before: [ space_before: [
Slice(start = 0, length = 0), Slice { start: 0, length: 0 },
], ],
space_after: [ space_after: [
Slice(start = 0, length = 0), Slice { start: 0, length: 0 },
], ],
spaces: [], spaces: [],
type_defs: [], type_defs: [],

View file

@ -4,16 +4,16 @@ expression: snapshot
--- ---
Defs { Defs {
tags: [ tags: [
Index(2147483648), EitherIndex(2147483648),
], ],
regions: [ regions: [
@0-154, @0-154,
], ],
space_before: [ space_before: [
Slice(start = 0, length = 0), Slice { start: 0, length: 0 },
], ],
space_after: [ space_after: [
Slice(start = 0, length = 1), Slice { start: 0, length: 1 },
], ],
spaces: [ spaces: [
Newline, Newline,

View file

@ -4,16 +4,16 @@ expression: snapshot
--- ---
Defs { Defs {
tags: [ tags: [
Index(2147483648), EitherIndex(2147483648),
], ],
regions: [ regions: [
@0-44, @0-44,
], ],
space_before: [ space_before: [
Slice(start = 0, length = 0), Slice { start: 0, length: 0 },
], ],
space_after: [ space_after: [
Slice(start = 0, length = 1), Slice { start: 0, length: 1 },
], ],
spaces: [ spaces: [
Newline, Newline,
@ -39,16 +39,16 @@ Defs {
@14-30 Defs( @14-30 Defs(
Defs { Defs {
tags: [ tags: [
Index(2147483648), EitherIndex(2147483648),
], ],
regions: [ regions: [
@28-30, @28-30,
], ],
space_before: [ space_before: [
Slice(start = 0, length = 0), Slice { start: 0, length: 0 },
], ],
space_after: [ space_after: [
Slice(start = 0, length = 0), Slice { start: 0, length: 0 },
], ],
spaces: [], spaces: [],
type_defs: [], type_defs: [],

View file

@ -4,16 +4,16 @@ expression: snapshot
--- ---
Defs { Defs {
tags: [ tags: [
Index(2147483648), EitherIndex(2147483648),
], ],
regions: [ regions: [
@0-45, @0-45,
], ],
space_before: [ space_before: [
Slice(start = 0, length = 0), Slice { start: 0, length: 0 },
], ],
space_after: [ space_after: [
Slice(start = 0, length = 1), Slice { start: 0, length: 1 },
], ],
spaces: [ spaces: [
Newline, Newline,

View file

@ -4,16 +4,16 @@ expression: snapshot
--- ---
Defs { Defs {
tags: [ tags: [
Index(2147483648), EitherIndex(2147483648),
], ],
regions: [ regions: [
@0-120, @0-120,
], ],
space_before: [ space_before: [
Slice(start = 0, length = 0), Slice { start: 0, length: 0 },
], ],
space_after: [ space_after: [
Slice(start = 0, length = 1), Slice { start: 0, length: 1 },
], ],
spaces: [ spaces: [
Newline, Newline,
@ -61,16 +61,16 @@ Defs {
@54-65 Defs( @54-65 Defs(
Defs { Defs {
tags: [ tags: [
Index(2147483648), EitherIndex(2147483648),
], ],
regions: [ regions: [
@54-65, @54-65,
], ],
space_before: [ space_before: [
Slice(start = 0, length = 0), Slice { start: 0, length: 0 },
], ],
space_after: [ space_after: [
Slice(start = 0, length = 0), Slice { start: 0, length: 0 },
], ],
spaces: [], spaces: [],
type_defs: [], type_defs: [],

View file

@ -4,16 +4,16 @@ expression: snapshot
--- ---
Defs { Defs {
tags: [ tags: [
Index(2147483648), EitherIndex(2147483648),
], ],
regions: [ regions: [
@0-74, @0-74,
], ],
space_before: [ space_before: [
Slice(start = 0, length = 0), Slice { start: 0, length: 0 },
], ],
space_after: [ space_after: [
Slice(start = 0, length = 1), Slice { start: 0, length: 1 },
], ],
spaces: [ spaces: [
Newline, Newline,

View file

@ -6560,9 +6560,9 @@
"dev": true "dev": true
}, },
"node_modules/cookie": { "node_modules/cookie": {
"version": "0.6.0", "version": "0.7.1",
"resolved": "https://registry.npmjs.org/cookie/-/cookie-0.6.0.tgz", "resolved": "https://registry.npmjs.org/cookie/-/cookie-0.7.1.tgz",
"integrity": "sha512-U71cyTamuh1CRNCfpGY6to28lxvNwPG4Guz/EVjgf3Jmzv0vlDp1atT9eS5dDjMYHucpHbWns6Lwf3BKz6svdw==", "integrity": "sha512-6DnInpx7SJ2AK3+CTUE/ZM0vWTUboZCegxhC2xiIydHR9jNuTAASBrfEpHhiGOZw/nX51bHt6YQl8jsGo4y/0w==",
"dev": true, "dev": true,
"engines": { "engines": {
"node": ">= 0.6" "node": ">= 0.6"
@ -8690,9 +8690,9 @@
} }
}, },
"node_modules/express": { "node_modules/express": {
"version": "4.21.0", "version": "4.21.1",
"resolved": "https://registry.npmjs.org/express/-/express-4.21.0.tgz", "resolved": "https://registry.npmjs.org/express/-/express-4.21.1.tgz",
"integrity": "sha512-VqcNGcj/Id5ZT1LZ/cfihi3ttTn+NJmkli2eZADigjq29qTlWi/hAQ43t/VLPq8+UX06FCEx3ByOYet6ZFblng==", "integrity": "sha512-YSFlK1Ee0/GC8QaO91tHcDxJiE/X4FbpAyQWkxAvG6AXCuR65YzK8ua6D9hvi/TzUfZMpc+BwuM1IPw8fmQBiQ==",
"dev": true, "dev": true,
"dependencies": { "dependencies": {
"accepts": "~1.3.8", "accepts": "~1.3.8",
@ -8700,7 +8700,7 @@
"body-parser": "1.20.3", "body-parser": "1.20.3",
"content-disposition": "0.5.4", "content-disposition": "0.5.4",
"content-type": "~1.0.4", "content-type": "~1.0.4",
"cookie": "0.6.0", "cookie": "0.7.1",
"cookie-signature": "1.0.6", "cookie-signature": "1.0.6",
"debug": "2.6.9", "debug": "2.6.9",
"depd": "2.0.0", "depd": "2.0.0",

View file

@ -16,3 +16,5 @@ im-rc.workspace = true
im.workspace = true im.workspace = true
wyhash.workspace = true wyhash.workspace = true
smallvec.workspace = true smallvec.workspace = true
soa.workspace = true

View file

@ -1,191 +1,30 @@
use std::usize; /// Push to a std::vec::Vec<T> and then return an index to that new element's
/// position in the Vec.
///
/// This is not a method on soa::Index because the `soa` is `no_std` by design.
/// Long-term, our arena-allocated vectors should have this as a method!
pub fn index_push_new<T>(vector: &mut Vec<T>, value: T) -> soa::Index<T> {
let index = soa::Index::new(vector.len() as u32);
pub struct Index<T> { vector.push(value);
index: u32,
_marker: std::marker::PhantomData<T>, index
} }
impl<T> Eq for Index<T> {} /// Extend a std::vec::Vec<T> and then return a slice to the new elements'
/// positions in the Vec.
///
/// This is not a method on soa::Slice because the `soa` is `no_std` by design.
/// Long-term, our arena-allocated vectors should have this as a method!
pub fn slice_extend_new<T>(
vector: &mut Vec<T>,
values: impl IntoIterator<Item = T>,
) -> soa::Slice<T> {
let start = vector.len() as u32;
impl<T> PartialEq for Index<T> { vector.extend(values);
fn eq(&self, other: &Self) -> bool {
self.index == other.index let end = vector.len() as u32;
}
} soa::Slice::new(start, (end - start) as u16)
impl<T> std::hash::Hash for Index<T> {
fn hash<H: std::hash::Hasher>(&self, state: &mut H) {
self.index.hash(state);
}
}
impl<T> Clone for Index<T> {
fn clone(&self) -> Self {
*self
}
}
impl<T> Copy for Index<T> {}
impl<T> std::fmt::Debug for Index<T> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "Index({})", self.index)
}
}
impl<T> Index<T> {
pub const fn new(index: u32) -> Self {
Self {
index,
_marker: std::marker::PhantomData,
}
}
pub const fn index(self) -> usize {
self.index as usize
}
pub fn push_new(vector: &mut Vec<T>, value: T) -> Index<T> {
let index = Self::new(vector.len() as _);
vector.push(value);
index
}
pub const fn as_slice(self) -> Slice<T> {
Slice::new(self.index, 1)
}
}
#[derive(PartialEq, Eq)]
pub struct Slice<T> {
length: u16,
start: u32,
_marker: std::marker::PhantomData<T>,
}
impl<T> Clone for Slice<T> {
fn clone(&self) -> Self {
*self
}
}
impl<T> Copy for Slice<T> {}
impl<T> std::fmt::Debug for Slice<T> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "Slice(start = {}, length = {})", self.start, self.length)
}
}
impl<T> Default for Slice<T> {
fn default() -> Self {
Self::empty()
}
}
impl<T> Slice<T> {
pub const fn empty() -> Self {
Self::new(0, 0)
}
pub const fn new(start: u32, length: u16) -> Self {
Self {
start,
length,
_marker: std::marker::PhantomData,
}
}
pub fn extend_new<I>(vector: &mut Vec<T>, values: I) -> Slice<T>
where
I: IntoIterator<Item = T>,
{
let start = vector.len() as u32;
vector.extend(values);
let end = vector.len() as u32;
Self::new(start, (end - start) as u16)
}
pub const fn len(&self) -> usize {
self.length as _
}
pub const fn start(&self) -> usize {
self.start as _
}
pub const fn is_empty(&self) -> bool {
self.length == 0
}
pub const fn indices(&self) -> std::ops::Range<usize> {
self.start as usize..(self.start as usize + self.length as usize)
}
pub fn into_iter(&self) -> impl Iterator<Item = Index<T>> {
self.indices().map(|i| Index::new(i as _))
}
pub const fn at(&self, i: usize) -> Index<T> {
Index::new(self.start + i as u32)
}
}
#[derive(PartialEq, Eq)]
pub struct EitherIndex<T, U> {
index: u32,
_marker: std::marker::PhantomData<(T, U)>,
}
impl<T, U> Clone for EitherIndex<T, U> {
fn clone(&self) -> Self {
*self
}
}
impl<T, U> Copy for EitherIndex<T, U> {}
impl<T, U> std::fmt::Debug for EitherIndex<T, U> {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "Index({})", self.index)
}
}
impl<T, U> EitherIndex<T, U> {
const MASK: u32 = 1 << 31;
pub const fn from_left(input: Index<T>) -> Self {
assert!(input.index & Self::MASK == 0);
Self {
index: input.index,
_marker: std::marker::PhantomData,
}
}
pub const fn from_right(input: Index<U>) -> Self {
assert!(input.index & Self::MASK == 0);
Self {
index: input.index | Self::MASK,
_marker: std::marker::PhantomData,
}
}
pub const fn split(self) -> Result<Index<T>, Index<U>> {
if self.index & Self::MASK == 0 {
Ok(Index::new(self.index))
} else {
Err(Index::new(self.index ^ Self::MASK))
}
}
pub fn decrement_index(&mut self) {
self.index = self.index.saturating_sub(1);
}
} }

View file

@ -18,3 +18,5 @@ roc_region = { path = "../region" }
roc_types = { path = "../types" } roc_types = { path = "../types" }
arrayvec.workspace = true arrayvec.workspace = true
soa.workspace = true

View file

@ -22,7 +22,6 @@ use roc_can::expr::{
use roc_can::pattern::Pattern; use roc_can::pattern::Pattern;
use roc_can::traverse::symbols_introduced_from_pattern; use roc_can::traverse::symbols_introduced_from_pattern;
use roc_collections::all::{HumanIndex, MutMap, SendMap}; use roc_collections::all::{HumanIndex, MutMap, SendMap};
use roc_collections::soa::{Index, Slice};
use roc_collections::VecMap; use roc_collections::VecMap;
use roc_module::ident::Lowercase; use roc_module::ident::Lowercase;
use roc_module::symbol::{ModuleId, Symbol}; use roc_module::symbol::{ModuleId, Symbol};
@ -33,6 +32,7 @@ use roc_types::types::{
AliasKind, AnnotationSource, Category, IndexOrField, OptAbleType, PReason, Reason, RecordField, AliasKind, AnnotationSource, Category, IndexOrField, OptAbleType, PReason, Reason, RecordField,
TypeExtension, TypeTag, Types, TypeExtension, TypeTag, Types,
}; };
use soa::{Index, Slice};
/// This is for constraining Defs /// This is for constraining Defs
#[derive(Default, Debug)] #[derive(Default, Debug)]
@ -2969,7 +2969,7 @@ fn constrain_typed_function_arguments(
None None
}; };
let it = arguments.iter().zip(arg_types.into_iter()).enumerate(); let it = arguments.iter().zip(arg_types).enumerate();
for (index, ((pattern_var, annotated_mark, loc_pattern), ann)) in it { for (index, ((pattern_var, annotated_mark, loc_pattern), ann)) in it {
let pattern_var_index = constraints.push_variable(*pattern_var); let pattern_var_index = constraints.push_variable(*pattern_var);
let ann_index = constraints.push_type(types, ann); let ann_index = constraints.push_type(types, ann);
@ -3123,7 +3123,7 @@ fn constrain_typed_function_arguments_simple(
arguments: &[(Variable, AnnotatedMark, Loc<Pattern>)], arguments: &[(Variable, AnnotatedMark, Loc<Pattern>)],
arg_types: Slice<TypeTag>, arg_types: Slice<TypeTag>,
) { ) {
let it = arguments.iter().zip(arg_types.into_iter()).enumerate(); let it = arguments.iter().zip(arg_types).enumerate();
for (index, ((pattern_var, annotated_mark, loc_pattern), ann)) in it { for (index, ((pattern_var, annotated_mark, loc_pattern), ann)) in it {
let pattern_var_index = constraints.push_variable(*pattern_var); let pattern_var_index = constraints.push_variable(*pattern_var);
let ann_index = constraints.push_type(types, ann); let ann_index = constraints.push_type(types, ann);

View file

@ -5,7 +5,6 @@ use roc_can::expected::{Expected, PExpected};
use roc_can::pattern::Pattern::{self, *}; use roc_can::pattern::Pattern::{self, *};
use roc_can::pattern::{DestructType, ListPatterns, RecordDestruct, TupleDestruct}; use roc_can::pattern::{DestructType, ListPatterns, RecordDestruct, TupleDestruct};
use roc_collections::all::{HumanIndex, SendMap}; use roc_collections::all::{HumanIndex, SendMap};
use roc_collections::soa::Index;
use roc_collections::VecMap; use roc_collections::VecMap;
use roc_module::ident::Lowercase; use roc_module::ident::Lowercase;
use roc_module::symbol::Symbol; use roc_module::symbol::Symbol;
@ -15,6 +14,7 @@ use roc_types::types::{
AliasKind, AliasShared, Category, OptAbleType, PReason, PatternCategory, Reason, RecordField, AliasKind, AliasShared, Category, OptAbleType, PReason, PatternCategory, Reason, RecordField,
Type, TypeExtension, TypeTag, Types, Type, TypeExtension, TypeTag, Types,
}; };
use soa::Index;
#[derive(Default, Debug)] #[derive(Default, Debug)]
pub struct PatternState { pub struct PatternState {
@ -171,8 +171,10 @@ fn headers_from_annotation_help(
return false; return false;
} }
arguments.iter().zip(arg_types_slice.into_iter()).all( arguments
|(arg_pattern, arg_type)| { .iter()
.zip(arg_types_slice)
.all(|(arg_pattern, arg_type)| {
headers_from_annotation_help( headers_from_annotation_help(
types, types,
constraints, constraints,
@ -180,8 +182,7 @@ fn headers_from_annotation_help(
&Loc::at(annotation.region, arg_type), &Loc::at(annotation.region, arg_type),
headers, headers,
) )
}, })
)
} else { } else {
false false
} }

View file

@ -68,7 +68,8 @@ fn wrap_in_decode_custom_decode_with(
// Decode.decodeWith : bytes, inner_decoder, fmt -> DecoderResult (List val) // Decode.decodeWith : bytes, inner_decoder, fmt -> DecoderResult (List val)
let this_decode_with_var_slice = let this_decode_with_var_slice =
SubsSlice::insert_into_subs(env.subs, [bytes_var, inner_decoder_var, fmt_var]); env.subs
.insert_into_vars([bytes_var, inner_decoder_var, fmt_var]);
let this_decode_with_clos_var = env.subs.fresh_unnamed_flex_var(); let this_decode_with_clos_var = env.subs.fresh_unnamed_flex_var();
let this_decode_with_ret_var = env.subs.fresh_unnamed_flex_var(); let this_decode_with_ret_var = env.subs.fresh_unnamed_flex_var();
let this_decode_with_fn_var = synth_var( let this_decode_with_fn_var = synth_var(
@ -131,7 +132,7 @@ fn wrap_in_decode_custom_decode_with(
); );
// bytes, fmt -[[fn_name]]-> DecoderResult (List elem) // bytes, fmt -[[fn_name]]-> DecoderResult (List elem)
let args_slice = SubsSlice::insert_into_subs(env.subs, [bytes_var, fmt_var]); let args_slice = env.subs.insert_into_vars([bytes_var, fmt_var]);
env.subs.set_content( env.subs.set_content(
fn_var, fn_var,
Content::Structure(FlatType::Func( Content::Structure(FlatType::Func(
@ -173,7 +174,7 @@ fn wrap_in_decode_custom_decode_with(
let decode_custom_type = env.import_builtin_symbol_var(Symbol::DECODE_CUSTOM); let decode_custom_type = env.import_builtin_symbol_var(Symbol::DECODE_CUSTOM);
// (List U8, fmt -> DecodeResult (List elem)) -> Decoder (List elem) fmt // (List U8, fmt -> DecodeResult (List elem)) -> Decoder (List elem) fmt
let this_decode_custom_args = SubsSlice::insert_into_subs(env.subs, [custom_var]); let this_decode_custom_args = env.subs.insert_into_vars([custom_var]);
let this_decode_custom_clos_var = env.subs.fresh_unnamed_flex_var(); let this_decode_custom_clos_var = env.subs.fresh_unnamed_flex_var();
let this_decode_custom_ret_var = env.subs.fresh_unnamed_flex_var(); let this_decode_custom_ret_var = env.subs.fresh_unnamed_flex_var();
let this_decode_custom_fn_var = synth_var( let this_decode_custom_fn_var = synth_var(

View file

@ -5,7 +5,7 @@ use roc_module::called_via::CalledVia;
use roc_module::symbol::Symbol; use roc_module::symbol::Symbol;
use roc_region::all::Loc; use roc_region::all::Loc;
use roc_types::subs::{Content, FlatType, GetSubsSlice, SubsSlice, Variable}; use roc_types::subs::{Content, FlatType, GetSubsSlice, Variable};
use roc_types::types::AliasKind; use roc_types::types::AliasKind;
use crate::decoding::wrap_in_decode_custom_decode_with; use crate::decoding::wrap_in_decode_custom_decode_with;
@ -56,7 +56,7 @@ pub(crate) fn decoder(env: &mut Env<'_>, _def_symbol: Symbol) -> (Expr, Variable
let decode_list_fn_var = env.import_builtin_symbol_var(Symbol::DECODE_LIST); let decode_list_fn_var = env.import_builtin_symbol_var(Symbol::DECODE_LIST);
// Decoder elem fmt -a-> b // Decoder elem fmt -a-> b
let elem_decoder_var_slice = SubsSlice::insert_into_subs(env.subs, [elem_decoder_var]); let elem_decoder_var_slice = env.subs.insert_into_vars([elem_decoder_var]);
let this_decode_list_clos_var = env.subs.fresh_unnamed_flex_var(); let this_decode_list_clos_var = env.subs.fresh_unnamed_flex_var();
let this_decode_list_ret_var = env.subs.fresh_unnamed_flex_var(); let this_decode_list_ret_var = env.subs.fresh_unnamed_flex_var();
let this_decode_list_fn_var = synth_var( let this_decode_list_fn_var = synth_var(

View file

@ -9,8 +9,8 @@ use roc_module::ident::Lowercase;
use roc_module::symbol::Symbol; use roc_module::symbol::Symbol;
use roc_region::all::{Loc, Region}; use roc_region::all::{Loc, Region};
use roc_types::subs::{ use roc_types::subs::{
Content, ExhaustiveMark, FlatType, LambdaSet, OptVariable, RecordFields, RedundantMark, Content, ExhaustiveMark, FlatType, LambdaSet, OptVariable, RecordFields, RedundantMark, TagExt,
SubsSlice, TagExt, UnionLambdas, UnionTags, Variable, UnionLambdas, UnionTags, Variable,
}; };
use roc_types::types::RecordField; use roc_types::types::RecordField;
@ -66,7 +66,7 @@ use super::wrap_in_decode_custom_decode_with;
/// Ok f1 -> Ok { f1, f0 } /// Ok f1 -> Ok { f1, f0 }
/// Err _ -> Err TooShort /// Err _ -> Err TooShort
/// Err _ -> Err TooShort /// Err _ -> Err TooShort
/// ///
/// Decode.custom \bytes, fmt -> Decode.decodeWith bytes (Decode.record initialState stepField finalizer) fmt /// Decode.custom \bytes, fmt -> Decode.decodeWith bytes (Decode.record initialState stepField finalizer) fmt
///``` ///```
pub(crate) fn decoder( pub(crate) fn decoder(
@ -108,7 +108,8 @@ pub(crate) fn decoder(
let decode_record_var = env.import_builtin_symbol_var(Symbol::DECODE_RECORD); let decode_record_var = env.import_builtin_symbol_var(Symbol::DECODE_RECORD);
let this_decode_record_var = { let this_decode_record_var = {
let flat_type = FlatType::Func( let flat_type = FlatType::Func(
SubsSlice::insert_into_subs(env.subs, [initial_state_var, step_var, finalizer_var]), env.subs
.insert_into_vars([initial_state_var, step_var, finalizer_var]),
decode_record_lambda_set, decode_record_lambda_set,
record_decoder_var, record_decoder_var,
); );
@ -200,7 +201,7 @@ pub(super) fn step_field(
let mut branches = Vec::with_capacity(fields.len() + 1); let mut branches = Vec::with_capacity(fields.len() + 1);
let keep_payload_var = env.subs.fresh_unnamed_flex_var(); let keep_payload_var = env.subs.fresh_unnamed_flex_var();
let keep_or_skip_var = { let keep_or_skip_var = {
let keep_payload_subs_slice = SubsSlice::insert_into_subs(env.subs, [keep_payload_var]); let keep_payload_subs_slice = env.subs.insert_into_vars([keep_payload_var]);
let flat_type = FlatType::TagUnion( let flat_type = FlatType::TagUnion(
UnionTags::insert_slices_into_subs( UnionTags::insert_slices_into_subs(
env.subs, env.subs,
@ -337,7 +338,7 @@ pub(super) fn step_field(
}; };
{ {
let args_slice = SubsSlice::insert_into_subs(env.subs, [state_record_var, Variable::STR]); let args_slice = env.subs.insert_into_vars([state_record_var, Variable::STR]);
env.subs.set_content( env.subs.set_content(
function_type, function_type,
@ -403,7 +404,7 @@ fn custom_decoder(env: &mut Env<'_>, args: DecodingFieldArgs) -> (Variable, Expr
let decode_custom_var = env.import_builtin_symbol_var(Symbol::DECODE_CUSTOM); let decode_custom_var = env.import_builtin_symbol_var(Symbol::DECODE_CUSTOM);
let decode_custom_closure_var = env.subs.fresh_unnamed_flex_var(); let decode_custom_closure_var = env.subs.fresh_unnamed_flex_var();
let this_decode_custom_var = { let this_decode_custom_var = {
let subs_slice = SubsSlice::insert_into_subs(env.subs, [this_custom_callback_var]); let subs_slice = env.subs.insert_into_vars([this_custom_callback_var]);
let flat_type = let flat_type =
FlatType::Func(subs_slice, decode_custom_closure_var, decode_custom_ret_var); FlatType::Func(subs_slice, decode_custom_closure_var, decode_custom_ret_var);
@ -566,7 +567,7 @@ fn custom_decoder_lambda(env: &mut Env<'_>, args: DecodingFieldArgs) -> (Variabl
ambient_function: this_custom_callback_var, ambient_function: this_custom_callback_var,
}); });
let custom_callback_lambda_set_var = synth_var(env.subs, content); let custom_callback_lambda_set_var = synth_var(env.subs, content);
let subs_slice = SubsSlice::insert_into_subs(env.subs, [bytes_arg_var, fmt_arg_var]); let subs_slice = env.subs.insert_into_vars([bytes_arg_var, fmt_arg_var]);
env.subs.set_content( env.subs.set_content(
this_custom_callback_var, this_custom_callback_var,
@ -979,7 +980,7 @@ pub(super) fn finalizer(
}; };
let closure_type = synth_var(env.subs, Content::LambdaSet(lambda_set)); let closure_type = synth_var(env.subs, Content::LambdaSet(lambda_set));
let flat_type = FlatType::Func( let flat_type = FlatType::Func(
SubsSlice::insert_into_subs(env.subs, [state_record_var, fmt_arg_var]), env.subs.insert_into_vars([state_record_var, fmt_arg_var]),
closure_type, closure_type,
return_type_var, return_type_var,
); );
@ -1020,7 +1021,7 @@ pub(super) fn finalizer(
/// decRec-> decRec.result /// decRec-> decRec.result
/// Ok a -> Ok a /// Ok a -> Ok a
/// ``` /// ```
/// Tries to decode the field with a zero byte input if it missing, /// Tries to decode the field with a zero byte input if it missing,
/// this allows the decoder to decode types that have a state for "missing", such as /// this allows the decoder to decode types that have a state for "missing", such as
/// an "Option" type. /// an "Option" type.
/// ///
@ -1266,8 +1267,9 @@ fn make_decode_with_vars(
let decode_with_var = env.import_builtin_symbol_var(Symbol::DECODE_DECODE_WITH); let decode_with_var = env.import_builtin_symbol_var(Symbol::DECODE_DECODE_WITH);
let lambda_set_var = env.subs.fresh_unnamed_flex_var(); let lambda_set_var = env.subs.fresh_unnamed_flex_var();
let this_decode_with_var = { let this_decode_with_var = {
let subs_slice = let subs_slice = env
SubsSlice::insert_into_subs(env.subs, [bytes_arg_var, decoder_var, fmt_arg_var]); .subs
.insert_into_vars([bytes_arg_var, decoder_var, fmt_arg_var]);
let this_decode_with_var = synth_var( let this_decode_with_var = synth_var(
env.subs, env.subs,
Content::Structure(FlatType::Func(subs_slice, lambda_set_var, rec_var)), Content::Structure(FlatType::Func(subs_slice, lambda_set_var, rec_var)),

View file

@ -9,8 +9,8 @@ use roc_module::ident::Lowercase;
use roc_module::symbol::Symbol; use roc_module::symbol::Symbol;
use roc_region::all::{Loc, Region}; use roc_region::all::{Loc, Region};
use roc_types::subs::{ use roc_types::subs::{
Content, ExhaustiveMark, FlatType, LambdaSet, OptVariable, RecordFields, RedundantMark, Content, ExhaustiveMark, FlatType, LambdaSet, OptVariable, RecordFields, RedundantMark, TagExt,
SubsSlice, TagExt, TupleElems, UnionLambdas, UnionTags, Variable, TupleElems, UnionLambdas, UnionTags, Variable,
}; };
use roc_types::types::RecordField; use roc_types::types::RecordField;
@ -98,7 +98,8 @@ pub(crate) fn decoder(env: &mut Env, _def_symbol: Symbol, arity: u32) -> (Expr,
let decode_record_var = env.import_builtin_symbol_var(Symbol::DECODE_TUPLE); let decode_record_var = env.import_builtin_symbol_var(Symbol::DECODE_TUPLE);
let this_decode_record_var = { let this_decode_record_var = {
let flat_type = FlatType::Func( let flat_type = FlatType::Func(
SubsSlice::insert_into_subs(env.subs, [state_var, step_var, finalizer_var]), env.subs
.insert_into_vars([state_var, step_var, finalizer_var]),
decode_record_lambda_set, decode_record_lambda_set,
tuple_decoder_var, tuple_decoder_var,
); );
@ -190,7 +191,7 @@ fn step_elem(
let mut branches = Vec::with_capacity(index_vars.len() + 1); let mut branches = Vec::with_capacity(index_vars.len() + 1);
let keep_payload_var = env.subs.fresh_unnamed_flex_var(); let keep_payload_var = env.subs.fresh_unnamed_flex_var();
let keep_or_skip_var = { let keep_or_skip_var = {
let keep_payload_subs_slice = SubsSlice::insert_into_subs(env.subs, [keep_payload_var]); let keep_payload_subs_slice = env.subs.insert_into_vars([keep_payload_var]);
let flat_type = FlatType::TagUnion( let flat_type = FlatType::TagUnion(
UnionTags::insert_slices_into_subs( UnionTags::insert_slices_into_subs(
env.subs, env.subs,
@ -270,10 +271,9 @@ fn step_elem(
let decode_with_var = env.import_builtin_symbol_var(Symbol::DECODE_DECODE_WITH); let decode_with_var = env.import_builtin_symbol_var(Symbol::DECODE_DECODE_WITH);
let lambda_set_var = env.subs.fresh_unnamed_flex_var(); let lambda_set_var = env.subs.fresh_unnamed_flex_var();
let this_decode_with_var = { let this_decode_with_var = {
let subs_slice = SubsSlice::insert_into_subs( let subs_slice =
env.subs, env.subs
[bytes_arg_var, decoder_var, fmt_arg_var], .insert_into_vars([bytes_arg_var, decoder_var, fmt_arg_var]);
);
let this_decode_with_var = synth_var( let this_decode_with_var = synth_var(
env.subs, env.subs,
Content::Structure(FlatType::Func(subs_slice, lambda_set_var, rec_var)), Content::Structure(FlatType::Func(subs_slice, lambda_set_var, rec_var)),
@ -537,8 +537,7 @@ fn step_elem(
ambient_function: this_custom_callback_var, ambient_function: this_custom_callback_var,
}); });
let custom_callback_lambda_set_var = synth_var(env.subs, content); let custom_callback_lambda_set_var = synth_var(env.subs, content);
let subs_slice = let subs_slice = env.subs.insert_into_vars([bytes_arg_var, fmt_arg_var]);
SubsSlice::insert_into_subs(env.subs, [bytes_arg_var, fmt_arg_var]);
env.subs.set_content( env.subs.set_content(
this_custom_callback_var, this_custom_callback_var,
@ -581,7 +580,7 @@ fn step_elem(
let decode_custom_var = env.import_builtin_symbol_var(Symbol::DECODE_CUSTOM); let decode_custom_var = env.import_builtin_symbol_var(Symbol::DECODE_CUSTOM);
let decode_custom_closure_var = env.subs.fresh_unnamed_flex_var(); let decode_custom_closure_var = env.subs.fresh_unnamed_flex_var();
let this_decode_custom_var = { let this_decode_custom_var = {
let subs_slice = SubsSlice::insert_into_subs(env.subs, [this_custom_callback_var]); let subs_slice = env.subs.insert_into_vars([this_custom_callback_var]);
let flat_type = let flat_type =
FlatType::Func(subs_slice, decode_custom_closure_var, decode_custom_ret_var); FlatType::Func(subs_slice, decode_custom_closure_var, decode_custom_ret_var);
@ -699,7 +698,7 @@ fn step_elem(
}; };
{ {
let args_slice = SubsSlice::insert_into_subs(env.subs, [state_record_var, Variable::U64]); let args_slice = env.subs.insert_into_vars([state_record_var, Variable::U64]);
env.subs.set_content( env.subs.set_content(
function_type, function_type,
@ -884,7 +883,7 @@ fn finalizer(
}; };
let closure_type = synth_var(env.subs, Content::LambdaSet(lambda_set)); let closure_type = synth_var(env.subs, Content::LambdaSet(lambda_set));
let flat_type = FlatType::Func( let flat_type = FlatType::Func(
SubsSlice::insert_into_subs(env.subs, [state_record_var]), env.subs.insert_into_vars([state_record_var]),
closure_type, closure_type,
return_type_var, return_type_var,
); );

View file

@ -71,8 +71,7 @@ pub(crate) fn derive_to_encoder(
let flex_tag_labels = tags let flex_tag_labels = tags
.into_iter() .into_iter()
.map(|(label, arity)| { .map(|(label, arity)| {
let variables_slice = let variables_slice = env.subs.reserve_into_vars(arity.into());
VariableSubsSlice::reserve_into_subs(env.subs, arity.into());
for var_index in variables_slice { for var_index in variables_slice {
env.subs[var_index] = env.subs.fresh_unnamed_flex_var(); env.subs[var_index] = env.subs.fresh_unnamed_flex_var();
} }
@ -114,7 +113,7 @@ fn to_encoder_list(env: &mut Env<'_>, fn_name: Symbol) -> (Expr, Variable) {
// List elem // List elem
let elem_var = env.subs.fresh_unnamed_flex_var(); let elem_var = env.subs.fresh_unnamed_flex_var();
let elem_var_slice = SubsSlice::insert_into_subs(env.subs, [elem_var]); let elem_var_slice = env.subs.insert_into_vars([elem_var]);
let list_var = synth_var( let list_var = synth_var(
env.subs, env.subs,
Content::Structure(FlatType::Apply(Symbol::LIST_LIST, elem_var_slice)), Content::Structure(FlatType::Apply(Symbol::LIST_LIST, elem_var_slice)),
@ -205,8 +204,9 @@ fn to_encoder_list(env: &mut Env<'_>, fn_name: Symbol) -> (Expr, Variable) {
let encode_list_fn_var = env.import_builtin_symbol_var(Symbol::ENCODE_LIST); let encode_list_fn_var = env.import_builtin_symbol_var(Symbol::ENCODE_LIST);
// List elem, to_elem_encoder_fn_var -[clos]-> t1 // List elem, to_elem_encoder_fn_var -[clos]-> t1
let this_encode_list_args_slice = let this_encode_list_args_slice = env
VariableSubsSlice::insert_into_subs(env.subs, [list_var, to_elem_encoder_fn_var]); .subs
.insert_into_vars([list_var, to_elem_encoder_fn_var]);
let this_encode_list_clos_var = env.subs.fresh_unnamed_flex_var(); // clos let this_encode_list_clos_var = env.subs.fresh_unnamed_flex_var(); // clos
let this_list_encoder_var = env.subs.fresh_unnamed_flex_var(); // t1 let this_list_encoder_var = env.subs.fresh_unnamed_flex_var(); // t1
let this_encode_list_fn_var = synth_var( let this_encode_list_fn_var = synth_var(
@ -266,7 +266,7 @@ fn to_encoder_list(env: &mut Env<'_>, fn_name: Symbol) -> (Expr, Variable) {
}), }),
); );
// List elem -[fn_name]-> Encoder fmt // List elem -[fn_name]-> Encoder fmt
let list_var_slice = SubsSlice::insert_into_subs(env.subs, once(list_var)); let list_var_slice = env.subs.insert_into_vars(once(list_var));
env.subs.set_content( env.subs.set_content(
fn_var, fn_var,
Content::Structure(FlatType::Func( Content::Structure(FlatType::Func(
@ -318,7 +318,7 @@ fn to_encoder_record(
.map(|(field_name_index, field_var_index, _)| { .map(|(field_name_index, field_var_index, _)| {
let field_name = env.subs[field_name_index].clone(); let field_name = env.subs[field_name_index].clone();
let field_var = env.subs[field_var_index]; let field_var = env.subs[field_var_index];
let field_var_slice = VariableSubsSlice::new(field_var_index.index, 1); let field_var_slice = VariableSubsSlice::new(field_var_index.index() as u32, 1);
// key: "a" // key: "a"
let key_field = Field { let key_field = Field {
@ -407,7 +407,7 @@ fn to_encoder_record(
.collect::<Vec<_>>(); .collect::<Vec<_>>();
// typeof [ { key: .., value: .. }, { key: .., value: .. } ] // typeof [ { key: .., value: .. }, { key: .., value: .. } ]
let fields_rcd_var_slice = VariableSubsSlice::insert_into_subs(env.subs, once(whole_rcd_var)); let fields_rcd_var_slice = env.subs.insert_into_vars(once(whole_rcd_var));
let fields_list_var = synth_var( let fields_list_var = synth_var(
env.subs, env.subs,
Content::Structure(FlatType::Apply(Symbol::LIST_LIST, fields_rcd_var_slice)), Content::Structure(FlatType::Apply(Symbol::LIST_LIST, fields_rcd_var_slice)),
@ -424,8 +424,7 @@ fn to_encoder_record(
let encode_record_fn_var = env.import_builtin_symbol_var(Symbol::ENCODE_RECORD); let encode_record_fn_var = env.import_builtin_symbol_var(Symbol::ENCODE_RECORD);
// fields_list_var -[clos]-> t1 // fields_list_var -[clos]-> t1
let fields_list_var_slice = let fields_list_var_slice = env.subs.insert_into_vars(once(fields_list_var));
VariableSubsSlice::insert_into_subs(env.subs, once(fields_list_var));
let encode_record_clos_var = env.subs.fresh_unnamed_flex_var(); // clos let encode_record_clos_var = env.subs.fresh_unnamed_flex_var(); // clos
let encoder_var = env.subs.fresh_unnamed_flex_var(); // t1 let encoder_var = env.subs.fresh_unnamed_flex_var(); // t1
let this_encode_record_fn_var = synth_var( let this_encode_record_fn_var = synth_var(
@ -476,7 +475,7 @@ fn to_encoder_record(
}), }),
); );
// typeof rcd -[fn_name]-> (typeof Encode.record [ .. ] = Encoder fmt) // typeof rcd -[fn_name]-> (typeof Encode.record [ .. ] = Encoder fmt)
let record_var_slice = SubsSlice::insert_into_subs(env.subs, once(record_var)); let record_var_slice = env.subs.insert_into_vars(once(record_var));
env.subs.set_content( env.subs.set_content(
fn_var, fn_var,
Content::Structure(FlatType::Func( Content::Structure(FlatType::Func(
@ -528,7 +527,7 @@ fn to_encoder_tuple(
.map(|(elem_index, elem_var_index)| { .map(|(elem_index, elem_var_index)| {
let index = env.subs[elem_index]; let index = env.subs[elem_index];
let elem_var = env.subs[elem_var_index]; let elem_var = env.subs[elem_var_index];
let elem_var_slice = VariableSubsSlice::new(elem_var_index.index, 1); let elem_var_slice = VariableSubsSlice::new(elem_var_index.index() as u32, 1);
// tup.0 // tup.0
let tuple_access = TupleAccess { let tuple_access = TupleAccess {
@ -587,7 +586,7 @@ fn to_encoder_tuple(
// typeof [ toEncoder tup.0, toEncoder tup.1 ] // typeof [ toEncoder tup.0, toEncoder tup.1 ]
let whole_encoder_in_list_var_slice = let whole_encoder_in_list_var_slice =
VariableSubsSlice::insert_into_subs(env.subs, once(whole_encoder_in_list_var)); env.subs.insert_into_vars(once(whole_encoder_in_list_var));
let elem_encoders_list_var = synth_var( let elem_encoders_list_var = synth_var(
env.subs, env.subs,
Content::Structure(FlatType::Apply( Content::Structure(FlatType::Apply(
@ -607,8 +606,7 @@ fn to_encoder_tuple(
let encode_tuple_fn_var = env.import_builtin_symbol_var(Symbol::ENCODE_TUPLE); let encode_tuple_fn_var = env.import_builtin_symbol_var(Symbol::ENCODE_TUPLE);
// elem_encoders_list_var -[clos]-> t1 // elem_encoders_list_var -[clos]-> t1
let elem_encoders_list_var_slice = let elem_encoders_list_var_slice = env.subs.insert_into_vars(once(elem_encoders_list_var));
VariableSubsSlice::insert_into_subs(env.subs, once(elem_encoders_list_var));
let encode_tuple_clos_var = env.subs.fresh_unnamed_flex_var(); // clos let encode_tuple_clos_var = env.subs.fresh_unnamed_flex_var(); // clos
let encoder_var = env.subs.fresh_unnamed_flex_var(); // t1 let encoder_var = env.subs.fresh_unnamed_flex_var(); // t1
let this_encode_tuple_fn_var = synth_var( let this_encode_tuple_fn_var = synth_var(
@ -659,7 +657,7 @@ fn to_encoder_tuple(
}), }),
); );
// typeof tup -[fn_name]-> (typeof Encode.tuple [ .. ] = Encoder fmt) // typeof tup -[fn_name]-> (typeof Encode.tuple [ .. ] = Encoder fmt)
let tuple_var_slice = SubsSlice::insert_into_subs(env.subs, once(tuple_var)); let tuple_var_slice = env.subs.insert_into_vars(once(tuple_var));
env.subs.set_content( env.subs.set_content(
fn_var, fn_var,
Content::Structure(FlatType::Func( Content::Structure(FlatType::Func(
@ -746,8 +744,7 @@ fn to_encoder_tag_union(
env.import_builtin_symbol_var(Symbol::ENCODE_TO_ENCODER); env.import_builtin_symbol_var(Symbol::ENCODE_TO_ENCODER);
// wanted: t1 -[clos]-> t' // wanted: t1 -[clos]-> t'
let var_slice_of_sym_var = let var_slice_of_sym_var = env.subs.insert_into_vars([sym_var]); // [ t1 ]
VariableSubsSlice::insert_into_subs(env.subs, [sym_var]); // [ t1 ]
let to_encoder_clos_var = env.subs.fresh_unnamed_flex_var(); // clos let to_encoder_clos_var = env.subs.fresh_unnamed_flex_var(); // clos
let encoder_var = env.subs.fresh_unnamed_flex_var(); // t' let encoder_var = env.subs.fresh_unnamed_flex_var(); // t'
let this_to_encoder_fn_var = synth_var( let this_to_encoder_fn_var = synth_var(
@ -788,8 +785,7 @@ fn to_encoder_tag_union(
.collect(); .collect();
// typeof [ Encode.toEncoder v1, Encode.toEncoder v2 ] // typeof [ Encode.toEncoder v1, Encode.toEncoder v2 ]
let whole_encoders_var_slice = let whole_encoders_var_slice = env.subs.insert_into_vars([whole_payload_encoders_var]);
VariableSubsSlice::insert_into_subs(env.subs, [whole_payload_encoders_var]);
let payload_encoders_list_var = synth_var( let payload_encoders_list_var = synth_var(
env.subs, env.subs,
Content::Structure(FlatType::Apply(Symbol::LIST_LIST, whole_encoders_var_slice)), Content::Structure(FlatType::Apply(Symbol::LIST_LIST, whole_encoders_var_slice)),
@ -806,10 +802,9 @@ fn to_encoder_tag_union(
let encode_tag_fn_var = env.import_builtin_symbol_var(Symbol::ENCODE_TAG); let encode_tag_fn_var = env.import_builtin_symbol_var(Symbol::ENCODE_TAG);
// wanted: Str, List whole_encoders_var -[clos]-> t' // wanted: Str, List whole_encoders_var -[clos]-> t'
let this_encode_tag_args_var_slice = VariableSubsSlice::insert_into_subs( let this_encode_tag_args_var_slice = env
env.subs, .subs
[Variable::STR, payload_encoders_list_var], .insert_into_vars([Variable::STR, payload_encoders_list_var]);
);
let this_encode_tag_clos_var = env.subs.fresh_unnamed_flex_var(); // -[clos]-> let this_encode_tag_clos_var = env.subs.fresh_unnamed_flex_var(); // -[clos]->
let this_encoder_var = env.subs.fresh_unnamed_flex_var(); // t' let this_encoder_var = env.subs.fresh_unnamed_flex_var(); // t'
let this_encode_tag_fn_var = synth_var( let this_encode_tag_fn_var = synth_var(
@ -899,7 +894,7 @@ fn to_encoder_tag_union(
}), }),
); );
// tag_union_var -[fn_name]-> whole_tag_encoders_var // tag_union_var -[fn_name]-> whole_tag_encoders_var
let tag_union_var_slice = SubsSlice::insert_into_subs(env.subs, once(tag_union_var)); let tag_union_var_slice = env.subs.insert_into_vars(once(tag_union_var));
env.subs.set_content( env.subs.set_content(
fn_var, fn_var,
Content::Structure(FlatType::Func( Content::Structure(FlatType::Func(
@ -964,7 +959,8 @@ fn wrap_in_encode_custom(
// wanted: Encode.appendWith : List U8, encoder_var, fmt -[clos]-> List U8 where fmt implements EncoderFormatting // wanted: Encode.appendWith : List U8, encoder_var, fmt -[clos]-> List U8 where fmt implements EncoderFormatting
let this_append_with_args_var_slice = let this_append_with_args_var_slice =
VariableSubsSlice::insert_into_subs(env.subs, [Variable::LIST_U8, encoder_var, fmt_var]); env.subs
.insert_into_vars([Variable::LIST_U8, encoder_var, fmt_var]);
let this_append_with_clos_var = env.subs.fresh_unnamed_flex_var(); // -[clos]-> let this_append_with_clos_var = env.subs.fresh_unnamed_flex_var(); // -[clos]->
let this_append_with_fn_var = synth_var( let this_append_with_fn_var = synth_var(
env.subs, env.subs,
@ -1018,7 +1014,7 @@ fn wrap_in_encode_custom(
); );
// bytes, fmt -[[FN_name captured_var]]-> Encode.appendWith bytes encoder fmt // bytes, fmt -[[FN_name captured_var]]-> Encode.appendWith bytes encoder fmt
let args_slice = SubsSlice::insert_into_subs(env.subs, vec![bytes_var, fmt_var]); let args_slice = env.subs.insert_into_vars(vec![bytes_var, fmt_var]);
env.subs.set_content( env.subs.set_content(
fn_var, fn_var,
Content::Structure(FlatType::Func(args_slice, fn_clos_var, Variable::LIST_U8)), Content::Structure(FlatType::Func(args_slice, fn_clos_var, Variable::LIST_U8)),
@ -1054,7 +1050,7 @@ fn wrap_in_encode_custom(
let custom_fn_var = env.import_builtin_symbol_var(Symbol::ENCODE_CUSTOM); let custom_fn_var = env.import_builtin_symbol_var(Symbol::ENCODE_CUSTOM);
// wanted: Encode.custom : fn_var -[clos]-> t' // wanted: Encode.custom : fn_var -[clos]-> t'
let this_custom_args_var_slice = VariableSubsSlice::insert_into_subs(env.subs, [fn_var]); let this_custom_args_var_slice = env.subs.insert_into_vars([fn_var]);
let this_custom_clos_var = env.subs.fresh_unnamed_flex_var(); // -[clos]-> let this_custom_clos_var = env.subs.fresh_unnamed_flex_var(); // -[clos]->
let this_custom_encoder_var = env.subs.fresh_unnamed_flex_var(); // t' let this_custom_encoder_var = env.subs.fresh_unnamed_flex_var(); // t'
let this_custom_fn_var = synth_var( let this_custom_fn_var = synth_var(

View file

@ -7,6 +7,7 @@ use roc_can::{
num::{IntBound, IntLitWidth}, num::{IntBound, IntLitWidth},
pattern::Pattern, pattern::Pattern,
}; };
use roc_collections::soa::{index_push_new, slice_extend_new};
use roc_derive_key::hash::FlatHashKey; use roc_derive_key::hash::FlatHashKey;
use roc_error_macros::internal_error; use roc_error_macros::internal_error;
use roc_module::{ use roc_module::{
@ -19,8 +20,7 @@ use roc_types::{
num::int_lit_width_to_variable, num::int_lit_width_to_variable,
subs::{ subs::{
Content, ExhaustiveMark, FlatType, GetSubsSlice, LambdaSet, OptVariable, RecordFields, Content, ExhaustiveMark, FlatType, GetSubsSlice, LambdaSet, OptVariable, RecordFields,
RedundantMark, Subs, SubsIndex, SubsSlice, TagExt, TupleElems, UnionLambdas, UnionTags, RedundantMark, Subs, SubsSlice, TagExt, TupleElems, UnionLambdas, UnionTags, Variable,
Variable, VariableSubsSlice,
}, },
types::RecordField, types::RecordField,
}; };
@ -206,7 +206,7 @@ fn hash_tag_union(
let flex_tag_labels = tags let flex_tag_labels = tags
.into_iter() .into_iter()
.map(|(label, arity)| { .map(|(label, arity)| {
let variables_slice = VariableSubsSlice::reserve_into_subs(env.subs, arity.into()); let variables_slice = env.subs.reserve_into_vars(arity.into());
for var_index in variables_slice { for var_index in variables_slice {
env.subs[var_index] = env.subs.fresh_unnamed_flex_var(); env.subs[var_index] = env.subs.fresh_unnamed_flex_var();
} }
@ -366,14 +366,14 @@ fn hash_newtype_tag_union(
let (union_var, tag_name, payload_variables) = { let (union_var, tag_name, payload_variables) = {
let (label, arity) = tag; let (label, arity) = tag;
let variables_slice = VariableSubsSlice::reserve_into_subs(env.subs, arity.into()); let variables_slice = env.subs.reserve_into_vars(arity.into());
for var_index in variables_slice { for var_index in variables_slice {
env.subs[var_index] = env.subs.fresh_unnamed_flex_var(); env.subs[var_index] = env.subs.fresh_unnamed_flex_var();
} }
let variables_slices_slice = let variables_slices_slice =
SubsSlice::extend_new(&mut env.subs.variable_slices, [variables_slice]); slice_extend_new(&mut env.subs.variable_slices, [variables_slice]);
let tag_name_index = SubsIndex::push_new(&mut env.subs.tag_names, label.clone()); let tag_name_index = index_push_new(&mut env.subs.tag_names, label.clone());
let union_tags = UnionTags::from_slices(tag_name_index.as_slice(), variables_slices_slice); let union_tags = UnionTags::from_slices(tag_name_index.as_slice(), variables_slices_slice);
let tag_union_var = synth_var( let tag_union_var = synth_var(
@ -466,8 +466,7 @@ fn call_hash_ability_member(
let exposed_hash_fn_var = env.import_builtin_symbol_var(member); let exposed_hash_fn_var = env.import_builtin_symbol_var(member);
// (typeof body), (typeof field) -[clos]-> hasher_result // (typeof body), (typeof field) -[clos]-> hasher_result
let this_arguments_slice = let this_arguments_slice = env.subs.insert_into_vars([in_hasher_var, in_val_var]);
VariableSubsSlice::insert_into_subs(env.subs, [in_hasher_var, in_val_var]);
let this_hash_clos_var = env.subs.fresh_unnamed_flex_var(); let this_hash_clos_var = env.subs.fresh_unnamed_flex_var();
let this_out_hasher_var = env.subs.fresh_unnamed_flex_var(); let this_out_hasher_var = env.subs.fresh_unnamed_flex_var();
let this_hash_fn_var = synth_var( let this_hash_fn_var = synth_var(
@ -530,7 +529,7 @@ fn build_outer_derived_closure(
); );
// hasher, rcd_var -[fn_name]-> (hasher = body_var) // hasher, rcd_var -[fn_name]-> (hasher = body_var)
let args_slice = SubsSlice::insert_into_subs(env.subs, [hasher_var, val_var]); let args_slice = env.subs.insert_into_vars([hasher_var, val_var]);
env.subs.set_content( env.subs.set_content(
fn_var, fn_var,
Content::Structure(FlatType::Func(args_slice, fn_clos_var, body_var)), Content::Structure(FlatType::Func(args_slice, fn_clos_var, body_var)),

View file

@ -71,8 +71,7 @@ pub(crate) fn derive_to_inspector(
let flex_tag_labels = tags let flex_tag_labels = tags
.into_iter() .into_iter()
.map(|(label, arity)| { .map(|(label, arity)| {
let variables_slice = let variables_slice = env.subs.reserve_into_vars(arity.into());
VariableSubsSlice::reserve_into_subs(env.subs, arity.into());
for var_index in variables_slice { for var_index in variables_slice {
env.subs[var_index] = env.subs.fresh_unnamed_flex_var(); env.subs[var_index] = env.subs.fresh_unnamed_flex_var();
} }
@ -119,7 +118,7 @@ fn to_inspector_list(env: &mut Env<'_>, fn_name: Symbol) -> (Expr, Variable) {
// List elem // List elem
let elem_var = env.subs.fresh_unnamed_flex_var(); let elem_var = env.subs.fresh_unnamed_flex_var();
let elem_var_slice = SubsSlice::insert_into_subs(env.subs, [elem_var]); let elem_var_slice = env.subs.insert_into_vars([elem_var]);
let list_var = synth_var( let list_var = synth_var(
env.subs, env.subs,
Content::Structure(FlatType::Apply(Symbol::LIST_LIST, elem_var_slice)), Content::Structure(FlatType::Apply(Symbol::LIST_LIST, elem_var_slice)),
@ -212,10 +211,9 @@ fn to_inspector_list(env: &mut Env<'_>, fn_name: Symbol) -> (Expr, Variable) {
// List elem, List.walk, to_elem_inspector_fn_var -[clos]-> t1 // List elem, List.walk, to_elem_inspector_fn_var -[clos]-> t1
let list_walk_fn_var = env.import_builtin_symbol_var(Symbol::LIST_WALK); let list_walk_fn_var = env.import_builtin_symbol_var(Symbol::LIST_WALK);
let this_inspect_list_args_slice = VariableSubsSlice::insert_into_subs( let this_inspect_list_args_slice =
env.subs, env.subs
[list_var, list_walk_fn_var, to_elem_inspector_fn_var], .insert_into_vars([list_var, list_walk_fn_var, to_elem_inspector_fn_var]);
);
let this_inspect_list_clos_var = env.subs.fresh_unnamed_flex_var(); // clos let this_inspect_list_clos_var = env.subs.fresh_unnamed_flex_var(); // clos
let this_list_inspector_var = env.subs.fresh_unnamed_flex_var(); // t1 let this_list_inspector_var = env.subs.fresh_unnamed_flex_var(); // t1
let this_inspect_list_fn_var = synth_var( let this_inspect_list_fn_var = synth_var(
@ -279,7 +277,7 @@ fn to_inspector_list(env: &mut Env<'_>, fn_name: Symbol) -> (Expr, Variable) {
}), }),
); );
// List elem -[fn_name]-> Inspector fmt // List elem -[fn_name]-> Inspector fmt
let list_var_slice = SubsSlice::insert_into_subs(env.subs, once(list_var)); let list_var_slice = env.subs.insert_into_vars(once(list_var));
env.subs.set_content( env.subs.set_content(
fn_var, fn_var,
Content::Structure(FlatType::Func( Content::Structure(FlatType::Func(
@ -331,7 +329,7 @@ fn to_inspector_record(
.map(|(field_name_index, field_var_index, _)| { .map(|(field_name_index, field_var_index, _)| {
let field_name = env.subs[field_name_index].clone(); let field_name = env.subs[field_name_index].clone();
let field_var = env.subs[field_var_index]; let field_var = env.subs[field_var_index];
let field_var_slice = VariableSubsSlice::new(field_var_index.index, 1); let field_var_slice = VariableSubsSlice::new(field_var_index.index() as u32, 1);
// key: "a" // key: "a"
let key_field = Field { let key_field = Field {
@ -421,7 +419,7 @@ fn to_inspector_record(
.collect::<Vec<_>>(); .collect::<Vec<_>>();
// typeof [ { key: .., value: .. }, { key: .., value: .. } ] // typeof [ { key: .., value: .. }, { key: .., value: .. } ]
let fields_rcd_var_slice = VariableSubsSlice::insert_into_subs(env.subs, once(whole_rcd_var)); let fields_rcd_var_slice = env.subs.insert_into_vars(once(whole_rcd_var));
let fields_list_var = synth_var( let fields_list_var = synth_var(
env.subs, env.subs,
Content::Structure(FlatType::Apply(Symbol::LIST_LIST, fields_rcd_var_slice)), Content::Structure(FlatType::Apply(Symbol::LIST_LIST, fields_rcd_var_slice)),
@ -438,8 +436,7 @@ fn to_inspector_record(
let inspect_record_fn_var = env.import_builtin_symbol_var(Symbol::INSPECT_RECORD); let inspect_record_fn_var = env.import_builtin_symbol_var(Symbol::INSPECT_RECORD);
// fields_list_var -[clos]-> t1 // fields_list_var -[clos]-> t1
let fields_list_var_slice = let fields_list_var_slice = env.subs.insert_into_vars(once(fields_list_var));
VariableSubsSlice::insert_into_subs(env.subs, once(fields_list_var));
let inspect_record_clos_var = env.subs.fresh_unnamed_flex_var(); // clos let inspect_record_clos_var = env.subs.fresh_unnamed_flex_var(); // clos
let inspector_var = env.subs.fresh_unnamed_flex_var(); // t1 let inspector_var = env.subs.fresh_unnamed_flex_var(); // t1
let this_inspect_record_fn_var = synth_var( let this_inspect_record_fn_var = synth_var(
@ -490,7 +487,7 @@ fn to_inspector_record(
}), }),
); );
// typeof rcd -[fn_name]-> (typeof Inspect.record [ .. ] = Inspector fmt) // typeof rcd -[fn_name]-> (typeof Inspect.record [ .. ] = Inspector fmt)
let record_var_slice = SubsSlice::insert_into_subs(env.subs, once(record_var)); let record_var_slice = env.subs.insert_into_vars(once(record_var));
env.subs.set_content( env.subs.set_content(
fn_var, fn_var,
Content::Structure(FlatType::Func( Content::Structure(FlatType::Func(
@ -542,7 +539,7 @@ fn to_inspector_tuple(
.map(|(elem_index, elem_var_index)| { .map(|(elem_index, elem_var_index)| {
let index = env.subs[elem_index]; let index = env.subs[elem_index];
let elem_var = env.subs[elem_var_index]; let elem_var = env.subs[elem_var_index];
let elem_var_slice = VariableSubsSlice::new(elem_var_index.index, 1); let elem_var_slice = VariableSubsSlice::new(elem_var_index.index() as u32, 1);
// tup.0 // tup.0
let tuple_access = TupleAccess { let tuple_access = TupleAccess {
@ -602,7 +599,7 @@ fn to_inspector_tuple(
// typeof [ toInspector tup.0, toInspector tup.1 ] // typeof [ toInspector tup.0, toInspector tup.1 ]
let whole_inspector_in_list_var_slice = let whole_inspector_in_list_var_slice =
VariableSubsSlice::insert_into_subs(env.subs, once(whole_inspector_in_list_var)); env.subs.insert_into_vars(once(whole_inspector_in_list_var));
let elem_inspectors_list_var = synth_var( let elem_inspectors_list_var = synth_var(
env.subs, env.subs,
Content::Structure(FlatType::Apply( Content::Structure(FlatType::Apply(
@ -622,8 +619,7 @@ fn to_inspector_tuple(
let inspect_tuple_fn_var = env.import_builtin_symbol_var(Symbol::INSPECT_TUPLE); let inspect_tuple_fn_var = env.import_builtin_symbol_var(Symbol::INSPECT_TUPLE);
// elem_inspectors_list_var -[clos]-> t1 // elem_inspectors_list_var -[clos]-> t1
let elem_inspectors_list_var_slice = let elem_inspectors_list_var_slice = env.subs.insert_into_vars(once(elem_inspectors_list_var));
VariableSubsSlice::insert_into_subs(env.subs, once(elem_inspectors_list_var));
let inspect_tuple_clos_var = env.subs.fresh_unnamed_flex_var(); // clos let inspect_tuple_clos_var = env.subs.fresh_unnamed_flex_var(); // clos
let inspector_var = env.subs.fresh_unnamed_flex_var(); // t1 let inspector_var = env.subs.fresh_unnamed_flex_var(); // t1
let this_inspect_tuple_fn_var = synth_var( let this_inspect_tuple_fn_var = synth_var(
@ -674,7 +670,7 @@ fn to_inspector_tuple(
}), }),
); );
// typeof tup -[fn_name]-> (typeof Inspect.tuple [ .. ] = Inspector fmt) // typeof tup -[fn_name]-> (typeof Inspect.tuple [ .. ] = Inspector fmt)
let tuple_var_slice = SubsSlice::insert_into_subs(env.subs, once(tuple_var)); let tuple_var_slice = env.subs.insert_into_vars(once(tuple_var));
env.subs.set_content( env.subs.set_content(
fn_var, fn_var,
Content::Structure(FlatType::Func( Content::Structure(FlatType::Func(
@ -761,8 +757,7 @@ fn to_inspector_tag_union(
env.import_builtin_symbol_var(Symbol::INSPECT_TO_INSPECTOR); env.import_builtin_symbol_var(Symbol::INSPECT_TO_INSPECTOR);
// wanted: t1 -[clos]-> t' // wanted: t1 -[clos]-> t'
let var_slice_of_sym_var = let var_slice_of_sym_var = env.subs.insert_into_vars([sym_var]); // [ t1 ]
VariableSubsSlice::insert_into_subs(env.subs, [sym_var]); // [ t1 ]
let to_inspector_clos_var = env.subs.fresh_unnamed_flex_var(); // clos let to_inspector_clos_var = env.subs.fresh_unnamed_flex_var(); // clos
let inspector_var = env.subs.fresh_unnamed_flex_var(); // t' let inspector_var = env.subs.fresh_unnamed_flex_var(); // t'
let this_to_inspector_fn_var = synth_var( let this_to_inspector_fn_var = synth_var(
@ -804,7 +799,7 @@ fn to_inspector_tag_union(
// typeof [ Inspect.toInspector v1, Inspect.toInspector v2 ] // typeof [ Inspect.toInspector v1, Inspect.toInspector v2 ]
let whole_inspectors_var_slice = let whole_inspectors_var_slice =
VariableSubsSlice::insert_into_subs(env.subs, [whole_payload_inspectors_var]); env.subs.insert_into_vars([whole_payload_inspectors_var]);
let payload_inspectors_list_var = synth_var( let payload_inspectors_list_var = synth_var(
env.subs, env.subs,
Content::Structure(FlatType::Apply( Content::Structure(FlatType::Apply(
@ -824,10 +819,9 @@ fn to_inspector_tag_union(
let inspect_tag_fn_var = env.import_builtin_symbol_var(Symbol::INSPECT_TAG); let inspect_tag_fn_var = env.import_builtin_symbol_var(Symbol::INSPECT_TAG);
// wanted: Str, List whole_inspectors_var -[clos]-> t' // wanted: Str, List whole_inspectors_var -[clos]-> t'
let this_inspect_tag_args_var_slice = VariableSubsSlice::insert_into_subs( let this_inspect_tag_args_var_slice = env
env.subs, .subs
[Variable::STR, payload_inspectors_list_var], .insert_into_vars([Variable::STR, payload_inspectors_list_var]);
);
let this_inspect_tag_clos_var = env.subs.fresh_unnamed_flex_var(); // -[clos]-> let this_inspect_tag_clos_var = env.subs.fresh_unnamed_flex_var(); // -[clos]->
let this_inspector_var = env.subs.fresh_unnamed_flex_var(); // t' let this_inspector_var = env.subs.fresh_unnamed_flex_var(); // t'
let this_inspect_tag_fn_var = synth_var( let this_inspect_tag_fn_var = synth_var(
@ -917,7 +911,7 @@ fn to_inspector_tag_union(
}), }),
); );
// tag_union_var -[fn_name]-> whole_tag_inspectors_var // tag_union_var -[fn_name]-> whole_tag_inspectors_var
let tag_union_var_slice = SubsSlice::insert_into_subs(env.subs, once(tag_union_var)); let tag_union_var_slice = env.subs.insert_into_vars(once(tag_union_var));
env.subs.set_content( env.subs.set_content(
fn_var, fn_var,
Content::Structure(FlatType::Func( Content::Structure(FlatType::Func(
@ -972,8 +966,7 @@ fn wrap_in_inspect_custom(
let apply_fn_var = env.import_builtin_symbol_var(Symbol::INSPECT_APPLY); let apply_fn_var = env.import_builtin_symbol_var(Symbol::INSPECT_APPLY);
// wanted: Inspect.apply : inspector_var, fmt -[clos]-> fmt where fmt implements InspectorFormatter // wanted: Inspect.apply : inspector_var, fmt -[clos]-> fmt where fmt implements InspectorFormatter
let this_apply_args_var_slice = let this_apply_args_var_slice = env.subs.insert_into_vars([inspector_var, fmt_var]);
VariableSubsSlice::insert_into_subs(env.subs, [inspector_var, fmt_var]);
let this_apply_clos_var = env.subs.fresh_unnamed_flex_var(); // -[clos]-> let this_apply_clos_var = env.subs.fresh_unnamed_flex_var(); // -[clos]->
let this_apply_fn_var = synth_var( let this_apply_fn_var = synth_var(
env.subs, env.subs,
@ -1025,7 +1018,7 @@ fn wrap_in_inspect_custom(
); );
// fmt -[[FN_name captured_var]]-> Inspect.apply inspector fmt // fmt -[[FN_name captured_var]]-> Inspect.apply inspector fmt
let args_slice = SubsSlice::insert_into_subs(env.subs, vec![fmt_var]); let args_slice = env.subs.insert_into_vars(vec![fmt_var]);
env.subs.set_content( env.subs.set_content(
fn_var, fn_var,
Content::Structure(FlatType::Func(args_slice, fn_clos_var, fmt_var)), Content::Structure(FlatType::Func(args_slice, fn_clos_var, fmt_var)),
@ -1054,7 +1047,7 @@ fn wrap_in_inspect_custom(
let custom_fn_var = env.import_builtin_symbol_var(Symbol::INSPECT_CUSTOM); let custom_fn_var = env.import_builtin_symbol_var(Symbol::INSPECT_CUSTOM);
// wanted: Inspect.custom : fn_var -[clos]-> t' // wanted: Inspect.custom : fn_var -[clos]-> t'
let this_custom_args_var_slice = VariableSubsSlice::insert_into_subs(env.subs, [fn_var]); let this_custom_args_var_slice = env.subs.insert_into_vars([fn_var]);
let this_custom_clos_var = env.subs.fresh_unnamed_flex_var(); // -[clos]-> let this_custom_clos_var = env.subs.fresh_unnamed_flex_var(); // -[clos]->
let this_custom_inspector_var = env.subs.fresh_unnamed_flex_var(); // t' let this_custom_inspector_var = env.subs.fresh_unnamed_flex_var(); // t'
let this_custom_fn_var = synth_var( let this_custom_fn_var = synth_var(

View file

@ -662,7 +662,7 @@ fn format_str_segment(seg: &StrSegment, buf: &mut Buf, indent: u16) {
buf.push('\\'); buf.push('\\');
buf.push(escaped.to_parsed_char()); buf.push(escaped.to_parsed_char());
} }
DeprecatedInterpolated(loc_expr) | Interpolated(loc_expr) => { Interpolated(loc_expr) => {
buf.push_str("$("); buf.push_str("$(");
// e.g. (name) in "Hi, $(name)!" // e.g. (name) in "Hi, $(name)!"
loc_expr.value.format_with_options( loc_expr.value.format_with_options(

View file

@ -1786,7 +1786,7 @@ impl<
fn build_num_neg(&mut self, dst: &Symbol, src: &Symbol, layout: &InLayout<'a>) { fn build_num_neg(&mut self, dst: &Symbol, src: &Symbol, layout: &InLayout<'a>) {
match self.layout_interner.get_repr(*layout) { match self.layout_interner.get_repr(*layout) {
LayoutRepr::Builtin(Builtin::Int(IntWidth::I64 | IntWidth::U64)) => { LayoutRepr::Builtin(Builtin::Int(quadword_and_smaller!())) => {
let dst_reg = self.storage_manager.claim_general_reg(&mut self.buf, dst); let dst_reg = self.storage_manager.claim_general_reg(&mut self.buf, dst);
let src_reg = self.storage_manager.load_to_general_reg(&mut self.buf, src); let src_reg = self.storage_manager.load_to_general_reg(&mut self.buf, src);
ASM::neg_reg64_reg64(&mut self.buf, dst_reg, src_reg); ASM::neg_reg64_reg64(&mut self.buf, dst_reg, src_reg);

View file

@ -5657,7 +5657,7 @@ mod test_reporting {
test_report!( test_report!(
weird_escape, weird_escape,
r#""abc\qdef""#, r#""abc\qdef""#,
@r###" @r#"
WEIRD ESCAPE in tmp/weird_escape/Test.roc WEIRD ESCAPE in tmp/weird_escape/Test.roc
I was partway through parsing a string literal, but I got stuck here: I was partway through parsing a string literal, but I got stuck here:
@ -5674,8 +5674,7 @@ mod test_reporting {
- An escaped quote: \" - An escaped quote: \"
- An escaped backslash: \\ - An escaped backslash: \\
- A unicode code point: \u(00FF) - A unicode code point: \u(00FF)
- An interpolated string: $(myVariable) "#
"###
); );
test_report!( test_report!(

View file

@ -20,6 +20,7 @@ use roc_can::module::{
canonicalize_module_defs, ExposedByModule, ExposedForModule, ExposedModuleTypes, Module, canonicalize_module_defs, ExposedByModule, ExposedForModule, ExposedModuleTypes, Module,
ModuleParams, ResolvedImplementations, TypeState, ModuleParams, ResolvedImplementations, TypeState,
}; };
use roc_collections::soa::slice_extend_new;
use roc_collections::{default_hasher, BumpMap, MutMap, MutSet, VecMap, VecSet}; use roc_collections::{default_hasher, BumpMap, MutMap, MutSet, VecMap, VecSet};
use roc_constrain::module::constrain_module; use roc_constrain::module::constrain_module;
use roc_debug_flags::dbg_do; use roc_debug_flags::dbg_do;
@ -4372,7 +4373,7 @@ fn synth_list_len_type(subs: &mut Subs) -> Variable {
// List.len : List a -> U64 // List.len : List a -> U64
let a = synth_import(subs, Content::FlexVar(None)); let a = synth_import(subs, Content::FlexVar(None));
let a_slice = SubsSlice::extend_new(&mut subs.variables, [a]); let a_slice = slice_extend_new(&mut subs.variables, [a]);
let list_a = synth_import( let list_a = synth_import(
subs, subs,
Content::Structure(FlatType::Apply(Symbol::LIST_LIST, a_slice)), Content::Structure(FlatType::Apply(Symbol::LIST_LIST, a_slice)),
@ -4388,7 +4389,7 @@ fn synth_list_len_type(subs: &mut Subs) -> Variable {
ambient_function: fn_var, ambient_function: fn_var,
}), }),
); );
let fn_args_slice = SubsSlice::extend_new(&mut subs.variables, [list_a]); let fn_args_slice = slice_extend_new(&mut subs.variables, [list_a]);
subs.set_content( subs.set_content(
fn_var, fn_var,
Content::Structure(FlatType::Func(fn_args_slice, clos_list_len, Variable::U64)), Content::Structure(FlatType::Func(fn_args_slice, clos_list_len, Variable::U64)),

View file

@ -10124,7 +10124,7 @@ fn find_lambda_sets_help(
| FlatType::RecursiveTagUnion(_, union_tags, ext) => { | FlatType::RecursiveTagUnion(_, union_tags, ext) => {
for tag in union_tags.variables() { for tag in union_tags.variables() {
stack.extend( stack.extend(
subs.get_subs_slice(subs.variable_slices[tag.index as usize]) subs.get_subs_slice(subs.variable_slices[tag.index()])
.iter() .iter()
.rev(), .rev(),
); );
@ -10146,7 +10146,7 @@ fn find_lambda_sets_help(
// the lambda set itself should already be caught by Func above, but the // the lambda set itself should already be caught by Func above, but the
// capture can itself contain more lambda sets // capture can itself contain more lambda sets
for index in lambda_set.solved.variables() { for index in lambda_set.solved.variables() {
let subs_slice = subs.variable_slices[index.index as usize]; let subs_slice = subs.variable_slices[index.index()];
stack.extend(subs.variables[subs_slice.indices()].iter()); stack.extend(subs.variables[subs_slice.indices()].iter());
} }
} }

View file

@ -16,6 +16,8 @@ roc_module = { path = "../module" }
roc_region = { path = "../region" } roc_region = { path = "../region" }
roc_error_macros = { path = "../../error_macros" } roc_error_macros = { path = "../../error_macros" }
soa.workspace = true
bumpalo.workspace = true bumpalo.workspace = true
encode_unicode.workspace = true encode_unicode.workspace = true

View file

@ -8,11 +8,12 @@ use crate::ident::Accessor;
use crate::parser::ESingleQuote; use crate::parser::ESingleQuote;
use bumpalo::collections::{String, Vec}; use bumpalo::collections::{String, Vec};
use bumpalo::Bump; use bumpalo::Bump;
use roc_collections::soa::{EitherIndex, Index, Slice}; use roc_collections::soa::{index_push_new, slice_extend_new};
use roc_error_macros::internal_error; use roc_error_macros::internal_error;
use roc_module::called_via::{BinOp, CalledVia, UnaryOp}; use roc_module::called_via::{BinOp, CalledVia, UnaryOp};
use roc_module::ident::QualifiedModuleName; use roc_module::ident::QualifiedModuleName;
use roc_region::all::{Loc, Position, Region}; use roc_region::all::{Loc, Position, Region};
use soa::{EitherIndex, Slice};
#[derive(Debug, Clone)] #[derive(Debug, Clone)]
pub struct FullAst<'a> { pub struct FullAst<'a> {
@ -281,11 +282,10 @@ pub struct WhenPattern<'a> {
#[derive(Clone, Copy, Debug, PartialEq)] #[derive(Clone, Copy, Debug, PartialEq)]
pub enum StrSegment<'a> { pub enum StrSegment<'a> {
Plaintext(&'a str), // e.g. "foo" Plaintext(&'a str), // e.g. "foo"
Unicode(Loc<&'a str>), // e.g. "00A0" in "\u(00A0)" Unicode(Loc<&'a str>), // e.g. "00A0" in "\u(00A0)"
EscapedChar(EscapedChar), // e.g. '\n' in "Hello!\n" EscapedChar(EscapedChar), // e.g. '\n' in "Hello!\n"
Interpolated(Loc<&'a Expr<'a>>), Interpolated(Loc<&'a Expr<'a>>), // e.g. "$(expr)"
DeprecatedInterpolated(Loc<&'a Expr<'a>>), // The old "$(...)" syntax - will be removed someday
} }
#[derive(Clone, Copy, Debug, PartialEq, Eq)] #[derive(Clone, Copy, Debug, PartialEq, Eq)]
@ -379,7 +379,6 @@ impl<'a> TryFrom<StrSegment<'a>> for SingleQuoteSegment<'a> {
StrSegment::Unicode(s) => Ok(SingleQuoteSegment::Unicode(s)), StrSegment::Unicode(s) => Ok(SingleQuoteSegment::Unicode(s)),
StrSegment::EscapedChar(s) => Ok(SingleQuoteSegment::EscapedChar(s)), StrSegment::EscapedChar(s) => Ok(SingleQuoteSegment::EscapedChar(s)),
StrSegment::Interpolated(_) => Err(ESingleQuote::InterpolationNotAllowed), StrSegment::Interpolated(_) => Err(ESingleQuote::InterpolationNotAllowed),
StrSegment::DeprecatedInterpolated(_) => Err(ESingleQuote::InterpolationNotAllowed),
} }
} }
} }
@ -1313,10 +1312,10 @@ impl<'a> Defs<'a> {
self.regions.push(region); self.regions.push(region);
let before = Slice::extend_new(&mut self.spaces, spaces_before.iter().copied()); let before = slice_extend_new(&mut self.spaces, spaces_before.iter().copied());
self.space_before.push(before); self.space_before.push(before);
let after = Slice::extend_new(&mut self.spaces, spaces_after.iter().copied()); let after = slice_extend_new(&mut self.spaces, spaces_after.iter().copied());
self.space_after.push(after); self.space_after.push(after);
} }
@ -1327,7 +1326,7 @@ impl<'a> Defs<'a> {
spaces_before: &[CommentOrNewline<'a>], spaces_before: &[CommentOrNewline<'a>],
spaces_after: &[CommentOrNewline<'a>], spaces_after: &[CommentOrNewline<'a>],
) { ) {
let value_def_index = Index::push_new(&mut self.value_defs, value_def); let value_def_index = index_push_new(&mut self.value_defs, value_def);
let tag = EitherIndex::from_right(value_def_index); let tag = EitherIndex::from_right(value_def_index);
self.push_def_help(tag, region, spaces_before, spaces_after) self.push_def_help(tag, region, spaces_before, spaces_after)
} }
@ -1361,7 +1360,7 @@ impl<'a> Defs<'a> {
spaces_before: &[CommentOrNewline<'a>], spaces_before: &[CommentOrNewline<'a>],
spaces_after: &[CommentOrNewline<'a>], spaces_after: &[CommentOrNewline<'a>],
) { ) {
let type_def_index = Index::push_new(&mut self.type_defs, type_def); let type_def_index = index_push_new(&mut self.type_defs, type_def);
let tag = EitherIndex::from_left(type_def_index); let tag = EitherIndex::from_left(type_def_index);
self.push_def_help(tag, region, spaces_before, spaces_after) self.push_def_help(tag, region, spaces_before, spaces_after)
} }
@ -1376,13 +1375,13 @@ impl<'a> Defs<'a> {
for (tag_index, tag) in self.tags.iter().enumerate() { for (tag_index, tag) in self.tags.iter().enumerate() {
let region = self.regions[tag_index]; let region = self.regions[tag_index];
let space_before = { let space_before = {
let start = self.space_before[tag_index].start(); let start = self.space_before[tag_index].start() as usize;
let len = self.space_before[tag_index].len(); let len = self.space_before[tag_index].len();
&self.spaces[start..(start + len)] &self.spaces[start..(start + len)]
}; };
let space_after = { let space_after = {
let start = self.space_after[tag_index].start(); let start = self.space_after[tag_index].start() as usize;
let len = self.space_after[tag_index].len(); let len = self.space_after[tag_index].len();
&self.spaces[start..(start + len)] &self.spaces[start..(start + len)]
@ -1395,13 +1394,13 @@ impl<'a> Defs<'a> {
match tag_index.cmp(&target) { match tag_index.cmp(&target) {
std::cmp::Ordering::Less => { std::cmp::Ordering::Less => {
// before // before
let type_def_index = Index::push_new(&mut before.type_defs, type_def); let type_def_index = index_push_new(&mut before.type_defs, type_def);
let tag = EitherIndex::from_left(type_def_index); let tag = EitherIndex::from_left(type_def_index);
before.push_def_help(tag, region, space_before, space_after); before.push_def_help(tag, region, space_before, space_after);
} }
std::cmp::Ordering::Greater => { std::cmp::Ordering::Greater => {
// after // after
let type_def_index = Index::push_new(&mut after.type_defs, type_def); let type_def_index = index_push_new(&mut after.type_defs, type_def);
let tag = EitherIndex::from_left(type_def_index); let tag = EitherIndex::from_left(type_def_index);
after.push_def_help(tag, region, space_before, space_after); after.push_def_help(tag, region, space_before, space_after);
} }
@ -1417,14 +1416,14 @@ impl<'a> Defs<'a> {
std::cmp::Ordering::Less => { std::cmp::Ordering::Less => {
// before // before
let new_value_def_index = let new_value_def_index =
Index::push_new(&mut before.value_defs, value_def); index_push_new(&mut before.value_defs, value_def);
let tag = EitherIndex::from_right(new_value_def_index); let tag = EitherIndex::from_right(new_value_def_index);
before.push_def_help(tag, region, space_before, space_after); before.push_def_help(tag, region, space_before, space_after);
} }
std::cmp::Ordering::Greater => { std::cmp::Ordering::Greater => {
// after // after
let new_value_def_index = let new_value_def_index =
Index::push_new(&mut after.value_defs, value_def); index_push_new(&mut after.value_defs, value_def);
let tag = EitherIndex::from_right(new_value_def_index); let tag = EitherIndex::from_right(new_value_def_index);
after.push_def_help(tag, region, space_before, space_after); after.push_def_help(tag, region, space_before, space_after);
} }
@ -2516,9 +2515,7 @@ impl<'a> Malformed for StrSegment<'a> {
fn is_malformed(&self) -> bool { fn is_malformed(&self) -> bool {
match self { match self {
StrSegment::Plaintext(_) | StrSegment::Unicode(_) | StrSegment::EscapedChar(_) => false, StrSegment::Plaintext(_) | StrSegment::Unicode(_) | StrSegment::EscapedChar(_) => false,
StrSegment::Interpolated(expr) | StrSegment::DeprecatedInterpolated(expr) => { StrSegment::Interpolated(expr) => expr.is_malformed(),
expr.is_malformed()
}
} }
} }
} }

View file

@ -28,7 +28,7 @@ use crate::type_annotation;
use crate::{header, keyword}; use crate::{header, keyword};
use bumpalo::collections::Vec; use bumpalo::collections::Vec;
use bumpalo::Bump; use bumpalo::Bump;
use roc_collections::soa::Slice; use roc_collections::soa::slice_extend_new;
use roc_error_macros::internal_error; use roc_error_macros::internal_error;
use roc_module::called_via::{BinOp, CalledVia, UnaryOp}; use roc_module::called_via::{BinOp, CalledVia, UnaryOp};
use roc_region::all::{Loc, Position, Region}; use roc_region::all::{Loc, Position, Region};
@ -2286,7 +2286,7 @@ pub fn parse_top_level_defs<'a>(
} }
if output.tags.len() > existing_len { if output.tags.len() > existing_len {
let after = Slice::extend_new(&mut output.spaces, last_space.iter().copied()); let after = slice_extend_new(&mut output.spaces, last_space.iter().copied());
let last = output.tags.len() - 1; let last = output.tags.len() - 1;
debug_assert!(output.space_after[last].is_empty() || after.is_empty()); debug_assert!(output.space_after[last].is_empty() || after.is_empty());
output.space_after[last] = after; output.space_after[last] = after;

View file

@ -649,13 +649,6 @@ fn normalize_str_segments<'a>(
} }
new_segments.push(StrSegment::Interpolated(e.normalize(arena))); new_segments.push(StrSegment::Interpolated(e.normalize(arena)));
} }
StrSegment::DeprecatedInterpolated(e) => {
if !last_text.is_empty() {
let text = std::mem::replace(last_text, String::new_in(arena));
new_segments.push(StrSegment::Plaintext(text.into_bump_str()));
}
new_segments.push(StrSegment::Interpolated(e.normalize(arena)));
}
} }
} }
} }
@ -680,7 +673,6 @@ impl<'a> Normalize<'a> for StrSegment<'a> {
StrSegment::Unicode(t) => StrSegment::Unicode(t.normalize(arena)), StrSegment::Unicode(t) => StrSegment::Unicode(t.normalize(arena)),
StrSegment::EscapedChar(c) => StrSegment::EscapedChar(c), StrSegment::EscapedChar(c) => StrSegment::EscapedChar(c),
StrSegment::Interpolated(t) => StrSegment::Interpolated(t.normalize(arena)), StrSegment::Interpolated(t) => StrSegment::Interpolated(t.normalize(arena)),
StrSegment::DeprecatedInterpolated(t) => StrSegment::Interpolated(t.normalize(arena)),
} }
} }
} }

View file

@ -364,36 +364,6 @@ pub fn parse_str_like_literal<'a>() -> impl Parser<'a, StrLikeLiteral<'a>, EStri
// This is the start of a new escape. Look at the next byte // This is the start of a new escape. Look at the next byte
// to figure out what type of escape it is. // to figure out what type of escape it is.
match bytes.next() { match bytes.next() {
Some(b'(') => {
// Advance past the `\(` before using the expr parser
state.advance_mut(2);
let original_byte_count = state.bytes().len();
// This is an interpolated variable.
// Parse an arbitrary expression, then give a
// canonicalization error if that expression variant
// is not allowed inside a string interpolation.
let (_progress, loc_expr, new_state) = skip_second(
specialize_err_ref(
EString::Format,
loc(allocated(reset_min_indent(expr::expr_help()))),
),
byte(b')', EString::FormatEnd),
)
.parse(arena, state, min_indent)?;
// Advance the iterator past the expr we just parsed.
for _ in 0..(original_byte_count - new_state.bytes().len()) {
bytes.next();
}
segments.push(StrSegment::DeprecatedInterpolated(loc_expr));
// Reset the segment
segment_parsed_bytes = 0;
state = new_state;
}
Some(b'u') => { Some(b'u') => {
// Advance past the `\u` before using the expr parser // Advance past the `\u` before using the expr parser
state.advance_mut(2); state.advance_mut(2);
@ -444,8 +414,8 @@ pub fn parse_str_like_literal<'a>() -> impl Parser<'a, StrLikeLiteral<'a>, EStri
} }
_ => { _ => {
// Invalid escape! A backslash must be followed // Invalid escape! A backslash must be followed
// by either an open paren or else one of the // by one of these escapable characters:
// escapable characters (\n, \t, \", \\, etc) // (\n, \t, \", \\, etc)
return Err((MadeProgress, EString::UnknownEscape(state.pos()))); return Err((MadeProgress, EString::UnknownEscape(state.pos())));
} }
} }

View file

@ -27,6 +27,8 @@ roc_unify = { path = "../unify" }
arrayvec.workspace = true arrayvec.workspace = true
bumpalo.workspace = true bumpalo.workspace = true
soa.workspace = true
[dev-dependencies] [dev-dependencies]
roc_builtins = { path = "../builtins" } roc_builtins = { path = "../builtins" }
roc_derive = { path = "../derive", features = ["debug-derived-symbols"] } roc_derive = { path = "../derive", features = ["debug-derived-symbols"] }

View file

@ -1,5 +1,5 @@
use roc_can::abilities::AbilitiesStore; use roc_can::abilities::AbilitiesStore;
use roc_collections::{soa::Index, MutMap}; use roc_collections::{soa::slice_extend_new, MutMap};
use roc_error_macros::internal_error; use roc_error_macros::internal_error;
use roc_module::symbol::Symbol; use roc_module::symbol::Symbol;
use roc_solve_problem::TypeError; use roc_solve_problem::TypeError;
@ -7,6 +7,7 @@ use roc_types::{
subs::{AliasVariables, Content, FlatType, Rank, Subs, SubsSlice, TagExt, UnionTags, Variable}, subs::{AliasVariables, Content, FlatType, Rank, Subs, SubsSlice, TagExt, UnionTags, Variable},
types::{Alias, AliasKind, OptAbleVar, Type, TypeTag, Types}, types::{Alias, AliasKind, OptAbleVar, Type, TypeTag, Types},
}; };
use soa::Index;
use crate::to_var::type_to_var_help; use crate::to_var::type_to_var_help;
use crate::{ability::ObligationCache, env::InferenceEnv}; use crate::{ability::ObligationCache, env::InferenceEnv};
@ -131,7 +132,7 @@ impl Aliases {
let ok_slice = SubsSlice::new(alias_variables.variables_start, 1); let ok_slice = SubsSlice::new(alias_variables.variables_start, 1);
let variable_slices = let variable_slices =
SubsSlice::extend_new(&mut env.subs.variable_slices, [err_slice, ok_slice]); slice_extend_new(&mut env.subs.variable_slices, [err_slice, ok_slice]);
let union_tags = UnionTags::from_slices(tag_names_slice, variable_slices); let union_tags = UnionTags::from_slices(tag_names_slice, variable_slices);
let ext_var = TagExt::Any(Variable::EMPTY_TAG_UNION); let ext_var = TagExt::Any(Variable::EMPTY_TAG_UNION);

View file

@ -1,11 +1,12 @@
use std::ops::ControlFlow; use std::ops::ControlFlow;
use bumpalo::Bump; use bumpalo::Bump;
use roc_collections::soa::slice_extend_new;
use roc_error_macros::internal_error; use roc_error_macros::internal_error;
use roc_types::{ use roc_types::{
subs::{ subs::{
self, AliasVariables, Content, Descriptor, FlatType, GetSubsSlice, Mark, OptVariable, Rank, self, AliasVariables, Content, Descriptor, FlatType, GetSubsSlice, Mark, OptVariable, Rank,
RecordFields, Subs, SubsSlice, TagExt, TupleElems, UnionLabels, Variable, RecordFields, Subs, TagExt, TupleElems, UnionLabels, Variable,
}, },
types::{RecordField, Uls}, types::{RecordField, Uls},
}; };
@ -121,7 +122,7 @@ fn deep_copy_var_help(
macro_rules! copy_sequence { macro_rules! copy_sequence {
($length:expr, $variables:expr) => {{ ($length:expr, $variables:expr) => {{
let new_variables = SubsSlice::reserve_into_subs(subs, $length as _); let new_variables = subs.reserve_into_vars($length as _);
for (target_index, var_index) in (new_variables.indices()).zip($variables) { for (target_index, var_index) in (new_variables.indices()).zip($variables) {
let var = subs[var_index]; let var = subs[var_index];
let copy_var = work!(var); let copy_var = work!(var);
@ -134,7 +135,7 @@ fn deep_copy_var_help(
macro_rules! copy_union { macro_rules! copy_union {
($tags:expr) => {{ ($tags:expr) => {{
let new_variable_slices = SubsSlice::reserve_variable_slices(subs, $tags.len()); let new_variable_slices = subs.reserve_variable_slices($tags.len());
let it = (new_variable_slices.indices()).zip($tags.variables()); let it = (new_variable_slices.indices()).zip($tags.variables());
for (target_index, index) in it { for (target_index, index) in it {
@ -201,7 +202,7 @@ fn deep_copy_var_help(
let new_field_types_start = if has_rigid_optional_field { let new_field_types_start = if has_rigid_optional_field {
let field_types = field_types.to_vec(); let field_types = field_types.to_vec();
let slice = SubsSlice::extend_new( let slice = slice_extend_new(
&mut subs.record_fields, &mut subs.record_fields,
field_types.into_iter().map(|f| match f { field_types.into_iter().map(|f| match f {
RecordField::RigidOptional(()) RecordField::RigidOptional(())
@ -212,7 +213,7 @@ fn deep_copy_var_help(
| RecordField::Optional(_) => f, | RecordField::Optional(_) => f,
}), }),
); );
slice.start slice.start()
} else { } else {
fields.field_types_start fields.field_types_start
}; };
@ -220,7 +221,7 @@ fn deep_copy_var_help(
RecordFields { RecordFields {
length: fields.length, length: fields.length,
field_names_start: fields.field_names_start, field_names_start: fields.field_names_start,
variables_start: new_variables.start, variables_start: new_variables.start(),
field_types_start: new_field_types_start, field_types_start: new_field_types_start,
} }
}; };
@ -234,7 +235,7 @@ fn deep_copy_var_help(
TupleElems { TupleElems {
length: elems.length, length: elems.length,
variables_start: new_variables.start, variables_start: new_variables.start(),
elem_index_start: elems.elem_index_start, elem_index_start: elems.elem_index_start,
} }
}; };
@ -291,7 +292,7 @@ fn deep_copy_var_help(
copy_sequence!(arguments.all_variables_len, arguments.all_variables()); copy_sequence!(arguments.all_variables_len, arguments.all_variables());
let new_arguments = AliasVariables { let new_arguments = AliasVariables {
variables_start: new_variables.start, variables_start: new_variables.start(),
..arguments ..arguments
}; };
@ -311,7 +312,7 @@ fn deep_copy_var_help(
let new_solved = copy_union!(solved); let new_solved = copy_union!(solved);
let new_rec_var = recursion_var.map(|v| work!(v)); let new_rec_var = recursion_var.map(|v| work!(v));
let new_unspecialized = SubsSlice::reserve_uls_slice(subs, unspecialized.len()); let new_unspecialized = subs.reserve_uls_slice(unspecialized.len());
for (new_uls_index, uls_index) in for (new_uls_index, uls_index) in
(new_unspecialized.into_iter()).zip(unspecialized.into_iter()) (new_unspecialized.into_iter()).zip(unspecialized.into_iter())

View file

@ -3,7 +3,7 @@
use std::collections::VecDeque; use std::collections::VecDeque;
use roc_can::abilities::{AbilitiesStore, ImplKey}; use roc_can::abilities::{AbilitiesStore, ImplKey};
use roc_collections::{VecMap, VecSet}; use roc_collections::{soa::slice_extend_new, VecMap, VecSet};
use roc_debug_flags::dbg_do; use roc_debug_flags::dbg_do;
#[cfg(debug_assertions)] #[cfg(debug_assertions)]
use roc_debug_flags::ROC_TRACE_COMPACTION; use roc_debug_flags::ROC_TRACE_COMPACTION;
@ -14,7 +14,7 @@ use roc_solve_schema::UnificationMode;
use roc_types::{ use roc_types::{
subs::{ subs::{
get_member_lambda_sets_at_region, Content, Descriptor, GetSubsSlice, LambdaSet, Mark, get_member_lambda_sets_at_region, Content, Descriptor, GetSubsSlice, LambdaSet, Mark,
OptVariable, Rank, Subs, SubsSlice, UlsOfVar, Variable, OptVariable, Rank, Subs, UlsOfVar, Variable,
}, },
types::{AliasKind, MemberImpl, Polarity, Uls}, types::{AliasKind, MemberImpl, Polarity, Uls},
}; };
@ -360,7 +360,7 @@ pub fn compact_lambda_sets_of_vars<P: Phase>(
// The first lambda set contains one concrete lambda, plus all solved // The first lambda set contains one concrete lambda, plus all solved
// lambdas, plus all other unspecialized lambdas. // lambdas, plus all other unspecialized lambdas.
// l' = [solved_lambdas + t1 + ... + tm + C:f:r] // l' = [solved_lambdas + t1 + ... + tm + C:f:r]
let unspecialized = SubsSlice::extend_new( let unspecialized = slice_extend_new(
&mut env.subs.unspecialized_lambda_sets, &mut env.subs.unspecialized_lambda_sets,
not_concrete not_concrete
.drain(..) .drain(..)
@ -371,7 +371,7 @@ pub fn compact_lambda_sets_of_vars<P: Phase>(
// All the other lambda sets consists only of their respective concrete // All the other lambda sets consists only of their respective concrete
// lambdas. // lambdas.
// ln = [[] + C:fn:rn] // ln = [[] + C:fn:rn]
let unspecialized = SubsSlice::extend_new( let unspecialized = slice_extend_new(
&mut env.subs.unspecialized_lambda_sets, &mut env.subs.unspecialized_lambda_sets,
[concrete_lambda], [concrete_lambda],
); );
@ -521,10 +521,7 @@ fn compact_lambda_set<P: Phase>(
let t_f1_lambda_set_without_concrete = LambdaSet { let t_f1_lambda_set_without_concrete = LambdaSet {
solved, solved,
recursion_var, recursion_var,
unspecialized: SubsSlice::extend_new( unspecialized: slice_extend_new(&mut env.subs.unspecialized_lambda_sets, new_unspecialized),
&mut env.subs.unspecialized_lambda_sets,
new_unspecialized,
),
ambient_function: t_f1, ambient_function: t_f1,
}; };
env.subs.set_content( env.subs.set_content(

View file

@ -1,7 +1,7 @@
use std::cell::RefCell; use std::cell::RefCell;
use roc_can::{abilities::AbilitiesStore, constraint::TypeOrVar, expected::Expected}; use roc_can::{abilities::AbilitiesStore, constraint::TypeOrVar, expected::Expected};
use roc_collections::soa::{Index, Slice}; use roc_collections::soa::slice_extend_new;
use roc_error_macros::internal_error; use roc_error_macros::internal_error;
use roc_module::{ident::TagName, symbol::Symbol}; use roc_module::{ident::TagName, symbol::Symbol};
use roc_region::all::Loc; use roc_region::all::Loc;
@ -19,6 +19,7 @@ use roc_types::{
}, },
}; };
use roc_unify::unify::{unify, Unified}; use roc_unify::unify::{unify, Unified};
use soa::{Index, Slice};
use crate::{ use crate::{
ability::{AbilityImplError, ObligationCache}, ability::{AbilityImplError, ObligationCache},
@ -329,7 +330,7 @@ pub(crate) fn type_to_var_help(
region: _, region: _,
} => { } => {
let arguments = types.get_type_arguments(typ_index); let arguments = types.get_type_arguments(typ_index);
let new_arguments = VariableSubsSlice::reserve_into_subs(env.subs, arguments.len()); let new_arguments = env.subs.reserve_into_vars(arguments.len());
for (target_index, var_index) in for (target_index, var_index) in
(new_arguments.indices()).zip(arguments.into_iter()) (new_arguments.indices()).zip(arguments.into_iter())
{ {
@ -372,7 +373,7 @@ pub(crate) fn type_to_var_help(
} }
} }
UnspecializedLambdaSet { unspecialized } => { UnspecializedLambdaSet { unspecialized } => {
let unspecialized_slice = SubsSlice::extend_new( let unspecialized_slice = slice_extend_new(
&mut env.subs.unspecialized_lambda_sets, &mut env.subs.unspecialized_lambda_sets,
std::iter::once(unspecialized), std::iter::once(unspecialized),
); );
@ -403,7 +404,7 @@ pub(crate) fn type_to_var_help(
// This case is important for the rank of boolean variables // This case is important for the rank of boolean variables
Function(closure_type, ret_type) => { Function(closure_type, ret_type) => {
let arguments = types.get_type_arguments(typ_index); let arguments = types.get_type_arguments(typ_index);
let new_arguments = VariableSubsSlice::reserve_into_subs(env.subs, arguments.len()); let new_arguments = env.subs.reserve_into_vars(arguments.len());
for (target_index, var_index) in for (target_index, var_index) in
(new_arguments.indices()).zip(arguments.into_iter()) (new_arguments.indices()).zip(arguments.into_iter())
{ {
@ -545,8 +546,8 @@ pub(crate) fn type_to_var_help(
unreachable!("we assert that the ext var is empty; otherwise we'd already know it was a tag union!"); unreachable!("we assert that the ext var is empty; otherwise we'd already know it was a tag union!");
} }
let tag_names = SubsSlice::extend_new(&mut env.subs.tag_names, [tag_name]); let tag_names = slice_extend_new(&mut env.subs.tag_names, [tag_name]);
let symbols = SubsSlice::extend_new(&mut env.subs.symbol_names, [symbol]); let symbols = slice_extend_new(&mut env.subs.symbol_names, [symbol]);
let content = let content =
Content::Structure(FlatType::FunctionOrTagUnion(tag_names, symbols, ext)); Content::Structure(FlatType::FunctionOrTagUnion(tag_names, symbols, ext));
@ -603,8 +604,7 @@ pub(crate) fn type_to_var_help(
let all_vars_length = type_arguments.len() let all_vars_length = type_arguments.len()
+ lambda_set_variables.len() + lambda_set_variables.len()
+ infer_ext_in_output_variables.len(); + infer_ext_in_output_variables.len();
let new_variables = let new_variables = env.subs.reserve_into_vars(all_vars_length);
VariableSubsSlice::reserve_into_subs(env.subs, all_vars_length);
let type_arguments_offset = 0; let type_arguments_offset = 0;
let lambda_set_vars_offset = type_arguments_offset + type_arguments.len(); let lambda_set_vars_offset = type_arguments_offset + type_arguments.len();
@ -652,7 +652,7 @@ pub(crate) fn type_to_var_help(
} }
AliasVariables { AliasVariables {
variables_start: new_variables.start, variables_start: new_variables.start(),
type_variables_len: type_arguments.len() as _, type_variables_len: type_arguments.len() as _,
lambda_set_variables_len: lambda_set_variables.len() as _, lambda_set_variables_len: lambda_set_variables.len() as _,
all_variables_len: all_vars_length as _, all_variables_len: all_vars_length as _,
@ -704,8 +704,7 @@ pub(crate) fn type_to_var_help(
let lambda_set_vars_offset = type_arguments_offset + type_arguments.len(); let lambda_set_vars_offset = type_arguments_offset + type_arguments.len();
let infer_ext_vars_offset = lambda_set_vars_offset + lambda_set_variables.len(); let infer_ext_vars_offset = lambda_set_vars_offset + lambda_set_variables.len();
let new_variables = let new_variables = env.subs.reserve_into_vars(all_vars_length);
VariableSubsSlice::reserve_into_subs(env.subs, all_vars_length);
for (((target_index, typ), region), abilities) in for (((target_index, typ), region), abilities) in
(new_variables.indices().skip(type_arguments_offset)) (new_variables.indices().skip(type_arguments_offset))
@ -736,7 +735,7 @@ pub(crate) fn type_to_var_help(
} }
AliasVariables { AliasVariables {
variables_start: new_variables.start, variables_start: new_variables.start(),
type_variables_len: type_arguments.len() as _, type_variables_len: type_arguments.len() as _,
lambda_set_variables_len: lambda_set_variables.len() as _, lambda_set_variables_len: lambda_set_variables.len() as _,
all_variables_len: all_vars_length as _, all_variables_len: all_vars_length as _,
@ -765,10 +764,8 @@ pub(crate) fn type_to_var_help(
match *env.subs.get_content_unchecked(var) { match *env.subs.get_content_unchecked(var) {
Content::RigidVar(a) => { Content::RigidVar(a) => {
// TODO(multi-abilities): check run cache // TODO(multi-abilities): check run cache
let abilities_slice = SubsSlice::extend_new( let abilities_slice =
&mut env.subs.symbol_names, slice_extend_new(&mut env.subs.symbol_names, abilities.sorted_iter().copied());
abilities.sorted_iter().copied(),
);
env.subs env.subs
.set_content(var, Content::RigidAbleVar(a, abilities_slice)); .set_content(var, Content::RigidAbleVar(a, abilities_slice));
} }
@ -778,10 +775,8 @@ pub(crate) fn type_to_var_help(
// pass, already bound // pass, already bound
} }
_ => { _ => {
let abilities_slice = SubsSlice::extend_new( let abilities_slice =
&mut env.subs.symbol_names, slice_extend_new(&mut env.subs.symbol_names, abilities.sorted_iter().copied());
abilities.sorted_iter().copied(),
);
let flex_ability = env.register(rank, Content::FlexAbleVar(None, abilities_slice)); let flex_ability = env.register(rank, Content::FlexAbleVar(None, abilities_slice));
@ -969,7 +964,7 @@ fn find_tag_name_run(slice: &[TagName], subs: &mut Subs) -> Option<SubsSlice<Tag
Some(occupied) => { Some(occupied) => {
let subs_slice = *occupied; let subs_slice = *occupied;
let prefix_slice = SubsSlice::new(subs_slice.start, slice.len() as _); let prefix_slice = SubsSlice::new(subs_slice.start(), slice.len() as _);
if slice.len() == 1 { if slice.len() == 1 {
return Some(prefix_slice); return Some(prefix_slice);
@ -978,7 +973,7 @@ fn find_tag_name_run(slice: &[TagName], subs: &mut Subs) -> Option<SubsSlice<Tag
match slice.len().cmp(&subs_slice.len()) { match slice.len().cmp(&subs_slice.len()) {
Ordering::Less => { Ordering::Less => {
// we might have a prefix // we might have a prefix
let tag_names = &subs.tag_names[subs_slice.start as usize..]; let tag_names = &subs.tag_names[subs_slice.start() as usize..];
for (from_subs, from_slice) in tag_names.iter().zip(slice.iter()) { for (from_subs, from_slice) in tag_names.iter().zip(slice.iter()) {
if from_subs != from_slice { if from_subs != from_slice {
@ -1025,8 +1020,8 @@ fn register_tag_arguments(
if arguments.is_empty() { if arguments.is_empty() {
VariableSubsSlice::default() VariableSubsSlice::default()
} else { } else {
let new_variables = VariableSubsSlice::reserve_into_subs(env.subs, arguments.len()); let new_variables = env.subs.reserve_into_vars(arguments.len());
let it = new_variables.indices().zip(arguments.into_iter()); let it = new_variables.indices().zip(arguments);
for (target_index, argument) in it { for (target_index, argument) in it {
let var = RegisterVariable::with_stack(env, rank, arena, types, argument, stack); let var = RegisterVariable::with_stack(env, rank, arena, types, argument, stack);
@ -1056,8 +1051,7 @@ fn insert_tags_fast_path(
let variable_slice = let variable_slice =
register_tag_arguments(env, rank, arena, types, stack, arguments_slice); register_tag_arguments(env, rank, arena, types, stack, arguments_slice);
let new_variable_slices = let new_variable_slices = slice_extend_new(&mut env.subs.variable_slices, [variable_slice]);
SubsSlice::extend_new(&mut env.subs.variable_slices, [variable_slice]);
macro_rules! subs_tag_name { macro_rules! subs_tag_name {
($tag_name_slice:expr) => { ($tag_name_slice:expr) => {
@ -1075,10 +1069,10 @@ fn insert_tags_fast_path(
} }
} }
let new_variable_slices = SubsSlice::reserve_variable_slices(env.subs, tags.len()); let new_variable_slices = env.subs.reserve_variable_slices(tags.len());
match find_tag_name_run(&types[tags], env.subs) { match find_tag_name_run(&types[tags], env.subs) {
Some(new_tag_names) => { Some(new_tag_names) => {
let it = (new_variable_slices.indices()).zip(payload_slices.into_iter()); let it = (new_variable_slices.indices()).zip(payload_slices);
for (variable_slice_index, arguments_index) in it { for (variable_slice_index, arguments_index) in it {
let arguments = types[arguments_index]; let arguments = types[arguments_index];
@ -1089,12 +1083,12 @@ fn insert_tags_fast_path(
UnionTags::from_slices(new_tag_names, new_variable_slices) UnionTags::from_slices(new_tag_names, new_variable_slices)
} }
None => { None => {
let new_tag_names = SubsSlice::reserve_tag_names(env.subs, tags.len()); let new_tag_names = env.subs.reserve_tag_names(tags.len());
let it = (new_variable_slices.indices()) let it = (new_variable_slices.indices())
.zip(new_tag_names.indices()) .zip(new_tag_names.indices())
.zip(tags.into_iter()) .zip(tags)
.zip(payload_slices.into_iter()); .zip(payload_slices);
for (((variable_slice_index, tag_name_index), tag_name), arguments_index) in it { for (((variable_slice_index, tag_name_index), tag_name), arguments_index) in it {
let arguments = types[arguments_index]; let arguments = types[arguments_index];
@ -1124,7 +1118,7 @@ fn insert_tags_slow_path(
{ {
let tag_argument_types = &types[tag_argument_types_index]; let tag_argument_types = &types[tag_argument_types_index];
let new_slice = VariableSubsSlice::reserve_into_subs(env.subs, tag_argument_types.len()); let new_slice = env.subs.reserve_into_vars(tag_argument_types.len());
for (i, arg) in (new_slice.indices()).zip(tag_argument_types.into_iter()) { for (i, arg) in (new_slice.indices()).zip(tag_argument_types.into_iter()) {
let var = RegisterVariable::with_stack(env, rank, arena, types, arg, stack); let var = RegisterVariable::with_stack(env, rank, arena, types, arg, stack);
@ -1208,10 +1202,9 @@ fn create_union_lambda(
stack: &mut bumpalo::collections::Vec<'_, TypeToVar>, stack: &mut bumpalo::collections::Vec<'_, TypeToVar>,
) -> UnionLambdas { ) -> UnionLambdas {
let variable_slice = register_tag_arguments(env, rank, arena, types, stack, capture_types); let variable_slice = register_tag_arguments(env, rank, arena, types, stack, capture_types);
let new_variable_slices = let new_variable_slices = slice_extend_new(&mut env.subs.variable_slices, [variable_slice]);
SubsSlice::extend_new(&mut env.subs.variable_slices, [variable_slice]);
let lambda_name_slice = SubsSlice::extend_new(&mut env.subs.symbol_names, [closure]); let lambda_name_slice = slice_extend_new(&mut env.subs.symbol_names, [closure]);
UnionLambdas::from_slices(lambda_name_slice, new_variable_slices) UnionLambdas::from_slices(lambda_name_slice, new_variable_slices)
} }

View file

@ -17,7 +17,10 @@ roc_can = { path = "../can" }
roc_collections = { path = "../collections" } roc_collections = { path = "../collections" }
roc_constrain = { path = "../constrain" } roc_constrain = { path = "../constrain" }
roc_debug_flags = { path = "../debug_flags" } roc_debug_flags = { path = "../debug_flags" }
roc_derive = { path = "../derive", features = ["debug-derived-symbols", "open-extension-vars"] } roc_derive = { path = "../derive", features = [
"debug-derived-symbols",
"open-extension-vars",
] }
roc_derive_key = { path = "../derive_key" } roc_derive_key = { path = "../derive_key" }
roc_load_internal = { path = "../load_internal" } roc_load_internal = { path = "../load_internal" }
roc_module = { path = "../module" } roc_module = { path = "../module" }

View file

@ -1,12 +1,11 @@
use std::fmt::Write as _; // import without risk of name clashing
use std::path::PathBuf;
use bumpalo::Bump; use bumpalo::Bump;
use roc_packaging::cache::RocCacheDir; use roc_packaging::cache::RocCacheDir;
use roc_solve::{ use roc_solve::{
module::{SolveConfig, SolveOutput}, module::{SolveConfig, SolveOutput},
FunctionKind, FunctionKind,
}; };
use std::fmt::Write as _;
use std::path::PathBuf;
use ven_pretty::DocAllocator; use ven_pretty::DocAllocator;
use roc_can::{ use roc_can::{
@ -116,12 +115,12 @@ macro_rules! v {
} }
}}; }};
([ $($tag:ident $($payload:expr)*),* ] as $rec_var:ident) => {{ ([ $($tag:ident $($payload:expr)*),* ] as $rec_var:ident) => {{
use roc_types::subs::{Subs, SubsIndex, Variable, Content, FlatType, TagExt, UnionTags}; use roc_types::subs::{Subs, Variable, Content, FlatType, TagExt, UnionTags};
use roc_module::ident::TagName; use roc_module::ident::TagName;
|subs: &mut Subs| { |subs: &mut Subs| {
let $rec_var = subs.fresh_unnamed_flex_var(); let $rec_var = subs.fresh_unnamed_flex_var();
let rec_name_index = let rec_name_index =
SubsIndex::push_new(&mut subs.field_names, stringify!($rec).into()); roc_collections::soa::index_push_new(&mut subs.field_names, stringify!($rec).into());
$( $(
let $tag = vec![ $( $payload(subs), )* ]; let $tag = vec![ $( $payload(subs), )* ];
@ -158,11 +157,11 @@ macro_rules! v {
} }
}}; }};
(Symbol::$sym:ident $($arg:expr)*) => {{ (Symbol::$sym:ident $($arg:expr)*) => {{
use roc_types::subs::{Subs, SubsSlice, Content, FlatType}; use roc_types::subs::{Subs, Content, FlatType};
use roc_module::symbol::Symbol; use roc_module::symbol::Symbol;
|subs: &mut Subs| { |subs: &mut Subs| {
let $sym = vec![ $( $arg(subs) ,)* ]; let $sym = vec![ $( $arg(subs) ,)* ];
let var_slice = SubsSlice::insert_into_subs(subs, $sym); let var_slice = subs.insert_into_vars($sym);
roc_derive::synth_var(subs, Content::Structure(FlatType::Apply(Symbol::$sym, var_slice))) roc_derive::synth_var(subs, Content::Structure(FlatType::Apply(Symbol::$sym, var_slice)))
} }
}}; }};
@ -193,12 +192,12 @@ macro_rules! v {
|subs: &mut Subs| { roc_derive::synth_var(subs, Content::FlexVar(None)) } |subs: &mut Subs| { roc_derive::synth_var(subs, Content::FlexVar(None)) }
}}; }};
($name:ident implements $ability:path) => {{ ($name:ident implements $ability:path) => {{
use roc_types::subs::{Subs, SubsIndex, SubsSlice, Content}; use roc_types::subs::{Subs, Content};
|subs: &mut Subs| { |subs: &mut Subs| {
let name_index = let name_index =
SubsIndex::push_new(&mut subs.field_names, stringify!($name).into()); roc_collections::soa::index_push_new(&mut subs.field_names, stringify!($name).into());
let abilities_slice = SubsSlice::extend_new(&mut subs.symbol_names, [$ability]); let abilities_slice = roc_collections::soa::slice_extend_new(&mut subs.symbol_names, [$ability]);
roc_derive::synth_var(subs, Content::FlexAbleVar(Some(name_index), abilities_slice)) roc_derive::synth_var(subs, Content::FlexAbleVar(Some(name_index), abilities_slice))
} }

View file

@ -1605,20 +1605,21 @@ fn tail_call_elimination() {
); );
} }
#[test]
#[cfg(feature = "gen-dev")]
fn int_negate_dev() {
// TODO
// dev backend yet to have `Num.maxI64` or `Num.minI64`.
// add the "gen-dev" feature to the test below after implementing them both.
assert_evals_to!("Num.neg 123", -123, i64);
assert_evals_to!("Num.neg -123", 123, i64);
assert_evals_to!("Num.neg 0", 0, i64);
}
#[test] #[test]
#[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))] #[cfg(any(feature = "gen-llvm", feature = "gen-wasm", feature = "gen-dev"))]
fn int_negate() { fn int_negate() {
assert_evals_to!("Num.neg 123i8", -123, i8);
assert_evals_to!("Num.neg Num.maxI8", -i8::MAX, i8);
assert_evals_to!("Num.neg (Num.minI8 + 1)", i8::MAX, i8);
assert_evals_to!("Num.neg 123i16", -123, i16);
assert_evals_to!("Num.neg Num.maxI16", -i16::MAX, i16);
assert_evals_to!("Num.neg (Num.minI16 + 1)", i16::MAX, i16);
assert_evals_to!("Num.neg 123i32", -123, i32);
assert_evals_to!("Num.neg Num.maxI32", -i32::MAX, i32);
assert_evals_to!("Num.neg (Num.minI32 + 1)", i32::MAX, i32);
assert_evals_to!("Num.neg 123", -123, i64); assert_evals_to!("Num.neg 123", -123, i64);
assert_evals_to!("Num.neg Num.maxI64", -i64::MAX, i64); assert_evals_to!("Num.neg Num.maxI64", -i64::MAX, i64);
assert_evals_to!("Num.neg (Num.minI64 + 1)", i64::MAX, i64); assert_evals_to!("Num.neg (Num.minI64 + 1)", i64::MAX, i64);

View file

@ -540,6 +540,7 @@ pub fn try_run_lib_function<T>(
} }
} }
#[allow(dead_code)]
// only used in tests // only used in tests
pub(crate) fn llvm_evals_to<T, U, F>( pub(crate) fn llvm_evals_to<T, U, F>(
src: &str, src: &str,
@ -589,6 +590,7 @@ pub(crate) fn llvm_evals_to<T, U, F>(
} }
} }
#[allow(unused_macros)]
macro_rules! assert_llvm_evals_to { macro_rules! assert_llvm_evals_to {
($src:expr, $expected:expr, $ty:ty, $transform:expr, $ignore_problems:expr) => { ($src:expr, $expected:expr, $ty:ty, $transform:expr, $ignore_problems:expr) => {
crate::helpers::llvm::llvm_evals_to::<$ty, _, _>( crate::helpers::llvm::llvm_evals_to::<$ty, _, _>(
@ -653,6 +655,7 @@ macro_rules! assert_evals_to {
}}; }};
} }
#[allow(unused_macros)]
macro_rules! assert_evals_to_erased { macro_rules! assert_evals_to_erased {
($src:expr, $expected:expr, $ty:ty) => {{ ($src:expr, $expected:expr, $ty:ty) => {{
crate::helpers::llvm::llvm_evals_to::<$ty, _, _>( crate::helpers::llvm::llvm_evals_to::<$ty, _, _>(
@ -665,12 +668,16 @@ macro_rules! assert_evals_to_erased {
}}; }};
} }
#[allow(dead_code)]
pub fn identity<T>(value: T) -> T { pub fn identity<T>(value: T) -> T {
value value
} }
#[allow(unused_imports)]
pub(crate) use assert_evals_to; pub(crate) use assert_evals_to;
#[allow(unused_imports)]
pub(crate) use assert_evals_to_erased; pub(crate) use assert_evals_to_erased;
#[allow(unused_imports)]
pub(crate) use assert_llvm_evals_to; pub(crate) use assert_llvm_evals_to;
#[cfg(feature = "gen-llvm-wasm")] #[cfg(feature = "gen-llvm-wasm")]
pub(crate) use assert_wasm_evals_to; pub(crate) use assert_wasm_evals_to;

View file

@ -0,0 +1 @@
Expr(Str(UnknownEscape(@1), @0), @0)

View file

@ -1,16 +1,16 @@
Defs( Defs(
Defs { Defs {
tags: [ tags: [
Index(0), EitherIndex(0),
], ],
regions: [ regions: [
@0-3, @0-3,
], ],
space_before: [ space_before: [
Slice(start = 0, length = 0), Slice { start: 0, length: 0 },
], ],
space_after: [ space_after: [
Slice(start = 0, length = 0), Slice { start: 0, length: 0 },
], ],
spaces: [], spaces: [],
type_defs: [ type_defs: [

View file

@ -2,16 +2,16 @@ SpaceAfter(
Defs( Defs(
Defs { Defs {
tags: [ tags: [
Index(0), EitherIndex(0),
], ],
regions: [ regions: [
@0-43, @0-43,
], ],
space_before: [ space_before: [
Slice(start = 0, length = 0), Slice { start: 0, length: 0 },
], ],
space_after: [ space_after: [
Slice(start = 0, length = 0), Slice { start: 0, length: 0 },
], ],
spaces: [], spaces: [],
type_defs: [ type_defs: [

View file

@ -2,16 +2,16 @@ SpaceAfter(
Defs( Defs(
Defs { Defs {
tags: [ tags: [
Index(0), EitherIndex(0),
], ],
regions: [ regions: [
@0-52, @0-52,
], ],
space_before: [ space_before: [
Slice(start = 0, length = 0), Slice { start: 0, length: 0 },
], ],
space_after: [ space_after: [
Slice(start = 0, length = 0), Slice { start: 0, length: 0 },
], ],
spaces: [], spaces: [],
type_defs: [ type_defs: [

View file

@ -2,16 +2,16 @@ SpaceAfter(
Defs( Defs(
Defs { Defs {
tags: [ tags: [
Index(0), EitherIndex(0),
], ],
regions: [ regions: [
@0-55, @0-55,
], ],
space_before: [ space_before: [
Slice(start = 0, length = 0), Slice { start: 0, length: 0 },
], ],
space_after: [ space_after: [
Slice(start = 0, length = 0), Slice { start: 0, length: 0 },
], ],
spaces: [], spaces: [],
type_defs: [ type_defs: [

View file

@ -2,20 +2,20 @@ SpaceAfter(
Defs( Defs(
Defs { Defs {
tags: [ tags: [
Index(0), EitherIndex(0),
Index(1), EitherIndex(1),
], ],
regions: [ regions: [
@0-51, @0-51,
@53-104, @53-104,
], ],
space_before: [ space_before: [
Slice(start = 0, length = 0), Slice { start: 0, length: 0 },
Slice(start = 0, length = 2), Slice { start: 0, length: 2 },
], ],
space_after: [ space_after: [
Slice(start = 0, length = 0), Slice { start: 0, length: 0 },
Slice(start = 2, length = 0), Slice { start: 2, length: 0 },
], ],
spaces: [ spaces: [
Newline, Newline,

View file

@ -1,16 +1,16 @@
Defs( Defs(
Defs { Defs {
tags: [ tags: [
Index(2147483648), EitherIndex(2147483648),
], ],
regions: [ regions: [
@0-38, @0-38,
], ],
space_before: [ space_before: [
Slice(start = 0, length = 0), Slice { start: 0, length: 0 },
], ],
space_after: [ space_after: [
Slice(start = 0, length = 0), Slice { start: 0, length: 0 },
], ],
spaces: [], spaces: [],
type_defs: [], type_defs: [],

View file

@ -1,16 +1,16 @@
Defs( Defs(
Defs { Defs {
tags: [ tags: [
Index(2147483648), EitherIndex(2147483648),
], ],
regions: [ regions: [
@0-39, @0-39,
], ],
space_before: [ space_before: [
Slice(start = 0, length = 0), Slice { start: 0, length: 0 },
], ],
space_after: [ space_after: [
Slice(start = 0, length = 0), Slice { start: 0, length: 0 },
], ],
spaces: [], spaces: [],
type_defs: [], type_defs: [],

View file

@ -2,16 +2,16 @@ SpaceAfter(
Defs( Defs(
Defs { Defs {
tags: [ tags: [
Index(2147483648), EitherIndex(2147483648),
], ],
regions: [ regions: [
@0-49, @0-49,
], ],
space_before: [ space_before: [
Slice(start = 0, length = 0), Slice { start: 0, length: 0 },
], ],
space_after: [ space_after: [
Slice(start = 0, length = 0), Slice { start: 0, length: 0 },
], ],
spaces: [], spaces: [],
type_defs: [], type_defs: [],

View file

@ -2,16 +2,16 @@ SpaceAfter(
Defs( Defs(
Defs { Defs {
tags: [ tags: [
Index(2147483648), EitherIndex(2147483648),
], ],
regions: [ regions: [
@0-46, @0-46,
], ],
space_before: [ space_before: [
Slice(start = 0, length = 0), Slice { start: 0, length: 0 },
], ],
space_after: [ space_after: [
Slice(start = 0, length = 0), Slice { start: 0, length: 0 },
], ],
spaces: [], spaces: [],
type_defs: [], type_defs: [],

View file

@ -2,16 +2,16 @@ SpaceAfter(
Defs( Defs(
Defs { Defs {
tags: [ tags: [
Index(2147483648), EitherIndex(2147483648),
], ],
regions: [ regions: [
@0-41, @0-41,
], ],
space_before: [ space_before: [
Slice(start = 0, length = 0), Slice { start: 0, length: 0 },
], ],
space_after: [ space_after: [
Slice(start = 0, length = 0), Slice { start: 0, length: 0 },
], ],
spaces: [], spaces: [],
type_defs: [], type_defs: [],

View file

@ -3,16 +3,16 @@ SpaceBefore(
Defs( Defs(
Defs { Defs {
tags: [ tags: [
Index(2147483648), EitherIndex(2147483648),
], ],
regions: [ regions: [
@107-112, @107-112,
], ],
space_before: [ space_before: [
Slice(start = 0, length = 0), Slice { start: 0, length: 0 },
], ],
space_after: [ space_after: [
Slice(start = 0, length = 0), Slice { start: 0, length: 0 },
], ],
spaces: [], spaces: [],
type_defs: [], type_defs: [],

View file

@ -2,16 +2,16 @@ SpaceAfter(
Defs( Defs(
Defs { Defs {
tags: [ tags: [
Index(0), EitherIndex(0),
], ],
regions: [ regions: [
@0-164, @0-164,
], ],
space_before: [ space_before: [
Slice(start = 0, length = 0), Slice { start: 0, length: 0 },
], ],
space_after: [ space_after: [
Slice(start = 0, length = 0), Slice { start: 0, length: 0 },
], ],
spaces: [], spaces: [],
type_defs: [ type_defs: [

View file

@ -1,16 +1,16 @@
Defs( Defs(
Defs { Defs {
tags: [ tags: [
Index(0), EitherIndex(0),
], ],
regions: [ regions: [
@0-3, @0-3,
], ],
space_before: [ space_before: [
Slice(start = 0, length = 0), Slice { start: 0, length: 0 },
], ],
space_after: [ space_after: [
Slice(start = 0, length = 0), Slice { start: 0, length: 0 },
], ],
spaces: [], spaces: [],
type_defs: [ type_defs: [

View file

@ -1,15 +1,15 @@
Defs { Defs {
tags: [ tags: [
Index(2147483648), EitherIndex(2147483648),
], ],
regions: [ regions: [
@0-7, @0-7,
], ],
space_before: [ space_before: [
Slice(start = 0, length = 0), Slice { start: 0, length: 0 },
], ],
space_after: [ space_after: [
Slice(start = 0, length = 1), Slice { start: 0, length: 1 },
], ],
spaces: [ spaces: [
LineComment( LineComment(

Some files were not shown because too many files have changed in this diff Show more