mirror of
https://github.com/roc-lang/roc.git
synced 2025-08-03 11:52:19 +00:00
Merge branch 'main' into allow-try-in-statements
This commit is contained in:
commit
29c8759bc0
320 changed files with 6977 additions and 2011 deletions
|
@ -7,11 +7,10 @@ license.workspace = true
|
|||
version.workspace = true
|
||||
|
||||
[dependencies]
|
||||
morphic_lib = { path = "../../vendor/morphic_lib" }
|
||||
roc_collections = { path = "../collections" }
|
||||
roc_debug_flags = { path = "../debug_flags" }
|
||||
roc_error_macros = { path = "../../error_macros" }
|
||||
roc_module = { path = "../module" }
|
||||
roc_mono = { path = "../mono" }
|
||||
|
||||
morphic_lib.workspace = true
|
||||
roc_collections.workspace = true
|
||||
roc_debug_flags.workspace = true
|
||||
roc_error_macros.workspace = true
|
||||
roc_module.workspace = true
|
||||
roc_mono.workspace = true
|
||||
bumpalo.workspace = true
|
||||
|
|
|
@ -1453,11 +1453,6 @@ fn expr_spec<'a>(
|
|||
|
||||
erasure_load(builder, block, value, *field, loaded_type)
|
||||
}
|
||||
RuntimeErrorFunction(_) => {
|
||||
let type_id = layout_spec(env, builder, interner, interner.get_repr(layout))?;
|
||||
|
||||
builder.add_terminate(block, type_id)
|
||||
}
|
||||
GetTagId { .. } => {
|
||||
// TODO touch heap cell in recursive cases
|
||||
|
||||
|
|
|
@ -8,32 +8,31 @@ license.workspace = true
|
|||
version.workspace = true
|
||||
|
||||
[dependencies]
|
||||
roc_bitcode = { path = "../builtins/bitcode" }
|
||||
roc_can = { path = "../can" }
|
||||
roc_collections = { path = "../collections" }
|
||||
roc_constrain = { path = "../constrain" }
|
||||
roc_debug_flags = { path = "../debug_flags" }
|
||||
roc_error_macros = { path = "../../error_macros" }
|
||||
roc_gen_dev = { path = "../gen_dev", default-features = false }
|
||||
roc_gen_llvm = { path = "../gen_llvm" }
|
||||
roc_gen_wasm = { path = "../gen_wasm" }
|
||||
roc_linker = { path = "../../linker" }
|
||||
roc_load = { path = "../load" }
|
||||
roc_module = { path = "../module" }
|
||||
roc_mono = { path = "../mono" }
|
||||
roc_packaging = { path = "../../packaging" }
|
||||
roc_parse = { path = "../parse" }
|
||||
roc_problem = { path = "../problem" }
|
||||
roc_region = { path = "../region" }
|
||||
roc_reporting = { path = "../../reporting" }
|
||||
roc_solve_problem = { path = "../solve_problem" }
|
||||
roc_std = { path = "../../roc_std" }
|
||||
roc_target = { path = "../roc_target" }
|
||||
roc_types = { path = "../types" }
|
||||
roc_unify = { path = "../unify" }
|
||||
roc_command_utils = { path = "../../utils/command" }
|
||||
|
||||
wasi_libc_sys = { path = "../../wasi-libc-sys" }
|
||||
roc_bitcode.workspace = true
|
||||
roc_can.workspace = true
|
||||
roc_collections.workspace = true
|
||||
roc_constrain.workspace = true
|
||||
roc_debug_flags.workspace = true
|
||||
roc_error_macros.workspace = true
|
||||
roc_gen_dev.workspace = true
|
||||
roc_gen_llvm.workspace = true
|
||||
roc_gen_wasm.workspace = true
|
||||
roc_linker.workspace = true
|
||||
roc_load.workspace = true
|
||||
roc_module.workspace = true
|
||||
roc_mono.workspace = true
|
||||
roc_packaging.workspace = true
|
||||
roc_parse.workspace = true
|
||||
roc_problem.workspace = true
|
||||
roc_region.workspace = true
|
||||
roc_reporting.workspace = true
|
||||
roc_solve_problem.workspace = true
|
||||
roc_std.workspace = true
|
||||
roc_target.workspace = true
|
||||
roc_types.workspace = true
|
||||
roc_unify.workspace = true
|
||||
roc_command_utils.workspace = true
|
||||
wasi_libc_sys.workspace = true
|
||||
|
||||
bumpalo.workspace = true
|
||||
indoc.workspace = true
|
||||
|
|
|
@ -8,8 +8,8 @@ license.workspace = true
|
|||
version.workspace = true
|
||||
|
||||
[dependencies]
|
||||
roc_collections = { path = "../collections" }
|
||||
roc_module = { path = "../module" }
|
||||
roc_region = { path = "../region" }
|
||||
roc_target = { path = "../roc_target" }
|
||||
roc_error_macros = { path = "../../error_macros" }
|
||||
roc_collections.workspace = true
|
||||
roc_module.workspace = true
|
||||
roc_region.workspace = true
|
||||
roc_target.workspace = true
|
||||
roc_error_macros.workspace = true
|
||||
|
|
|
@ -11,8 +11,8 @@ version.workspace = true
|
|||
tempfile.workspace = true
|
||||
|
||||
[build-dependencies]
|
||||
roc_command_utils = { path = "../../../utils/command" }
|
||||
roc_error_macros = { path = "../../../error_macros" }
|
||||
roc_command_utils.workspace = true
|
||||
roc_error_macros.workspace = true
|
||||
# dunce can be removed once ziglang/zig#5109 is fixed
|
||||
dunce = "1.0.3"
|
||||
|
||||
|
|
|
@ -8,8 +8,8 @@ license.workspace = true
|
|||
version.workspace = true
|
||||
|
||||
[build-dependencies]
|
||||
roc_command_utils = { path = "../../../../utils/command" }
|
||||
roc_error_macros = { path = "../../../../error_macros" }
|
||||
roc_command_utils.workspace = true
|
||||
roc_error_macros.workspace = true
|
||||
# dunce can be removed once ziglang/zig#5109 is fixed
|
||||
dunce = "1.0.3"
|
||||
|
||||
|
|
|
@ -437,16 +437,16 @@ pub const RocDec = extern struct {
|
|||
const numerator_i128 = self.num;
|
||||
const denominator_i128 = other.num;
|
||||
|
||||
// (0 / n) is always 0
|
||||
if (numerator_i128 == 0) {
|
||||
return RocDec{ .num = 0 };
|
||||
}
|
||||
|
||||
// (n / 0) is an error
|
||||
if (denominator_i128 == 0) {
|
||||
roc_panic("Decimal division by 0!", 0);
|
||||
}
|
||||
|
||||
// (0 / n) is always 0
|
||||
if (numerator_i128 == 0) {
|
||||
return RocDec{ .num = 0 };
|
||||
}
|
||||
|
||||
// If they're both negative, or if neither is negative, the final answer
|
||||
// is positive or zero. If one is negative and the denominator isn't, the
|
||||
// final answer is negative (or zero, in which case final sign won't matter).
|
||||
|
|
|
@ -110,7 +110,21 @@ pub fn exportNumToFloatCast(comptime T: type, comptime F: type, comptime name: [
|
|||
pub fn exportPow(comptime T: type, comptime name: []const u8) void {
|
||||
comptime var f = struct {
|
||||
fn func(base: T, exp: T) callconv(.C) T {
|
||||
return std.math.pow(T, base, exp);
|
||||
switch (@typeInfo(T)) {
|
||||
// std.math.pow can handle ints via powi, but it turns any errors to unreachable
|
||||
// we want to catch overflow and report a proper error to the user
|
||||
.Int => {
|
||||
if (std.math.powi(T, base, exp)) |value| {
|
||||
return value;
|
||||
} else |err| switch (err) {
|
||||
error.Overflow => roc_panic("Integer raised to power overflowed!", 0),
|
||||
error.Underflow => return 0,
|
||||
}
|
||||
},
|
||||
else => {
|
||||
return std.math.pow(T, base, exp);
|
||||
},
|
||||
}
|
||||
}
|
||||
}.func;
|
||||
@export(f, .{ .name = name ++ @typeName(T), .linkage = .Strong });
|
||||
|
|
|
@ -8,25 +8,23 @@ license.workspace = true
|
|||
version.workspace = true
|
||||
|
||||
[dependencies]
|
||||
roc_collections = { path = "../collections" }
|
||||
roc_error_macros = { path = "../../error_macros" }
|
||||
roc_exhaustive = { path = "../exhaustive" }
|
||||
roc_module = { path = "../module" }
|
||||
roc_parse = { path = "../parse" }
|
||||
roc_problem = { path = "../problem" }
|
||||
roc_region = { path = "../region" }
|
||||
roc_serialize = { path = "../serialize" }
|
||||
roc_types = { path = "../types" }
|
||||
|
||||
ven_pretty = { path = "../../vendor/pretty" }
|
||||
|
||||
roc_collections.workspace = true
|
||||
roc_error_macros.workspace = true
|
||||
roc_exhaustive.workspace = true
|
||||
roc_module.workspace = true
|
||||
roc_parse.workspace = true
|
||||
roc_problem.workspace = true
|
||||
roc_region.workspace = true
|
||||
roc_serialize.workspace = true
|
||||
roc_types.workspace = true
|
||||
ven_pretty.workspace = true
|
||||
bitvec.workspace = true
|
||||
bumpalo.workspace = true
|
||||
static_assertions.workspace = true
|
||||
|
||||
soa.workspace = true
|
||||
|
||||
[dev-dependencies]
|
||||
indoc.workspace = true
|
||||
insta.workspace = true
|
||||
pretty_assertions.workspace = true
|
||||
test_compile.workspace = true
|
||||
|
|
|
@ -113,8 +113,6 @@ pub struct SpecializationId(NonZeroU32);
|
|||
|
||||
static_assertions::assert_eq_size!(SpecializationId, Option<SpecializationId>);
|
||||
|
||||
pub enum SpecializationLambdaSetError {}
|
||||
|
||||
/// A key into a particular implementation of an ability member for an opaque type.
|
||||
#[derive(Clone, Copy, PartialEq, Eq, PartialOrd, Ord, Hash, Debug)]
|
||||
pub struct ImplKey {
|
||||
|
|
|
@ -132,7 +132,7 @@ pub struct AbleVariable {
|
|||
pub first_seen: Region,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Default)]
|
||||
#[derive(Clone, Debug, Default, PartialEq)]
|
||||
pub struct IntroducedVariables {
|
||||
pub wildcards: Vec<Loc<Variable>>,
|
||||
pub lambda_sets: Vec<Variable>,
|
||||
|
|
|
@ -929,7 +929,7 @@ pub struct FxExpectation {
|
|||
pub ann_region: Option<Region>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
#[derive(Debug, Clone, Copy, PartialEq)]
|
||||
pub enum FxCallKind {
|
||||
Call(Option<Symbol>),
|
||||
Stmt,
|
||||
|
@ -943,7 +943,7 @@ pub struct FxSuffixConstraint {
|
|||
pub region: Region,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
#[derive(Debug, Clone, Copy, PartialEq)]
|
||||
pub enum FxSuffixKind {
|
||||
Let(Symbol),
|
||||
Pattern(Symbol),
|
||||
|
@ -957,9 +957,16 @@ impl FxSuffixKind {
|
|||
Self::UnsuffixedRecordField => IdentSuffix::None,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn symbol(&self) -> Option<&Symbol> {
|
||||
match self {
|
||||
Self::Let(symbol) | Self::Pattern(symbol) => Some(symbol),
|
||||
Self::UnsuffixedRecordField => None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
#[derive(Debug, Clone, Copy, PartialEq)]
|
||||
pub enum ExpectEffectfulReason {
|
||||
Stmt,
|
||||
Ignored,
|
||||
|
|
|
@ -718,8 +718,6 @@ fn deep_copy_expr_help<C: CopyEnv>(env: &mut C, copied: &mut Vec<Variable>, expr
|
|||
symbol: *symbol,
|
||||
},
|
||||
|
||||
TypedHole(v) => TypedHole(sub!(*v)),
|
||||
|
||||
RuntimeError(err) => RuntimeError(err.clone()),
|
||||
}
|
||||
}
|
||||
|
|
|
@ -453,7 +453,6 @@ fn expr<'a>(c: &Ctx, p: EPrec, f: &'a Arena<'a>, e: &'a Expr) -> DocBuilder<'a,
|
|||
Dbg { .. } => todo!(),
|
||||
Expect { .. } => todo!(),
|
||||
Return { .. } => todo!(),
|
||||
TypedHole(_) => todo!(),
|
||||
RuntimeError(_) => todo!(),
|
||||
}
|
||||
}
|
||||
|
|
|
@ -63,7 +63,7 @@ use std::io::Read;
|
|||
use std::path::PathBuf;
|
||||
use std::sync::Arc;
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
pub struct Def {
|
||||
pub loc_pattern: Loc<Pattern>,
|
||||
pub loc_expr: Loc<Expr>,
|
||||
|
@ -91,7 +91,7 @@ impl Def {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
#[derive(Clone, Copy, Debug, PartialEq)]
|
||||
pub enum DefKind {
|
||||
/// A def that introduces identifiers
|
||||
Let,
|
||||
|
@ -123,7 +123,7 @@ impl DefKind {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
pub struct Annotation {
|
||||
pub signature: Type,
|
||||
pub introduced_variables: IntroducedVariables,
|
||||
|
|
|
@ -2,7 +2,7 @@ use crate::pattern::Pattern;
|
|||
use roc_region::all::{Loc, Region};
|
||||
use roc_types::types::{AnnotationSource, PReason, Reason};
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
pub enum Expected<T> {
|
||||
NoExpectation(T),
|
||||
FromAnnotation(Loc<Pattern>, usize, AnnotationSource, T),
|
||||
|
@ -10,7 +10,7 @@ pub enum Expected<T> {
|
|||
}
|
||||
|
||||
/// Like Expected, but for Patterns.
|
||||
#[derive(Debug, Clone)]
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
pub enum PExpected<T> {
|
||||
NoExpectation(T),
|
||||
ForReason(PReason, T, Region),
|
||||
|
|
|
@ -85,7 +85,55 @@ impl Display for IntValue {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
impl IntValue {
|
||||
pub fn as_u8(self) -> u8 {
|
||||
self.as_u128() as u8
|
||||
}
|
||||
|
||||
pub fn as_i8(self) -> i8 {
|
||||
self.as_i128() as i8
|
||||
}
|
||||
|
||||
pub fn as_u16(self) -> u16 {
|
||||
self.as_u128() as u16
|
||||
}
|
||||
|
||||
pub fn as_i16(self) -> i16 {
|
||||
self.as_i128() as i16
|
||||
}
|
||||
|
||||
pub fn as_u32(self) -> u32 {
|
||||
self.as_u128() as u32
|
||||
}
|
||||
|
||||
pub fn as_i32(self) -> i32 {
|
||||
self.as_i128() as i32
|
||||
}
|
||||
|
||||
pub fn as_u64(self) -> u64 {
|
||||
self.as_u128() as u64
|
||||
}
|
||||
|
||||
pub fn as_i64(self) -> i64 {
|
||||
self.as_i128() as i64
|
||||
}
|
||||
|
||||
pub fn as_u128(self) -> u128 {
|
||||
match self {
|
||||
IntValue::I128(i128) => i128::from_ne_bytes(i128) as u128,
|
||||
IntValue::U128(u128) => u128::from_ne_bytes(u128),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn as_i128(self) -> i128 {
|
||||
match self {
|
||||
IntValue::I128(i128) => i128::from_ne_bytes(i128),
|
||||
IntValue::U128(u128) => u128::from_ne_bytes(u128) as i128,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
pub enum Expr {
|
||||
// Literals
|
||||
|
||||
|
@ -104,7 +152,7 @@ pub enum Expr {
|
|||
loc_elems: Vec<Loc<Expr>>,
|
||||
},
|
||||
|
||||
// An ingested files, it's bytes, and the type variable.
|
||||
// An ingested files, its bytes, and the type variable.
|
||||
IngestedFile(Box<PathBuf>, Arc<Vec<u8>>, Variable),
|
||||
|
||||
// Lookups
|
||||
|
@ -131,7 +179,7 @@ pub enum Expr {
|
|||
/// The actual condition of the when expression.
|
||||
loc_cond: Box<Loc<Expr>>,
|
||||
cond_var: Variable,
|
||||
/// Result type produced by the branches.
|
||||
/// Type of each branch (and therefore the type of the entire `when` expression)
|
||||
expr_var: Variable,
|
||||
region: Region,
|
||||
/// The branches of the when, and the type of the condition that they expect to be matched
|
||||
|
@ -285,14 +333,11 @@ pub enum Expr {
|
|||
return_var: Variable,
|
||||
},
|
||||
|
||||
/// Rendered as empty box in editor
|
||||
TypedHole(Variable),
|
||||
|
||||
/// Compiles, but will crash if reached
|
||||
RuntimeError(RuntimeError),
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
#[derive(Clone, Copy, Debug, PartialEq)]
|
||||
pub struct ExpectLookup {
|
||||
pub symbol: Symbol,
|
||||
pub var: Variable,
|
||||
|
@ -363,7 +408,7 @@ impl Expr {
|
|||
Self::Dbg { .. } => Category::Expect,
|
||||
|
||||
// these nodes place no constraints on the expression's type
|
||||
Self::TypedHole(_) | Self::RuntimeError(..) => Category::Unknown,
|
||||
Self::RuntimeError(..) => Category::Unknown,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -470,7 +515,7 @@ impl Expr {
|
|||
|
||||
/// Stores exhaustiveness-checking metadata for a closure argument that may
|
||||
/// have an annotated type.
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
#[derive(Clone, Copy, Debug, PartialEq)]
|
||||
pub struct AnnotatedMark {
|
||||
pub annotation_var: Variable,
|
||||
pub exhaustive: ExhaustiveMark,
|
||||
|
@ -494,7 +539,7 @@ impl AnnotatedMark {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
pub struct ClosureData {
|
||||
pub function_type: Variable,
|
||||
pub closure_type: Variable,
|
||||
|
@ -591,7 +636,7 @@ impl StructAccessorData {
|
|||
/// An opaque wrapper like `@Foo`, which is equivalent to `\p -> @Foo p`
|
||||
/// These are desugared to closures, but we distinguish them so we can have
|
||||
/// better error messages during constraint generation.
|
||||
#[derive(Clone, Debug)]
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
pub struct OpaqueWrapFunctionData {
|
||||
pub opaque_name: Symbol,
|
||||
pub opaque_var: Variable,
|
||||
|
@ -663,7 +708,7 @@ impl OpaqueWrapFunctionData {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
pub struct Field {
|
||||
pub var: Variable,
|
||||
// The region of the full `foo: f bar`, rather than just `f bar`
|
||||
|
@ -687,7 +732,7 @@ impl Recursive {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
pub struct WhenBranchPattern {
|
||||
pub pattern: Loc<Pattern>,
|
||||
/// Degenerate branch patterns are those that don't fully bind symbols that the branch body
|
||||
|
@ -696,7 +741,7 @@ pub struct WhenBranchPattern {
|
|||
pub degenerate: bool,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
pub struct WhenBranch {
|
||||
pub patterns: Vec<WhenBranchPattern>,
|
||||
pub value: Loc<Expr>,
|
||||
|
@ -2147,7 +2192,6 @@ pub fn inline_calls(var_store: &mut VarStore, expr: Expr) -> Expr {
|
|||
| other @ ParamsVar { .. }
|
||||
| other @ AbilityMember(..)
|
||||
| other @ RunLowLevel { .. }
|
||||
| other @ TypedHole { .. }
|
||||
| other @ ForeignCall { .. }
|
||||
| other @ OpaqueWrapFunction(_)
|
||||
| other @ Crash { .. }
|
||||
|
@ -3512,7 +3556,6 @@ pub(crate) fn get_lookup_symbols(expr: &Expr) -> Vec<ExpectLookup> {
|
|||
| Expr::RecordAccessor(_)
|
||||
| Expr::SingleQuote(..)
|
||||
| Expr::EmptyRecord
|
||||
| Expr::TypedHole(_)
|
||||
| Expr::RuntimeError(_)
|
||||
| Expr::ImportParams(_, _, None)
|
||||
| Expr::OpaqueWrapFunction(_) => {}
|
||||
|
|
|
@ -1055,7 +1055,6 @@ fn fix_values_captured_in_closure_expr(
|
|||
| ParamsVar { .. }
|
||||
| AbilityMember(..)
|
||||
| EmptyRecord
|
||||
| TypedHole { .. }
|
||||
| RuntimeError(_)
|
||||
| ZeroArgumentTag { .. }
|
||||
| RecordAccessor { .. } => {}
|
||||
|
|
|
@ -19,7 +19,7 @@ use roc_types::types::{LambdaSet, OptAbleVar, PatternCategory, Type};
|
|||
|
||||
/// A pattern, including possible problems (e.g. shadowing) so that
|
||||
/// codegen can generate a runtime error if this pattern is reached.
|
||||
#[derive(Clone, Debug)]
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
pub enum Pattern {
|
||||
Identifier(Symbol),
|
||||
As(Box<Loc<Pattern>>, Symbol),
|
||||
|
@ -198,7 +198,7 @@ impl Pattern {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
pub struct ListPatterns {
|
||||
pub patterns: Vec<Loc<Pattern>>,
|
||||
/// Where a rest pattern splits patterns before and after it, if it does at all.
|
||||
|
@ -207,6 +207,7 @@ pub struct ListPatterns {
|
|||
/// [ .., A, B ] -> patterns = [A, B], rest = 0
|
||||
/// [ A, .., B ] -> patterns = [A, B], rest = 1
|
||||
/// [ A, B, .. ] -> patterns = [A, B], rest = 2
|
||||
/// Optionally, the rest pattern can be named - e.g. `[ A, B, ..others ]`
|
||||
pub opt_rest: Option<(usize, Option<Loc<Symbol>>)>,
|
||||
}
|
||||
|
||||
|
@ -228,7 +229,7 @@ impl ListPatterns {
|
|||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
pub struct RecordDestruct {
|
||||
pub var: Variable,
|
||||
pub label: Lowercase,
|
||||
|
@ -236,14 +237,14 @@ pub struct RecordDestruct {
|
|||
pub typ: DestructType,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
pub struct TupleDestruct {
|
||||
pub var: Variable,
|
||||
pub destruct_index: usize,
|
||||
pub typ: (Variable, Loc<Pattern>),
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
#[derive(Clone, Debug, PartialEq)]
|
||||
pub enum DestructType {
|
||||
Required,
|
||||
Optional(Variable, Loc<Expr>),
|
||||
|
|
|
@ -406,7 +406,6 @@ pub fn walk_expr<V: Visitor>(visitor: &mut V, expr: &Expr, var: Variable) {
|
|||
} => {
|
||||
visitor.visit_expr(&return_value.value, return_value.region, *return_var);
|
||||
}
|
||||
Expr::TypedHole(_) => { /* terminal */ }
|
||||
Expr::RuntimeError(..) => { /* terminal */ }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
---
|
||||
source: crates/compiler/can/tests/test_suffixed.rs
|
||||
expression: snapshot
|
||||
snapshot_kind: text
|
||||
---
|
||||
Defs {
|
||||
tags: [
|
||||
|
@ -10,10 +11,10 @@ Defs {
|
|||
@0-28,
|
||||
],
|
||||
space_before: [
|
||||
Slice { start: 0, length: 0 },
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
space_after: [
|
||||
Slice { start: 0, length: 1 },
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 1 },
|
||||
],
|
||||
spaces: [
|
||||
Newline,
|
||||
|
@ -65,10 +66,10 @@ Defs {
|
|||
@15-22,
|
||||
],
|
||||
space_before: [
|
||||
Slice { start: 0, length: 0 },
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
space_after: [
|
||||
Slice { start: 0, length: 0 },
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
spaces: [],
|
||||
type_defs: [],
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
---
|
||||
source: crates/compiler/can/tests/test_suffixed.rs
|
||||
expression: snapshot
|
||||
snapshot_kind: text
|
||||
---
|
||||
Defs {
|
||||
tags: [
|
||||
|
@ -10,10 +11,10 @@ Defs {
|
|||
@0-25,
|
||||
],
|
||||
space_before: [
|
||||
Slice { start: 0, length: 0 },
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
space_after: [
|
||||
Slice { start: 0, length: 1 },
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 1 },
|
||||
],
|
||||
spaces: [
|
||||
Newline,
|
||||
|
@ -49,10 +50,10 @@ Defs {
|
|||
@15-19,
|
||||
],
|
||||
space_before: [
|
||||
Slice { start: 0, length: 0 },
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
space_after: [
|
||||
Slice { start: 0, length: 0 },
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
spaces: [],
|
||||
type_defs: [],
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
---
|
||||
source: crates/compiler/can/tests/test_suffixed.rs
|
||||
expression: snapshot
|
||||
snapshot_kind: text
|
||||
---
|
||||
Defs {
|
||||
tags: [
|
||||
|
@ -10,10 +11,10 @@ Defs {
|
|||
@0-43,
|
||||
],
|
||||
space_before: [
|
||||
Slice { start: 0, length: 0 },
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
space_after: [
|
||||
Slice { start: 0, length: 1 },
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 1 },
|
||||
],
|
||||
spaces: [
|
||||
Newline,
|
||||
|
@ -59,10 +60,10 @@ Defs {
|
|||
@15-33,
|
||||
],
|
||||
space_before: [
|
||||
Slice { start: 0, length: 0 },
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
space_after: [
|
||||
Slice { start: 0, length: 0 },
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
spaces: [],
|
||||
type_defs: [],
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
---
|
||||
source: crates/compiler/can/tests/test_suffixed.rs
|
||||
expression: snapshot
|
||||
snapshot_kind: text
|
||||
---
|
||||
Defs {
|
||||
tags: [
|
||||
|
@ -10,10 +11,10 @@ Defs {
|
|||
@0-45,
|
||||
],
|
||||
space_before: [
|
||||
Slice { start: 0, length: 0 },
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
space_after: [
|
||||
Slice { start: 0, length: 1 },
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 1 },
|
||||
],
|
||||
spaces: [
|
||||
Newline,
|
||||
|
@ -59,10 +60,10 @@ Defs {
|
|||
@15-35,
|
||||
],
|
||||
space_before: [
|
||||
Slice { start: 0, length: 0 },
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
space_after: [
|
||||
Slice { start: 0, length: 0 },
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
spaces: [],
|
||||
type_defs: [],
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
---
|
||||
source: crates/compiler/can/tests/test_suffixed.rs
|
||||
expression: snapshot
|
||||
snapshot_kind: text
|
||||
---
|
||||
Defs {
|
||||
tags: [
|
||||
|
@ -10,10 +11,10 @@ Defs {
|
|||
@0-28,
|
||||
],
|
||||
space_before: [
|
||||
Slice { start: 0, length: 0 },
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
space_after: [
|
||||
Slice { start: 0, length: 1 },
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 1 },
|
||||
],
|
||||
spaces: [
|
||||
Newline,
|
||||
|
@ -49,10 +50,10 @@ Defs {
|
|||
@15-22,
|
||||
],
|
||||
space_before: [
|
||||
Slice { start: 0, length: 0 },
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
space_after: [
|
||||
Slice { start: 0, length: 0 },
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
spaces: [],
|
||||
type_defs: [],
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
---
|
||||
source: crates/compiler/can/tests/test_suffixed.rs
|
||||
expression: snapshot
|
||||
snapshot_kind: text
|
||||
---
|
||||
Defs {
|
||||
tags: [
|
||||
|
@ -10,10 +11,10 @@ Defs {
|
|||
@0-26,
|
||||
],
|
||||
space_before: [
|
||||
Slice { start: 0, length: 0 },
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
space_after: [
|
||||
Slice { start: 0, length: 1 },
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 1 },
|
||||
],
|
||||
spaces: [
|
||||
Newline,
|
||||
|
@ -39,10 +40,10 @@ Defs {
|
|||
@11-14,
|
||||
],
|
||||
space_before: [
|
||||
Slice { start: 0, length: 0 },
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
space_after: [
|
||||
Slice { start: 0, length: 0 },
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
spaces: [],
|
||||
type_defs: [],
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
---
|
||||
source: crates/compiler/can/tests/test_suffixed.rs
|
||||
expression: snapshot
|
||||
snapshot_kind: text
|
||||
---
|
||||
Defs {
|
||||
tags: [
|
||||
|
@ -10,10 +11,10 @@ Defs {
|
|||
@0-42,
|
||||
],
|
||||
space_before: [
|
||||
Slice { start: 0, length: 0 },
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
space_after: [
|
||||
Slice { start: 0, length: 1 },
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 1 },
|
||||
],
|
||||
spaces: [
|
||||
Newline,
|
||||
|
@ -49,10 +50,10 @@ Defs {
|
|||
@16-35,
|
||||
],
|
||||
space_before: [
|
||||
Slice { start: 0, length: 0 },
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
space_after: [
|
||||
Slice { start: 0, length: 0 },
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
spaces: [],
|
||||
type_defs: [],
|
||||
|
|
|
@ -11,10 +11,10 @@ Defs {
|
|||
@0-69,
|
||||
],
|
||||
space_before: [
|
||||
Slice { start: 0, length: 0 },
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
space_after: [
|
||||
Slice { start: 0, length: 1 },
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 1 },
|
||||
],
|
||||
spaces: [
|
||||
Newline,
|
||||
|
@ -34,10 +34,10 @@ Defs {
|
|||
@15-57,
|
||||
],
|
||||
space_before: [
|
||||
Slice { start: 0, length: 0 },
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
space_after: [
|
||||
Slice { start: 0, length: 0 },
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
spaces: [],
|
||||
type_defs: [],
|
||||
|
@ -67,10 +67,10 @@ Defs {
|
|||
@31-43,
|
||||
],
|
||||
space_before: [
|
||||
Slice { start: 0, length: 0 },
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
space_after: [
|
||||
Slice { start: 0, length: 0 },
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
spaces: [],
|
||||
type_defs: [],
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
---
|
||||
source: crates/compiler/can/tests/test_suffixed.rs
|
||||
expression: snapshot
|
||||
snapshot_kind: text
|
||||
---
|
||||
Defs {
|
||||
tags: [
|
||||
|
@ -10,10 +11,10 @@ Defs {
|
|||
@0-114,
|
||||
],
|
||||
space_before: [
|
||||
Slice { start: 0, length: 0 },
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
space_after: [
|
||||
Slice { start: 0, length: 1 },
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 1 },
|
||||
],
|
||||
spaces: [
|
||||
Newline,
|
||||
|
@ -33,10 +34,10 @@ Defs {
|
|||
@39-101,
|
||||
],
|
||||
space_before: [
|
||||
Slice { start: 0, length: 0 },
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
space_after: [
|
||||
Slice { start: 0, length: 0 },
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
spaces: [],
|
||||
type_defs: [],
|
||||
|
@ -84,10 +85,10 @@ Defs {
|
|||
@82-91,
|
||||
],
|
||||
space_before: [
|
||||
Slice { start: 0, length: 0 },
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
space_after: [
|
||||
Slice { start: 0, length: 0 },
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
spaces: [],
|
||||
type_defs: [],
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
---
|
||||
source: crates/compiler/can/tests/test_suffixed.rs
|
||||
expression: snapshot
|
||||
snapshot_kind: text
|
||||
---
|
||||
Defs {
|
||||
tags: [
|
||||
|
@ -10,10 +11,10 @@ Defs {
|
|||
@0-143,
|
||||
],
|
||||
space_before: [
|
||||
Slice { start: 0, length: 0 },
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
space_after: [
|
||||
Slice { start: 0, length: 1 },
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 1 },
|
||||
],
|
||||
spaces: [
|
||||
Newline,
|
||||
|
@ -33,10 +34,10 @@ Defs {
|
|||
@56-119,
|
||||
],
|
||||
space_before: [
|
||||
Slice { start: 0, length: 0 },
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
space_after: [
|
||||
Slice { start: 0, length: 0 },
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
spaces: [],
|
||||
type_defs: [],
|
||||
|
@ -112,10 +113,10 @@ Defs {
|
|||
@76-83,
|
||||
],
|
||||
space_before: [
|
||||
Slice { start: 0, length: 0 },
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
space_after: [
|
||||
Slice { start: 0, length: 0 },
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
spaces: [],
|
||||
type_defs: [],
|
||||
|
@ -181,10 +182,10 @@ Defs {
|
|||
@92-99,
|
||||
],
|
||||
space_before: [
|
||||
Slice { start: 0, length: 0 },
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
space_after: [
|
||||
Slice { start: 0, length: 0 },
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
spaces: [],
|
||||
type_defs: [],
|
||||
|
|
|
@ -1,19 +1,20 @@
|
|||
---
|
||||
source: crates/compiler/can/tests/test_suffixed.rs
|
||||
expression: snapshot
|
||||
snapshot_kind: text
|
||||
---
|
||||
Defs {
|
||||
tags: [
|
||||
EitherIndex(2147483648),
|
||||
],
|
||||
regions: [
|
||||
@0-26,
|
||||
@0-28,
|
||||
],
|
||||
space_before: [
|
||||
Slice { start: 0, length: 0 },
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
space_after: [
|
||||
Slice { start: 0, length: 1 },
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 1 },
|
||||
],
|
||||
spaces: [
|
||||
Newline,
|
||||
|
@ -24,88 +25,90 @@ Defs {
|
|||
@0-4 Identifier {
|
||||
ident: "main",
|
||||
},
|
||||
@11-26 Defs(
|
||||
@11-28 Defs(
|
||||
Defs {
|
||||
tags: [
|
||||
EitherIndex(2147483648),
|
||||
],
|
||||
regions: [
|
||||
@15-26,
|
||||
@16-27,
|
||||
],
|
||||
space_before: [
|
||||
Slice { start: 0, length: 0 },
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
space_after: [
|
||||
Slice { start: 0, length: 0 },
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
spaces: [],
|
||||
type_defs: [],
|
||||
value_defs: [
|
||||
Body(
|
||||
@15-26 Identifier {
|
||||
@16-27 Identifier {
|
||||
ident: "1",
|
||||
},
|
||||
@15-26 ParensAround(
|
||||
@16-27 ParensAround(
|
||||
Defs(
|
||||
Defs {
|
||||
tags: [
|
||||
EitherIndex(2147483648),
|
||||
],
|
||||
regions: [
|
||||
@20-25,
|
||||
@21-26,
|
||||
],
|
||||
space_before: [
|
||||
Slice { start: 0, length: 0 },
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
space_after: [
|
||||
Slice { start: 0, length: 0 },
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
spaces: [],
|
||||
type_defs: [],
|
||||
value_defs: [
|
||||
Body(
|
||||
@20-25 Identifier {
|
||||
@21-26 Identifier {
|
||||
ident: "0",
|
||||
},
|
||||
@20-25 Apply(
|
||||
@22-23 Var {
|
||||
module_name: "Num",
|
||||
ident: "add",
|
||||
},
|
||||
[
|
||||
@20-21 Num(
|
||||
"1",
|
||||
@21-26 ParensAround(
|
||||
Apply(
|
||||
@23-24 Var {
|
||||
module_name: "Num",
|
||||
ident: "add",
|
||||
},
|
||||
[
|
||||
@21-22 Num(
|
||||
"1",
|
||||
),
|
||||
@25-26 Num(
|
||||
"1",
|
||||
),
|
||||
],
|
||||
BinOp(
|
||||
Plus,
|
||||
),
|
||||
@24-25 Num(
|
||||
"1",
|
||||
),
|
||||
],
|
||||
BinOp(
|
||||
Plus,
|
||||
),
|
||||
),
|
||||
),
|
||||
],
|
||||
},
|
||||
@15-26 LowLevelDbg(
|
||||
@16-27 LowLevelDbg(
|
||||
(
|
||||
"test.roc:3",
|
||||
" ",
|
||||
),
|
||||
@20-25 Apply(
|
||||
@20-25 Var {
|
||||
@21-26 Apply(
|
||||
@21-26 Var {
|
||||
module_name: "Inspect",
|
||||
ident: "toStr",
|
||||
},
|
||||
[
|
||||
@20-25 Var {
|
||||
@21-26 Var {
|
||||
module_name: "",
|
||||
ident: "0",
|
||||
},
|
||||
],
|
||||
Space,
|
||||
),
|
||||
@20-25 Var {
|
||||
@21-26 Var {
|
||||
module_name: "",
|
||||
ident: "0",
|
||||
},
|
||||
|
@ -115,25 +118,25 @@ Defs {
|
|||
),
|
||||
],
|
||||
},
|
||||
@11-26 LowLevelDbg(
|
||||
@11-28 LowLevelDbg(
|
||||
(
|
||||
"test.roc:2",
|
||||
"in =\n ",
|
||||
"n =\n ",
|
||||
),
|
||||
@15-26 Apply(
|
||||
@15-26 Var {
|
||||
@16-27 Apply(
|
||||
@16-27 Var {
|
||||
module_name: "Inspect",
|
||||
ident: "toStr",
|
||||
},
|
||||
[
|
||||
@15-26 Var {
|
||||
@16-27 Var {
|
||||
module_name: "",
|
||||
ident: "1",
|
||||
},
|
||||
],
|
||||
Space,
|
||||
),
|
||||
@15-26 Var {
|
||||
@16-27 Var {
|
||||
module_name: "",
|
||||
ident: "1",
|
||||
},
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
---
|
||||
source: crates/compiler/can/tests/test_suffixed.rs
|
||||
expression: snapshot
|
||||
snapshot_kind: text
|
||||
---
|
||||
Defs {
|
||||
tags: [
|
||||
|
@ -10,10 +11,10 @@ Defs {
|
|||
@0-49,
|
||||
],
|
||||
space_before: [
|
||||
Slice { start: 0, length: 0 },
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
space_after: [
|
||||
Slice { start: 0, length: 1 },
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 1 },
|
||||
],
|
||||
spaces: [
|
||||
Newline,
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
---
|
||||
source: crates/compiler/can/tests/test_suffixed.rs
|
||||
expression: snapshot
|
||||
snapshot_kind: text
|
||||
---
|
||||
Defs {
|
||||
tags: [
|
||||
|
@ -10,10 +11,10 @@ Defs {
|
|||
@0-24,
|
||||
],
|
||||
space_before: [
|
||||
Slice { start: 0, length: 0 },
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
space_after: [
|
||||
Slice { start: 0, length: 1 },
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 1 },
|
||||
],
|
||||
spaces: [
|
||||
Newline,
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
---
|
||||
source: crates/compiler/can/tests/test_suffixed.rs
|
||||
expression: snapshot
|
||||
snapshot_kind: text
|
||||
---
|
||||
Defs {
|
||||
tags: [
|
||||
|
@ -10,10 +11,10 @@ Defs {
|
|||
@0-99,
|
||||
],
|
||||
space_before: [
|
||||
Slice { start: 0, length: 0 },
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
space_after: [
|
||||
Slice { start: 0, length: 1 },
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 1 },
|
||||
],
|
||||
spaces: [
|
||||
Newline,
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
---
|
||||
source: crates/compiler/can/tests/test_suffixed.rs
|
||||
expression: snapshot
|
||||
snapshot_kind: text
|
||||
---
|
||||
Defs {
|
||||
tags: [
|
||||
|
@ -12,12 +13,12 @@ Defs {
|
|||
@56-98,
|
||||
],
|
||||
space_before: [
|
||||
Slice { start: 0, length: 0 },
|
||||
Slice { start: 0, length: 2 },
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 2 },
|
||||
],
|
||||
space_after: [
|
||||
Slice { start: 0, length: 0 },
|
||||
Slice { start: 2, length: 1 },
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 2, length: 1 },
|
||||
],
|
||||
spaces: [
|
||||
Newline,
|
||||
|
@ -39,10 +40,10 @@ Defs {
|
|||
@15-20,
|
||||
],
|
||||
space_before: [
|
||||
Slice { start: 0, length: 0 },
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
space_after: [
|
||||
Slice { start: 0, length: 0 },
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
spaces: [],
|
||||
type_defs: [],
|
||||
|
@ -74,10 +75,10 @@ Defs {
|
|||
@25-39,
|
||||
],
|
||||
space_before: [
|
||||
Slice { start: 0, length: 0 },
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
space_after: [
|
||||
Slice { start: 0, length: 0 },
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
spaces: [],
|
||||
type_defs: [],
|
||||
|
@ -151,10 +152,10 @@ Defs {
|
|||
@75-80,
|
||||
],
|
||||
space_before: [
|
||||
Slice { start: 0, length: 0 },
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
space_after: [
|
||||
Slice { start: 0, length: 0 },
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
spaces: [],
|
||||
type_defs: [],
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
---
|
||||
source: crates/compiler/can/tests/test_suffixed.rs
|
||||
expression: snapshot
|
||||
snapshot_kind: text
|
||||
---
|
||||
Defs {
|
||||
tags: [
|
||||
|
@ -10,10 +11,10 @@ Defs {
|
|||
@0-158,
|
||||
],
|
||||
space_before: [
|
||||
Slice { start: 0, length: 0 },
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
space_after: [
|
||||
Slice { start: 0, length: 1 },
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 1 },
|
||||
],
|
||||
spaces: [
|
||||
Newline,
|
||||
|
@ -45,10 +46,10 @@ Defs {
|
|||
@50-52,
|
||||
],
|
||||
space_before: [
|
||||
Slice { start: 0, length: 0 },
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
space_after: [
|
||||
Slice { start: 0, length: 0 },
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
spaces: [],
|
||||
type_defs: [],
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
---
|
||||
source: crates/compiler/can/tests/test_suffixed.rs
|
||||
expression: snapshot
|
||||
snapshot_kind: text
|
||||
---
|
||||
Defs {
|
||||
tags: [
|
||||
|
@ -10,10 +11,10 @@ Defs {
|
|||
@0-31,
|
||||
],
|
||||
space_before: [
|
||||
Slice { start: 0, length: 0 },
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
space_after: [
|
||||
Slice { start: 0, length: 1 },
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 1 },
|
||||
],
|
||||
spaces: [
|
||||
Newline,
|
||||
|
@ -33,10 +34,10 @@ Defs {
|
|||
@11-24,
|
||||
],
|
||||
space_before: [
|
||||
Slice { start: 0, length: 0 },
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
space_after: [
|
||||
Slice { start: 0, length: 0 },
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
spaces: [],
|
||||
type_defs: [],
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
---
|
||||
source: crates/compiler/can/tests/test_suffixed.rs
|
||||
expression: snapshot
|
||||
snapshot_kind: text
|
||||
---
|
||||
Defs {
|
||||
tags: [
|
||||
|
@ -10,10 +11,10 @@ Defs {
|
|||
@0-307,
|
||||
],
|
||||
space_before: [
|
||||
Slice { start: 0, length: 0 },
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
space_after: [
|
||||
Slice { start: 0, length: 1 },
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 1 },
|
||||
],
|
||||
spaces: [
|
||||
Newline,
|
||||
|
@ -37,14 +38,14 @@ Defs {
|
|||
@109-298,
|
||||
],
|
||||
space_before: [
|
||||
Slice { start: 0, length: 0 },
|
||||
Slice { start: 0, length: 1 },
|
||||
Slice { start: 1, length: 1 },
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 1 },
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 1, length: 1 },
|
||||
],
|
||||
space_after: [
|
||||
Slice { start: 0, length: 0 },
|
||||
Slice { start: 1, length: 0 },
|
||||
Slice { start: 2, length: 0 },
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 1, length: 0 },
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 2, length: 0 },
|
||||
],
|
||||
spaces: [
|
||||
Newline,
|
||||
|
@ -171,10 +172,10 @@ Defs {
|
|||
@140-152,
|
||||
],
|
||||
space_before: [
|
||||
Slice { start: 0, length: 0 },
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
space_after: [
|
||||
Slice { start: 0, length: 0 },
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
spaces: [],
|
||||
type_defs: [],
|
||||
|
@ -293,10 +294,10 @@ Defs {
|
|||
@227-239,
|
||||
],
|
||||
space_before: [
|
||||
Slice { start: 0, length: 0 },
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
space_after: [
|
||||
Slice { start: 0, length: 0 },
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
spaces: [],
|
||||
type_defs: [],
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
---
|
||||
source: crates/compiler/can/tests/test_suffixed.rs
|
||||
expression: snapshot
|
||||
snapshot_kind: text
|
||||
---
|
||||
Defs {
|
||||
tags: [
|
||||
|
@ -10,10 +11,10 @@ Defs {
|
|||
@0-189,
|
||||
],
|
||||
space_before: [
|
||||
Slice { start: 0, length: 0 },
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
space_after: [
|
||||
Slice { start: 0, length: 1 },
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 1 },
|
||||
],
|
||||
spaces: [
|
||||
Newline,
|
||||
|
@ -35,12 +36,12 @@ Defs {
|
|||
@52-70,
|
||||
],
|
||||
space_before: [
|
||||
Slice { start: 0, length: 0 },
|
||||
Slice { start: 0, length: 1 },
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 1 },
|
||||
],
|
||||
space_after: [
|
||||
Slice { start: 0, length: 0 },
|
||||
Slice { start: 1, length: 0 },
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 1, length: 0 },
|
||||
],
|
||||
spaces: [
|
||||
Newline,
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
---
|
||||
source: crates/compiler/can/tests/test_suffixed.rs
|
||||
expression: snapshot
|
||||
snapshot_kind: text
|
||||
---
|
||||
Defs {
|
||||
tags: [
|
||||
|
@ -14,14 +15,14 @@ Defs {
|
|||
@229-266,
|
||||
],
|
||||
space_before: [
|
||||
Slice { start: 0, length: 0 },
|
||||
Slice { start: 0, length: 2 },
|
||||
Slice { start: 2, length: 2 },
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 2 },
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 2, length: 2 },
|
||||
],
|
||||
space_after: [
|
||||
Slice { start: 0, length: 0 },
|
||||
Slice { start: 2, length: 0 },
|
||||
Slice { start: 4, length: 1 },
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 2, length: 0 },
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 4, length: 1 },
|
||||
],
|
||||
spaces: [
|
||||
Newline,
|
||||
|
@ -120,12 +121,12 @@ Defs {
|
|||
@203-208,
|
||||
],
|
||||
space_before: [
|
||||
Slice { start: 0, length: 0 },
|
||||
Slice { start: 0, length: 1 },
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 1 },
|
||||
],
|
||||
space_after: [
|
||||
Slice { start: 0, length: 0 },
|
||||
Slice { start: 1, length: 0 },
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 1, length: 0 },
|
||||
],
|
||||
spaces: [
|
||||
Newline,
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
---
|
||||
source: crates/compiler/can/tests/test_suffixed.rs
|
||||
expression: snapshot
|
||||
snapshot_kind: text
|
||||
---
|
||||
Defs {
|
||||
tags: [
|
||||
|
@ -12,12 +13,12 @@ Defs {
|
|||
@35-45,
|
||||
],
|
||||
space_before: [
|
||||
Slice { start: 0, length: 0 },
|
||||
Slice { start: 0, length: 2 },
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 2 },
|
||||
],
|
||||
space_after: [
|
||||
Slice { start: 0, length: 0 },
|
||||
Slice { start: 2, length: 1 },
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 2, length: 1 },
|
||||
],
|
||||
spaces: [
|
||||
Newline,
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
---
|
||||
source: crates/compiler/can/tests/test_suffixed.rs
|
||||
expression: snapshot
|
||||
snapshot_kind: text
|
||||
---
|
||||
Defs {
|
||||
tags: [
|
||||
|
@ -10,10 +11,10 @@ Defs {
|
|||
@0-26,
|
||||
],
|
||||
space_before: [
|
||||
Slice { start: 0, length: 0 },
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
space_after: [
|
||||
Slice { start: 0, length: 1 },
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 1 },
|
||||
],
|
||||
spaces: [
|
||||
Newline,
|
||||
|
@ -33,10 +34,10 @@ Defs {
|
|||
@15-17,
|
||||
],
|
||||
space_before: [
|
||||
Slice { start: 0, length: 0 },
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
space_after: [
|
||||
Slice { start: 0, length: 0 },
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
spaces: [],
|
||||
type_defs: [],
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
---
|
||||
source: crates/compiler/can/tests/test_suffixed.rs
|
||||
expression: snapshot
|
||||
snapshot_kind: text
|
||||
---
|
||||
Defs {
|
||||
tags: [
|
||||
|
@ -10,10 +11,10 @@ Defs {
|
|||
@0-33,
|
||||
],
|
||||
space_before: [
|
||||
Slice { start: 0, length: 0 },
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
space_after: [
|
||||
Slice { start: 0, length: 1 },
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 1 },
|
||||
],
|
||||
spaces: [
|
||||
Newline,
|
||||
|
@ -39,10 +40,10 @@ Defs {
|
|||
@11-14,
|
||||
],
|
||||
space_before: [
|
||||
Slice { start: 0, length: 0 },
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
space_after: [
|
||||
Slice { start: 0, length: 0 },
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
spaces: [],
|
||||
type_defs: [],
|
||||
|
@ -99,10 +100,10 @@ Defs {
|
|||
@20-23,
|
||||
],
|
||||
space_before: [
|
||||
Slice { start: 0, length: 0 },
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
space_after: [
|
||||
Slice { start: 0, length: 0 },
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
spaces: [],
|
||||
type_defs: [],
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
---
|
||||
source: crates/compiler/can/tests/test_suffixed.rs
|
||||
expression: snapshot
|
||||
snapshot_kind: text
|
||||
---
|
||||
Defs {
|
||||
tags: [
|
||||
|
@ -10,10 +11,10 @@ Defs {
|
|||
@0-26,
|
||||
],
|
||||
space_before: [
|
||||
Slice { start: 0, length: 0 },
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
space_after: [
|
||||
Slice { start: 0, length: 1 },
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 1 },
|
||||
],
|
||||
spaces: [
|
||||
Newline,
|
||||
|
|
|
@ -11,10 +11,10 @@ Defs {
|
|||
@0-72,
|
||||
],
|
||||
space_before: [
|
||||
Slice { start: 0, length: 0 },
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
space_after: [
|
||||
Slice { start: 0, length: 1 },
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 1 },
|
||||
],
|
||||
spaces: [
|
||||
Newline,
|
||||
|
@ -40,10 +40,10 @@ Defs {
|
|||
@11-23,
|
||||
],
|
||||
space_before: [
|
||||
Slice { start: 0, length: 0 },
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
space_after: [
|
||||
Slice { start: 0, length: 0 },
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
spaces: [],
|
||||
type_defs: [],
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
---
|
||||
source: crates/compiler/can/tests/test_suffixed.rs
|
||||
expression: snapshot
|
||||
snapshot_kind: text
|
||||
---
|
||||
Defs {
|
||||
tags: [
|
||||
|
@ -10,10 +11,10 @@ Defs {
|
|||
@0-51,
|
||||
],
|
||||
space_before: [
|
||||
Slice { start: 0, length: 0 },
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
space_after: [
|
||||
Slice { start: 0, length: 1 },
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 1 },
|
||||
],
|
||||
spaces: [
|
||||
Newline,
|
||||
|
@ -33,10 +34,10 @@ Defs {
|
|||
@17-24,
|
||||
],
|
||||
space_before: [
|
||||
Slice { start: 0, length: 0 },
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
space_after: [
|
||||
Slice { start: 0, length: 0 },
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
spaces: [],
|
||||
type_defs: [],
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
---
|
||||
source: crates/compiler/can/tests/test_suffixed.rs
|
||||
expression: snapshot
|
||||
snapshot_kind: text
|
||||
---
|
||||
Defs {
|
||||
tags: [
|
||||
|
@ -10,10 +11,10 @@ Defs {
|
|||
@0-24,
|
||||
],
|
||||
space_before: [
|
||||
Slice { start: 0, length: 0 },
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
space_after: [
|
||||
Slice { start: 0, length: 1 },
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 1 },
|
||||
],
|
||||
spaces: [
|
||||
Newline,
|
||||
|
@ -39,10 +40,10 @@ Defs {
|
|||
@11-16,
|
||||
],
|
||||
space_before: [
|
||||
Slice { start: 0, length: 0 },
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
space_after: [
|
||||
Slice { start: 0, length: 0 },
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
spaces: [],
|
||||
type_defs: [],
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
---
|
||||
source: crates/compiler/can/tests/test_suffixed.rs
|
||||
expression: snapshot
|
||||
snapshot_kind: text
|
||||
---
|
||||
Defs {
|
||||
tags: [
|
||||
|
@ -10,10 +11,10 @@ Defs {
|
|||
@0-61,
|
||||
],
|
||||
space_before: [
|
||||
Slice { start: 0, length: 0 },
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
space_after: [
|
||||
Slice { start: 0, length: 1 },
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 1 },
|
||||
],
|
||||
spaces: [
|
||||
Newline,
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
---
|
||||
source: crates/compiler/can/tests/test_suffixed.rs
|
||||
expression: snapshot
|
||||
snapshot_kind: text
|
||||
---
|
||||
Defs {
|
||||
tags: [
|
||||
|
@ -10,10 +11,10 @@ Defs {
|
|||
@0-49,
|
||||
],
|
||||
space_before: [
|
||||
Slice { start: 0, length: 0 },
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
space_after: [
|
||||
Slice { start: 0, length: 1 },
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 1 },
|
||||
],
|
||||
spaces: [
|
||||
Newline,
|
||||
|
@ -33,10 +34,10 @@ Defs {
|
|||
@23-42,
|
||||
],
|
||||
space_before: [
|
||||
Slice { start: 0, length: 0 },
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
space_after: [
|
||||
Slice { start: 0, length: 0 },
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
spaces: [],
|
||||
type_defs: [],
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
---
|
||||
source: crates/compiler/can/tests/test_suffixed.rs
|
||||
expression: snapshot
|
||||
snapshot_kind: text
|
||||
---
|
||||
Defs {
|
||||
tags: [
|
||||
|
@ -10,10 +11,10 @@ Defs {
|
|||
@0-22,
|
||||
],
|
||||
space_before: [
|
||||
Slice { start: 0, length: 0 },
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
space_after: [
|
||||
Slice { start: 0, length: 1 },
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 1 },
|
||||
],
|
||||
spaces: [
|
||||
Newline,
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
---
|
||||
source: crates/compiler/can/tests/test_suffixed.rs
|
||||
expression: snapshot
|
||||
snapshot_kind: text
|
||||
---
|
||||
Defs {
|
||||
tags: [
|
||||
|
@ -10,10 +11,10 @@ Defs {
|
|||
@0-51,
|
||||
],
|
||||
space_before: [
|
||||
Slice { start: 0, length: 0 },
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
space_after: [
|
||||
Slice { start: 0, length: 1 },
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 1 },
|
||||
],
|
||||
spaces: [
|
||||
Newline,
|
||||
|
@ -33,10 +34,10 @@ Defs {
|
|||
@11-40,
|
||||
],
|
||||
space_before: [
|
||||
Slice { start: 0, length: 0 },
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
space_after: [
|
||||
Slice { start: 0, length: 0 },
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
spaces: [],
|
||||
type_defs: [],
|
||||
|
@ -60,10 +61,10 @@ Defs {
|
|||
@11-12,
|
||||
],
|
||||
space_before: [
|
||||
Slice { start: 0, length: 0 },
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
space_after: [
|
||||
Slice { start: 0, length: 0 },
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
spaces: [],
|
||||
type_defs: [],
|
||||
|
|
|
@ -11,10 +11,10 @@ Defs {
|
|||
@0-73,
|
||||
],
|
||||
space_before: [
|
||||
Slice { start: 0, length: 0 },
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
space_after: [
|
||||
Slice { start: 0, length: 1 },
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 1 },
|
||||
],
|
||||
spaces: [
|
||||
Newline,
|
||||
|
@ -40,10 +40,10 @@ Defs {
|
|||
@11-57,
|
||||
],
|
||||
space_before: [
|
||||
Slice { start: 0, length: 0 },
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
space_after: [
|
||||
Slice { start: 0, length: 0 },
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
spaces: [],
|
||||
type_defs: [],
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
---
|
||||
source: crates/compiler/can/tests/test_suffixed.rs
|
||||
expression: snapshot
|
||||
snapshot_kind: text
|
||||
---
|
||||
Defs {
|
||||
tags: [
|
||||
|
@ -10,10 +11,10 @@ Defs {
|
|||
@0-67,
|
||||
],
|
||||
space_before: [
|
||||
Slice { start: 0, length: 0 },
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
space_after: [
|
||||
Slice { start: 0, length: 1 },
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 1 },
|
||||
],
|
||||
spaces: [
|
||||
Newline,
|
||||
|
@ -48,10 +49,10 @@ Defs {
|
|||
@19-30,
|
||||
],
|
||||
space_before: [
|
||||
Slice { start: 0, length: 0 },
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
space_after: [
|
||||
Slice { start: 0, length: 0 },
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
spaces: [],
|
||||
type_defs: [],
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
---
|
||||
source: crates/compiler/can/tests/test_suffixed.rs
|
||||
expression: snapshot
|
||||
snapshot_kind: text
|
||||
---
|
||||
Defs {
|
||||
tags: [
|
||||
|
@ -10,10 +11,10 @@ Defs {
|
|||
@0-154,
|
||||
],
|
||||
space_before: [
|
||||
Slice { start: 0, length: 0 },
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
space_after: [
|
||||
Slice { start: 0, length: 1 },
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 1 },
|
||||
],
|
||||
spaces: [
|
||||
Newline,
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
---
|
||||
source: crates/compiler/can/tests/test_suffixed.rs
|
||||
expression: snapshot
|
||||
snapshot_kind: text
|
||||
---
|
||||
Defs {
|
||||
tags: [
|
||||
|
@ -10,10 +11,10 @@ Defs {
|
|||
@0-44,
|
||||
],
|
||||
space_before: [
|
||||
Slice { start: 0, length: 0 },
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
space_after: [
|
||||
Slice { start: 0, length: 1 },
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 1 },
|
||||
],
|
||||
spaces: [
|
||||
Newline,
|
||||
|
@ -45,10 +46,10 @@ Defs {
|
|||
@28-29,
|
||||
],
|
||||
space_before: [
|
||||
Slice { start: 0, length: 0 },
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
space_after: [
|
||||
Slice { start: 0, length: 0 },
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
spaces: [],
|
||||
type_defs: [],
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
---
|
||||
source: crates/compiler/can/tests/test_suffixed.rs
|
||||
expression: snapshot
|
||||
snapshot_kind: text
|
||||
---
|
||||
Defs {
|
||||
tags: [
|
||||
|
@ -10,10 +11,10 @@ Defs {
|
|||
@0-45,
|
||||
],
|
||||
space_before: [
|
||||
Slice { start: 0, length: 0 },
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
space_after: [
|
||||
Slice { start: 0, length: 1 },
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 1 },
|
||||
],
|
||||
spaces: [
|
||||
Newline,
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
---
|
||||
source: crates/compiler/can/tests/test_suffixed.rs
|
||||
expression: snapshot
|
||||
snapshot_kind: text
|
||||
---
|
||||
Defs {
|
||||
tags: [
|
||||
|
@ -10,10 +11,10 @@ Defs {
|
|||
@0-120,
|
||||
],
|
||||
space_before: [
|
||||
Slice { start: 0, length: 0 },
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
space_after: [
|
||||
Slice { start: 0, length: 1 },
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 1 },
|
||||
],
|
||||
spaces: [
|
||||
Newline,
|
||||
|
@ -67,10 +68,10 @@ Defs {
|
|||
@54-65,
|
||||
],
|
||||
space_before: [
|
||||
Slice { start: 0, length: 0 },
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
space_after: [
|
||||
Slice { start: 0, length: 0 },
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
spaces: [],
|
||||
type_defs: [],
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
---
|
||||
source: crates/compiler/can/tests/test_suffixed.rs
|
||||
expression: snapshot
|
||||
snapshot_kind: text
|
||||
---
|
||||
Defs {
|
||||
tags: [
|
||||
|
@ -10,10 +11,10 @@ Defs {
|
|||
@0-74,
|
||||
],
|
||||
space_before: [
|
||||
Slice { start: 0, length: 0 },
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 0 },
|
||||
],
|
||||
space_after: [
|
||||
Slice { start: 0, length: 1 },
|
||||
Slice<roc_parse::ast::CommentOrNewline> { start: 0, length: 1 },
|
||||
],
|
||||
spaces: [
|
||||
Newline,
|
||||
|
|
13
crates/compiler/can/tests/test_can_expr.rs
Normal file
13
crates/compiler/can/tests/test_can_expr.rs
Normal file
|
@ -0,0 +1,13 @@
|
|||
#[cfg(test)]
|
||||
mod test_can_expr {
|
||||
use roc_can::expr::Expr;
|
||||
use test_compile::can_expr;
|
||||
|
||||
#[test]
|
||||
fn test_can_unit() {
|
||||
let output = can_expr("{}");
|
||||
|
||||
assert_eq!(output.problems, Vec::new());
|
||||
assert!(matches!(output.expr, Expr::EmptyRecord));
|
||||
}
|
||||
}
|
|
@ -464,7 +464,7 @@ mod suffixed_tests {
|
|||
run_test!(
|
||||
r#"
|
||||
main =
|
||||
dbg (dbg 1 + 1)
|
||||
dbg (dbg (1 + 1))
|
||||
"#
|
||||
);
|
||||
}
|
||||
|
|
|
@ -8,12 +8,12 @@ license.workspace = true
|
|||
version.workspace = true
|
||||
|
||||
[dependencies]
|
||||
roc_checkmate_schema = { path = "../checkmate_schema" }
|
||||
roc_module = { path = "../module" }
|
||||
roc_solve_schema = { path = "../solve_schema" }
|
||||
roc_types = { path = "../types" }
|
||||
roc_checkmate_schema.workspace = true
|
||||
roc_module.workspace = true
|
||||
roc_solve_schema.workspace = true
|
||||
roc_types.workspace = true
|
||||
chrono.workspace = true
|
||||
|
||||
[build-dependencies]
|
||||
roc_checkmate_schema = { path = "../checkmate_schema" }
|
||||
roc_checkmate_schema.workspace = true
|
||||
serde_json.workspace = true
|
||||
|
|
|
@ -4,6 +4,7 @@
|
|||
#![allow(clippy::large_enum_variant)]
|
||||
|
||||
pub mod all;
|
||||
mod push;
|
||||
mod reference_matrix;
|
||||
mod small_string_interner;
|
||||
mod small_vec;
|
||||
|
@ -12,6 +13,7 @@ mod vec_map;
|
|||
mod vec_set;
|
||||
|
||||
pub use all::{default_hasher, BumpMap, ImEntry, ImMap, ImSet, MutMap, MutSet, SendMap};
|
||||
pub use push::Push;
|
||||
pub use reference_matrix::{ReferenceMatrix, Sccs, TopologicalSort};
|
||||
pub use small_string_interner::SmallStringInterner;
|
||||
pub use small_vec::SmallVec;
|
||||
|
|
15
crates/compiler/collections/src/push.rs
Normal file
15
crates/compiler/collections/src/push.rs
Normal file
|
@ -0,0 +1,15 @@
|
|||
pub trait Push<T> {
|
||||
fn push(&mut self, entry: T);
|
||||
}
|
||||
|
||||
impl<T> Push<T> for Vec<T> {
|
||||
fn push(&mut self, entry: T) {
|
||||
self.push(entry);
|
||||
}
|
||||
}
|
||||
|
||||
impl<T> Push<T> for &mut Vec<T> {
|
||||
fn push(&mut self, entry: T) {
|
||||
(*self).push(entry);
|
||||
}
|
||||
}
|
|
@ -8,15 +8,13 @@ license.workspace = true
|
|||
version.workspace = true
|
||||
|
||||
[dependencies]
|
||||
roc_can = { path = "../can" }
|
||||
roc_collections = { path = "../collections" }
|
||||
roc_error_macros = { path = "../../error_macros" }
|
||||
roc_module = { path = "../module" }
|
||||
roc_parse = { path = "../parse" }
|
||||
roc_problem = { path = "../problem" }
|
||||
roc_region = { path = "../region" }
|
||||
roc_types = { path = "../types" }
|
||||
|
||||
roc_can.workspace = true
|
||||
roc_collections.workspace = true
|
||||
roc_error_macros.workspace = true
|
||||
roc_module.workspace = true
|
||||
roc_parse.workspace = true
|
||||
roc_problem.workspace = true
|
||||
roc_region.workspace = true
|
||||
roc_types.workspace = true
|
||||
arrayvec.workspace = true
|
||||
|
||||
soa.workspace = true
|
||||
|
|
|
@ -64,6 +64,15 @@ pub struct Env {
|
|||
}
|
||||
|
||||
impl Env {
|
||||
pub fn new(home: ModuleId) -> Self {
|
||||
Self {
|
||||
rigids: MutMap::default(),
|
||||
resolutions_to_make: Vec::new(),
|
||||
home,
|
||||
fx_expectation: None,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn with_fx_expectation<F, T>(
|
||||
&mut self,
|
||||
fx_var: Variable,
|
||||
|
@ -1806,15 +1815,6 @@ pub fn constrain_expr(
|
|||
arg_cons.push(eq);
|
||||
constraints.exists_many(vars, arg_cons)
|
||||
}
|
||||
TypedHole(var) => {
|
||||
// store the expected type for this position
|
||||
constraints.equal_types_var(
|
||||
*var,
|
||||
expected,
|
||||
Category::Storage(std::file!(), std::line!()),
|
||||
region,
|
||||
)
|
||||
}
|
||||
RuntimeError(_) => {
|
||||
// Runtime Errors are always going to crash, so they don't introduce any new
|
||||
// constraints.
|
||||
|
@ -4405,7 +4405,6 @@ fn is_generalizable_expr(mut expr: &Expr) -> bool {
|
|||
| Expect { .. }
|
||||
| Dbg { .. }
|
||||
| Return { .. }
|
||||
| TypedHole(_)
|
||||
| RuntimeError(..)
|
||||
| ZeroArgumentTag { .. }
|
||||
| Tag { .. }
|
||||
|
|
|
@ -8,17 +8,16 @@ license.workspace = true
|
|||
version.workspace = true
|
||||
|
||||
[dependencies]
|
||||
roc_can = { path = "../can" }
|
||||
roc_checkmate = { path = "../checkmate" }
|
||||
roc_collections = { path = "../collections" }
|
||||
roc_derive_key = { path = "../derive_key" }
|
||||
roc_error_macros = { path = "../../error_macros" }
|
||||
roc_module = { path = "../module" }
|
||||
roc_region = { path = "../region" }
|
||||
roc_solve_schema = { path = "../solve_schema" }
|
||||
roc_types = { path = "../types" }
|
||||
roc_unify = { path = "../unify" }
|
||||
|
||||
roc_can.workspace = true
|
||||
roc_checkmate.workspace = true
|
||||
roc_collections.workspace = true
|
||||
roc_derive_key.workspace = true
|
||||
roc_error_macros.workspace = true
|
||||
roc_module.workspace = true
|
||||
roc_region.workspace = true
|
||||
roc_solve_schema.workspace = true
|
||||
roc_types.workspace = true
|
||||
roc_unify.workspace = true
|
||||
bumpalo.workspace = true
|
||||
|
||||
[features]
|
||||
|
|
|
@ -7,8 +7,8 @@ license.workspace = true
|
|||
version.workspace = true
|
||||
|
||||
[dependencies]
|
||||
roc_collections = { path = "../collections" }
|
||||
roc_error_macros = { path = "../../error_macros" }
|
||||
roc_module = { path = "../module" }
|
||||
roc_region = { path = "../region" }
|
||||
roc_types = { path = "../types" }
|
||||
roc_collections.workspace = true
|
||||
roc_error_macros.workspace = true
|
||||
roc_module.workspace = true
|
||||
roc_region.workspace = true
|
||||
roc_types.workspace = true
|
||||
|
|
|
@ -8,8 +8,8 @@ license.workspace = true
|
|||
version.workspace = true
|
||||
|
||||
[dependencies]
|
||||
roc_collections = { path = "../collections" }
|
||||
roc_error_macros = { path = "../../error_macros" }
|
||||
roc_module = { path = "../module" }
|
||||
roc_problem = { path = "../problem" }
|
||||
roc_region = { path = "../region" }
|
||||
roc_collections.workspace = true
|
||||
roc_error_macros.workspace = true
|
||||
roc_module.workspace = true
|
||||
roc_problem.workspace = true
|
||||
roc_region.workspace = true
|
||||
|
|
|
@ -8,10 +8,10 @@ license.workspace = true
|
|||
version.workspace = true
|
||||
|
||||
[dependencies]
|
||||
roc_collections = { path = "../collections" }
|
||||
roc_module = { path = "../module" }
|
||||
roc_parse = { path = "../parse" }
|
||||
roc_region = { path = "../region" }
|
||||
roc_error_macros = { path = "../../error_macros" }
|
||||
roc_collections.workspace = true
|
||||
roc_module.workspace = true
|
||||
roc_parse.workspace = true
|
||||
roc_region.workspace = true
|
||||
roc_error_macros.workspace = true
|
||||
|
||||
bumpalo.workspace = true
|
||||
|
|
|
@ -447,7 +447,7 @@ impl<'a> Formattable for Expr<'a> {
|
|||
buf.push_str("dbg");
|
||||
}
|
||||
DbgStmt(condition, continuation) => {
|
||||
fmt_dbg_stmt(buf, condition, continuation, self.is_multiline(), indent);
|
||||
fmt_dbg_stmt(buf, condition, continuation, parens, indent);
|
||||
}
|
||||
LowLevelDbg(_, _, _) => unreachable!(
|
||||
"LowLevelDbg should only exist after desugaring, not during formatting"
|
||||
|
@ -1022,42 +1022,15 @@ fn fmt_dbg_stmt<'a>(
|
|||
buf: &mut Buf,
|
||||
condition: &'a Loc<Expr<'a>>,
|
||||
continuation: &'a Loc<Expr<'a>>,
|
||||
_: bool,
|
||||
parens: Parens,
|
||||
indent: u16,
|
||||
) {
|
||||
buf.ensure_ends_with_newline();
|
||||
buf.indent(indent);
|
||||
buf.push_str("dbg");
|
||||
|
||||
buf.spaces(1);
|
||||
|
||||
fn should_outdent(mut expr: &Expr) -> bool {
|
||||
loop {
|
||||
match expr {
|
||||
Expr::ParensAround(_) | Expr::List(_) | Expr::Record(_) | Expr::Tuple(_) => {
|
||||
return true
|
||||
}
|
||||
Expr::SpaceAfter(inner, _) => {
|
||||
expr = inner;
|
||||
}
|
||||
_ => return false,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let inner_indent = if should_outdent(&condition.value) {
|
||||
indent
|
||||
} else {
|
||||
indent + INDENT
|
||||
};
|
||||
|
||||
let cond_value = condition.value.extract_spaces();
|
||||
|
||||
let is_defs = matches!(cond_value.item, Expr::Defs(_, _));
|
||||
|
||||
let newlines = if is_defs { Newlines::Yes } else { Newlines::No };
|
||||
|
||||
condition.format_with_options(buf, Parens::NotNeeded, newlines, inner_indent);
|
||||
Expr::Apply(
|
||||
&Loc::at_zero(Expr::Dbg),
|
||||
&[condition],
|
||||
called_via::CalledVia::Space,
|
||||
)
|
||||
.format_with_options(buf, parens, Newlines::Yes, indent);
|
||||
|
||||
// Always put a blank line after the `dbg` line(s)
|
||||
buf.ensure_ends_with_blank_line();
|
||||
|
|
|
@ -8,28 +8,26 @@ license.workspace = true
|
|||
version.workspace = true
|
||||
|
||||
[dependencies]
|
||||
roc_builtins = { path = "../builtins" }
|
||||
roc_collections = { path = "../collections" }
|
||||
roc_error_macros = { path = "../../error_macros" }
|
||||
roc_module = { path = "../module" }
|
||||
roc_mono = { path = "../mono" }
|
||||
roc_problem = { path = "../problem" }
|
||||
roc_region = { path = "../region" }
|
||||
roc_solve = { path = "../solve" }
|
||||
roc_target = { path = "../roc_target" }
|
||||
roc_types = { path = "../types" }
|
||||
roc_unify = { path = "../unify" }
|
||||
|
||||
roc_builtins.workspace = true
|
||||
roc_collections.workspace = true
|
||||
roc_error_macros.workspace = true
|
||||
roc_module.workspace = true
|
||||
roc_mono.workspace = true
|
||||
roc_problem.workspace = true
|
||||
roc_region.workspace = true
|
||||
roc_solve.workspace = true
|
||||
roc_target.workspace = true
|
||||
roc_types.workspace = true
|
||||
roc_unify.workspace = true
|
||||
bumpalo.workspace = true
|
||||
object.workspace = true
|
||||
packed_struct.workspace = true
|
||||
target-lexicon.workspace = true
|
||||
|
||||
[dev-dependencies]
|
||||
roc_can = { path = "../can" }
|
||||
roc_parse = { path = "../parse" }
|
||||
roc_std = { path = "../../roc_std" }
|
||||
|
||||
roc_can.workspace = true
|
||||
roc_parse.workspace = true
|
||||
roc_std.workspace = true
|
||||
bumpalo.workspace = true
|
||||
capstone.workspace = true
|
||||
|
||||
|
|
|
@ -1846,6 +1846,26 @@ impl Assembler<AArch64GeneralReg, AArch64FloatReg> for AArch64Assembler {
|
|||
neg_reg64_reg64(buf, dst, src);
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
fn neg_freg64_freg64(
|
||||
buf: &mut Vec<'_, u8>,
|
||||
_relocs: &mut Vec<'_, Relocation>,
|
||||
dst: AArch64FloatReg,
|
||||
src: AArch64FloatReg,
|
||||
) {
|
||||
fneg_freg_freg(buf, FloatWidth::F64, dst, src);
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
fn neg_freg32_freg32(
|
||||
buf: &mut Vec<'_, u8>,
|
||||
_relocs: &mut Vec<'_, Relocation>,
|
||||
dst: AArch64FloatReg,
|
||||
src: AArch64FloatReg,
|
||||
) {
|
||||
fneg_freg_freg(buf, FloatWidth::F32, dst, src);
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
fn sub_reg64_reg64_imm32(
|
||||
buf: &mut Vec<'_, u8>,
|
||||
|
@ -3953,6 +3973,24 @@ fn fsub_freg_freg_freg(
|
|||
buf.extend(inst.bytes());
|
||||
}
|
||||
|
||||
/// `FNEG Sd/Dd, Sn/Dn`
|
||||
#[inline(always)]
|
||||
fn fneg_freg_freg(
|
||||
buf: &mut Vec<'_, u8>,
|
||||
ftype: FloatWidth,
|
||||
dst: AArch64FloatReg,
|
||||
src: AArch64FloatReg,
|
||||
) {
|
||||
let inst =
|
||||
FloatingPointDataProcessingOneSource::new(FloatingPointDataProcessingOneSourceParams {
|
||||
ptype: ftype,
|
||||
opcode: 0b00010,
|
||||
rn: src,
|
||||
rd: dst,
|
||||
});
|
||||
buf.extend(inst.bytes());
|
||||
}
|
||||
|
||||
/// `FCMP Sn/Dn, Sm/Dm` -> Compare Sn/Dn and Sm/Dm, setting condition flags.
|
||||
#[inline(always)]
|
||||
fn fcmp_freg_freg(
|
||||
|
|
|
@ -557,6 +557,18 @@ pub trait Assembler<GeneralReg: RegTrait, FloatReg: RegTrait>: Sized + Copy {
|
|||
fn sqrt_freg32_freg32(buf: &mut Vec<'_, u8>, dst: FloatReg, src: FloatReg);
|
||||
|
||||
fn neg_reg64_reg64(buf: &mut Vec<'_, u8>, dst: GeneralReg, src: GeneralReg);
|
||||
fn neg_freg64_freg64(
|
||||
buf: &mut Vec<'_, u8>,
|
||||
relocs: &mut Vec<'_, Relocation>,
|
||||
dst: FloatReg,
|
||||
src: FloatReg,
|
||||
);
|
||||
fn neg_freg32_freg32(
|
||||
buf: &mut Vec<'_, u8>,
|
||||
relocs: &mut Vec<'_, Relocation>,
|
||||
dst: FloatReg,
|
||||
src: FloatReg,
|
||||
);
|
||||
fn mul_freg32_freg32_freg32(
|
||||
buf: &mut Vec<'_, u8>,
|
||||
dst: FloatReg,
|
||||
|
@ -1420,28 +1432,20 @@ impl<
|
|||
src2: Symbol,
|
||||
layout: InLayout<'a>,
|
||||
) {
|
||||
match self.layout_interner.get_repr(layout) {
|
||||
LayoutRepr::Builtin(Builtin::Int(width @ quadword_and_smaller!())) => {
|
||||
let intrinsic = bitcode::NUM_ADD_SATURATED_INT[width].to_string();
|
||||
match self.interner().get_repr(layout) {
|
||||
LayoutRepr::Builtin(Builtin::Int(int_width)) => {
|
||||
let intrinsic = bitcode::NUM_ADD_SATURATED_INT[int_width].to_string();
|
||||
self.build_fn_call(&dst, intrinsic, &[src1, src2], &[layout, layout], &layout);
|
||||
}
|
||||
LayoutRepr::Builtin(Builtin::Float(FloatWidth::F64)) => {
|
||||
let dst_reg = self.storage_manager.claim_float_reg(&mut self.buf, &dst);
|
||||
let src1_reg = self.storage_manager.load_to_float_reg(&mut self.buf, &src1);
|
||||
let src2_reg = self.storage_manager.load_to_float_reg(&mut self.buf, &src2);
|
||||
ASM::add_freg64_freg64_freg64(&mut self.buf, dst_reg, src1_reg, src2_reg);
|
||||
}
|
||||
LayoutRepr::Builtin(Builtin::Float(FloatWidth::F32)) => {
|
||||
let dst_reg = self.storage_manager.claim_float_reg(&mut self.buf, &dst);
|
||||
let src1_reg = self.storage_manager.load_to_float_reg(&mut self.buf, &src1);
|
||||
let src2_reg = self.storage_manager.load_to_float_reg(&mut self.buf, &src2);
|
||||
ASM::add_freg32_freg32_freg32(&mut self.buf, dst_reg, src1_reg, src2_reg);
|
||||
LayoutRepr::Builtin(Builtin::Float(_)) => {
|
||||
// saturated add is just normal add
|
||||
self.build_num_add(&dst, &src1, &src2, &layout)
|
||||
}
|
||||
LayoutRepr::Builtin(Builtin::Decimal) => {
|
||||
let intrinsic = bitcode::DEC_ADD_SATURATED.to_string();
|
||||
self.build_fn_call(&dst, intrinsic, &[src1, src2], &[layout, layout], &layout);
|
||||
}
|
||||
x => todo!("NumAddSaturated: layout, {:?}", x),
|
||||
other => internal_error!("NumAddSaturated is not defined for {other:?}"),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1469,6 +1473,30 @@ impl<
|
|||
)
|
||||
}
|
||||
|
||||
fn build_num_sub_saturated(
|
||||
&mut self,
|
||||
dst: Symbol,
|
||||
src1: Symbol,
|
||||
src2: Symbol,
|
||||
layout: InLayout<'a>,
|
||||
) {
|
||||
match self.interner().get_repr(layout) {
|
||||
LayoutRepr::Builtin(Builtin::Int(int_width)) => {
|
||||
let intrinsic = bitcode::NUM_SUB_SATURATED_INT[int_width].to_string();
|
||||
self.build_fn_call(&dst, intrinsic, &[src1, src2], &[layout, layout], &layout);
|
||||
}
|
||||
LayoutRepr::Builtin(Builtin::Float(_)) => {
|
||||
// saturated sub is just normal sub
|
||||
self.build_num_sub(&dst, &src1, &src2, &layout)
|
||||
}
|
||||
LayoutRepr::Builtin(Builtin::Decimal) => {
|
||||
let intrinsic = bitcode::DEC_SUB_SATURATED.to_string();
|
||||
self.build_fn_call(&dst, intrinsic, &[src1, src2], &[layout, layout], &layout);
|
||||
}
|
||||
other => internal_error!("NumSubSaturated is not defined for {other:?}"),
|
||||
}
|
||||
}
|
||||
|
||||
fn build_num_sub_checked(
|
||||
&mut self,
|
||||
dst: &Symbol,
|
||||
|
@ -1607,28 +1635,20 @@ impl<
|
|||
src2: Symbol,
|
||||
layout: InLayout<'a>,
|
||||
) {
|
||||
match self.layout_interner.get_repr(layout) {
|
||||
LayoutRepr::Builtin(Builtin::Int(width @ quadword_and_smaller!())) => {
|
||||
let intrinsic = bitcode::NUM_MUL_SATURATED_INT[width].to_string();
|
||||
match self.interner().get_repr(layout) {
|
||||
LayoutRepr::Builtin(Builtin::Int(int_width)) => {
|
||||
let intrinsic = bitcode::NUM_MUL_SATURATED_INT[int_width].to_string();
|
||||
self.build_fn_call(&dst, intrinsic, &[src1, src2], &[layout, layout], &layout);
|
||||
}
|
||||
LayoutRepr::Builtin(Builtin::Float(FloatWidth::F64)) => {
|
||||
let dst_reg = self.storage_manager.claim_float_reg(&mut self.buf, &dst);
|
||||
let src1_reg = self.storage_manager.load_to_float_reg(&mut self.buf, &src1);
|
||||
let src2_reg = self.storage_manager.load_to_float_reg(&mut self.buf, &src2);
|
||||
ASM::mul_freg64_freg64_freg64(&mut self.buf, dst_reg, src1_reg, src2_reg);
|
||||
}
|
||||
LayoutRepr::Builtin(Builtin::Float(FloatWidth::F32)) => {
|
||||
let dst_reg = self.storage_manager.claim_float_reg(&mut self.buf, &dst);
|
||||
let src1_reg = self.storage_manager.load_to_float_reg(&mut self.buf, &src1);
|
||||
let src2_reg = self.storage_manager.load_to_float_reg(&mut self.buf, &src2);
|
||||
ASM::mul_freg32_freg32_freg32(&mut self.buf, dst_reg, src1_reg, src2_reg);
|
||||
LayoutRepr::Builtin(Builtin::Float(_)) => {
|
||||
// saturated mul is just normal mul
|
||||
self.build_num_mul(&dst, &src1, &src2, &layout)
|
||||
}
|
||||
LayoutRepr::Builtin(Builtin::Decimal) => {
|
||||
let intrinsic = bitcode::DEC_MUL_SATURATED.to_string();
|
||||
self.build_fn_call(&dst, intrinsic, &[src1, src2], &[layout, layout], &layout);
|
||||
}
|
||||
x => todo!("NumMulSaturated: layout, {:?}", x),
|
||||
other => internal_error!("NumMulSaturated is not defined for {other:?}"),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1791,7 +1811,24 @@ impl<
|
|||
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);
|
||||
}
|
||||
x => todo!("NumNeg: layout, {:?}", x),
|
||||
LayoutRepr::F32 => {
|
||||
let dst_reg = self.storage_manager.claim_float_reg(&mut self.buf, dst);
|
||||
let src_reg = self.storage_manager.load_to_float_reg(&mut self.buf, src);
|
||||
ASM::neg_freg32_freg32(&mut self.buf, &mut self.relocs, dst_reg, src_reg);
|
||||
}
|
||||
LayoutRepr::F64 => {
|
||||
let dst_reg = self.storage_manager.claim_float_reg(&mut self.buf, dst);
|
||||
let src_reg = self.storage_manager.load_to_float_reg(&mut self.buf, src);
|
||||
ASM::neg_freg64_freg64(&mut self.buf, &mut self.relocs, dst_reg, src_reg);
|
||||
}
|
||||
LayoutRepr::DEC => self.build_fn_call(
|
||||
dst,
|
||||
bitcode::DEC_NEGATE.to_string(),
|
||||
&[*src],
|
||||
&[Layout::DEC],
|
||||
&Layout::DEC,
|
||||
),
|
||||
other => internal_error!("unreachable: NumNeg for layout, {:?}", other),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2087,27 +2124,34 @@ impl<
|
|||
}
|
||||
|
||||
fn build_num_is_nan(&mut self, dst: &Symbol, src: &Symbol, arg_layout: &InLayout<'a>) {
|
||||
let float_width = match *arg_layout {
|
||||
Layout::F32 => FloatWidth::F32,
|
||||
Layout::F64 => FloatWidth::F64,
|
||||
match *arg_layout {
|
||||
Layout::F32 => {
|
||||
let dst_reg = self.storage_manager.claim_general_reg(&mut self.buf, dst);
|
||||
let src_reg = self.storage_manager.load_to_float_reg(&mut self.buf, src);
|
||||
ASM::is_nan_freg_reg64(&mut self.buf, dst_reg, src_reg, FloatWidth::F32);
|
||||
}
|
||||
Layout::F64 => {
|
||||
let dst_reg = self.storage_manager.claim_general_reg(&mut self.buf, dst);
|
||||
let src_reg = self.storage_manager.load_to_float_reg(&mut self.buf, src);
|
||||
ASM::is_nan_freg_reg64(&mut self.buf, dst_reg, src_reg, FloatWidth::F64);
|
||||
}
|
||||
Layout::DEC => {
|
||||
let dst_reg = self.storage_manager.claim_general_reg(&mut self.buf, dst);
|
||||
// boolean "false"
|
||||
ASM::mov_reg64_imm64(&mut self.buf, dst_reg, 0);
|
||||
}
|
||||
_ => unreachable!(),
|
||||
};
|
||||
|
||||
let dst_reg = self.storage_manager.claim_general_reg(&mut self.buf, dst);
|
||||
let src_reg = self.storage_manager.load_to_float_reg(&mut self.buf, src);
|
||||
|
||||
ASM::is_nan_freg_reg64(&mut self.buf, dst_reg, src_reg, float_width);
|
||||
}
|
||||
|
||||
fn build_num_is_infinite(&mut self, dst: &Symbol, src: &Symbol, arg_layout: &InLayout<'a>) {
|
||||
let dst_reg = self.storage_manager.claim_general_reg(&mut self.buf, dst);
|
||||
let src_reg = self.storage_manager.load_to_float_reg(&mut self.buf, src);
|
||||
|
||||
self.storage_manager.with_tmp_general_reg(
|
||||
&mut self.buf,
|
||||
|_storage_manager, buf, mask_reg| {
|
||||
match *arg_layout {
|
||||
Layout::F32 => {
|
||||
match *arg_layout {
|
||||
Layout::F32 => {
|
||||
let dst_reg = self.storage_manager.claim_general_reg(&mut self.buf, dst);
|
||||
let src_reg = self.storage_manager.load_to_float_reg(&mut self.buf, src);
|
||||
self.storage_manager.with_tmp_general_reg(
|
||||
&mut self.buf,
|
||||
|_storage_manager, buf, mask_reg| {
|
||||
ASM::mov_reg64_imm64(buf, mask_reg, 0x7fff_ffff);
|
||||
ASM::xor_reg64_reg64_reg64(buf, dst_reg, dst_reg, dst_reg); // zero out dst reg
|
||||
ASM::mov_reg32_freg32(buf, dst_reg, src_reg);
|
||||
|
@ -2115,46 +2159,69 @@ impl<
|
|||
|
||||
ASM::mov_reg64_imm64(buf, mask_reg, 0x7f80_0000);
|
||||
ASM::eq_reg_reg_reg(buf, RegisterWidth::W32, dst_reg, dst_reg, mask_reg);
|
||||
}
|
||||
Layout::F64 => {
|
||||
},
|
||||
)
|
||||
}
|
||||
Layout::F64 => {
|
||||
let dst_reg = self.storage_manager.claim_general_reg(&mut self.buf, dst);
|
||||
let src_reg = self.storage_manager.load_to_float_reg(&mut self.buf, src);
|
||||
self.storage_manager.with_tmp_general_reg(
|
||||
&mut self.buf,
|
||||
|_storage_manager, buf, mask_reg| {
|
||||
ASM::mov_reg64_imm64(buf, mask_reg, 0x7fff_ffff_ffff_ffff);
|
||||
ASM::mov_reg64_freg64(buf, dst_reg, src_reg);
|
||||
ASM::and_reg64_reg64_reg64(buf, dst_reg, dst_reg, mask_reg);
|
||||
|
||||
ASM::mov_reg64_imm64(buf, mask_reg, 0x7ff0_0000_0000_0000);
|
||||
ASM::eq_reg_reg_reg(buf, RegisterWidth::W64, dst_reg, dst_reg, mask_reg);
|
||||
}
|
||||
_ => unreachable!(),
|
||||
}
|
||||
},
|
||||
);
|
||||
},
|
||||
)
|
||||
}
|
||||
Layout::DEC => {
|
||||
let dst_reg = self.storage_manager.claim_general_reg(&mut self.buf, dst);
|
||||
// boolean "false"
|
||||
ASM::mov_reg64_imm64(&mut self.buf, dst_reg, 0);
|
||||
}
|
||||
_ => unreachable!(),
|
||||
}
|
||||
}
|
||||
|
||||
fn build_num_is_finite(&mut self, dst: &Symbol, src: &Symbol, arg_layout: &InLayout<'a>) {
|
||||
let dst_reg = self.storage_manager.claim_general_reg(&mut self.buf, dst);
|
||||
let src_reg = self.storage_manager.load_to_float_reg(&mut self.buf, src);
|
||||
|
||||
self.storage_manager.with_tmp_general_reg(
|
||||
&mut self.buf,
|
||||
|_storage_manager, buf, mask_reg| {
|
||||
match *arg_layout {
|
||||
Layout::F32 => {
|
||||
match *arg_layout {
|
||||
Layout::F32 => {
|
||||
let dst_reg = self.storage_manager.claim_general_reg(&mut self.buf, dst);
|
||||
let src_reg = self.storage_manager.load_to_float_reg(&mut self.buf, src);
|
||||
self.storage_manager.with_tmp_general_reg(
|
||||
&mut self.buf,
|
||||
|_storage_manager, buf, mask_reg| {
|
||||
ASM::mov_reg64_imm64(buf, mask_reg, 0x7f80_0000);
|
||||
ASM::xor_reg64_reg64_reg64(buf, dst_reg, dst_reg, dst_reg); // zero out dst reg
|
||||
ASM::mov_reg32_freg32(buf, dst_reg, src_reg);
|
||||
ASM::and_reg64_reg64_reg64(buf, dst_reg, dst_reg, mask_reg);
|
||||
ASM::neq_reg_reg_reg(buf, RegisterWidth::W32, dst_reg, dst_reg, mask_reg);
|
||||
}
|
||||
Layout::F64 => {
|
||||
},
|
||||
)
|
||||
}
|
||||
Layout::F64 => {
|
||||
let dst_reg = self.storage_manager.claim_general_reg(&mut self.buf, dst);
|
||||
let src_reg = self.storage_manager.load_to_float_reg(&mut self.buf, src);
|
||||
self.storage_manager.with_tmp_general_reg(
|
||||
&mut self.buf,
|
||||
|_storage_manager, buf, mask_reg| {
|
||||
ASM::mov_reg64_imm64(buf, mask_reg, 0x7ff0_0000_0000_0000);
|
||||
ASM::mov_reg64_freg64(buf, dst_reg, src_reg);
|
||||
ASM::and_reg64_reg64_reg64(buf, dst_reg, dst_reg, mask_reg);
|
||||
ASM::neq_reg_reg_reg(buf, RegisterWidth::W64, dst_reg, dst_reg, mask_reg);
|
||||
}
|
||||
_ => unreachable!(),
|
||||
}
|
||||
},
|
||||
);
|
||||
},
|
||||
)
|
||||
}
|
||||
Layout::DEC => {
|
||||
let dst_reg = self.storage_manager.claim_general_reg(&mut self.buf, dst);
|
||||
// boolean "true"
|
||||
ASM::mov_reg64_imm64(&mut self.buf, dst_reg, 1);
|
||||
}
|
||||
_ => unreachable!(),
|
||||
}
|
||||
}
|
||||
|
||||
fn build_int_to_float_cast(
|
||||
|
|
|
@ -2602,6 +2602,28 @@ impl Assembler<X86_64GeneralReg, X86_64FloatReg> for X86_64Assembler {
|
|||
neg_reg64(buf, dst);
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
fn neg_freg64_freg64(
|
||||
buf: &mut Vec<'_, u8>,
|
||||
relocs: &mut Vec<'_, Relocation>,
|
||||
dst: X86_64FloatReg,
|
||||
src: X86_64FloatReg,
|
||||
) {
|
||||
Self::mov_freg64_imm64(buf, relocs, dst, f64::from_bits(0x8000_0000_0000_0000));
|
||||
xorpd_freg64_freg64(buf, dst, src);
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
fn neg_freg32_freg32(
|
||||
buf: &mut Vec<'_, u8>,
|
||||
relocs: &mut Vec<'_, Relocation>,
|
||||
dst: X86_64FloatReg,
|
||||
src: X86_64FloatReg,
|
||||
) {
|
||||
Self::mov_freg32_imm32(buf, relocs, dst, f32::from_bits(0x8000_0000));
|
||||
xorps_freg32_freg32(buf, dst, src);
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
fn sub_reg64_reg64_imm32(
|
||||
buf: &mut Vec<'_, u8>,
|
||||
|
@ -3352,6 +3374,49 @@ fn sqrtss_freg32_freg32(buf: &mut Vec<'_, u8>, dst: X86_64FloatReg, src: X86_64F
|
|||
}
|
||||
}
|
||||
|
||||
/// `XORPD xmm1, xmm2/m128` -> Bitwise exclusive-OR of xmm2/m128 and xmm1.
|
||||
#[inline(always)]
|
||||
fn xorpd_freg64_freg64(buf: &mut Vec<'_, u8>, dst: X86_64FloatReg, src: X86_64FloatReg) {
|
||||
let dst_high = dst as u8 > 7;
|
||||
let dst_mod = dst as u8 % 8;
|
||||
|
||||
let src_high = src as u8 > 7;
|
||||
let src_mod = src as u8 % 8;
|
||||
|
||||
if dst_high || src_high {
|
||||
buf.extend([
|
||||
0x66,
|
||||
0x40 | ((dst_high as u8) << 2) | (src_high as u8),
|
||||
0x0F,
|
||||
0x57,
|
||||
0xC0 | (dst_mod << 3) | src_mod,
|
||||
])
|
||||
} else {
|
||||
buf.extend([0x66, 0x0F, 0x57, 0xC0 | (dst_mod << 3) | src_mod]);
|
||||
}
|
||||
}
|
||||
|
||||
/// `XORPS xmm1,xmm2/m128` -> Bitwise exclusive-OR of xmm2/m128 and xmm1.
|
||||
#[inline(always)]
|
||||
fn xorps_freg32_freg32(buf: &mut Vec<'_, u8>, dst: X86_64FloatReg, src: X86_64FloatReg) {
|
||||
let dst_high = dst as u8 > 7;
|
||||
let dst_mod = dst as u8 % 8;
|
||||
|
||||
let src_high = src as u8 > 7;
|
||||
let src_mod = src as u8 % 8;
|
||||
|
||||
if dst_high || src_high {
|
||||
buf.extend([
|
||||
0x40 | ((dst_high as u8) << 2) | (src_high as u8),
|
||||
0x0F,
|
||||
0x57,
|
||||
0xC0 | (dst_mod << 3) | src_mod,
|
||||
]);
|
||||
} else {
|
||||
buf.extend([0x0F, 0x57, 0xC0 | (dst_mod << 3) | src_mod]);
|
||||
}
|
||||
}
|
||||
|
||||
/// `TEST r/m64,r64` -> AND r64 with r/m64; set SF, ZF, PF according to result.
|
||||
#[allow(dead_code)]
|
||||
#[inline(always)]
|
||||
|
|
|
@ -209,7 +209,6 @@ impl<'a> LastSeenMap<'a> {
|
|||
self.set_last_seen(*initializer, stmt);
|
||||
}
|
||||
}
|
||||
Expr::RuntimeErrorFunction(_) => {}
|
||||
Expr::FunctionPointer { .. } => todo_lambda_erasure!(),
|
||||
Expr::EmptyArray => {}
|
||||
}
|
||||
|
@ -1003,11 +1002,10 @@ trait Backend<'a> {
|
|||
} => {
|
||||
self.build_alloca(*sym, *initializer, *element_layout);
|
||||
}
|
||||
Expr::RuntimeErrorFunction(_) => todo!(),
|
||||
}
|
||||
}
|
||||
|
||||
/// build_run_low_level builds the low level opertation and outputs to the specified symbol.
|
||||
/// build_run_low_level builds the low level operation and outputs to the specified symbol.
|
||||
/// The builder must keep track of the symbol because it may be referred to later.
|
||||
fn build_run_low_level(
|
||||
&mut self,
|
||||
|
@ -1070,9 +1068,6 @@ trait Backend<'a> {
|
|||
LowLevel::NumAddChecked => {
|
||||
self.build_num_add_checked(sym, &args[0], &args[1], &arg_layouts[0], ret_layout)
|
||||
}
|
||||
LowLevel::NumSubChecked => {
|
||||
self.build_num_sub_checked(sym, &args[0], &args[1], &arg_layouts[0], ret_layout)
|
||||
}
|
||||
LowLevel::NumAcos => self.build_fn_call(
|
||||
sym,
|
||||
bitcode::NUM_ACOS[FloatWidth::F64].to_string(),
|
||||
|
@ -1241,27 +1236,12 @@ trait Backend<'a> {
|
|||
);
|
||||
self.build_num_sub_wrap(sym, &args[0], &args[1], ret_layout)
|
||||
}
|
||||
LowLevel::NumSubSaturated => match self.interner().get_repr(*ret_layout) {
|
||||
LayoutRepr::Builtin(Builtin::Int(int_width)) => self.build_fn_call(
|
||||
sym,
|
||||
bitcode::NUM_SUB_SATURATED_INT[int_width].to_string(),
|
||||
args,
|
||||
arg_layouts,
|
||||
ret_layout,
|
||||
),
|
||||
LayoutRepr::Builtin(Builtin::Float(FloatWidth::F32)) => {
|
||||
self.build_num_sub(sym, &args[0], &args[1], ret_layout)
|
||||
}
|
||||
LayoutRepr::Builtin(Builtin::Float(FloatWidth::F64)) => {
|
||||
// saturated sub is just normal sub
|
||||
self.build_num_sub(sym, &args[0], &args[1], ret_layout)
|
||||
}
|
||||
LayoutRepr::Builtin(Builtin::Decimal) => {
|
||||
// self.load_args_and_call_zig(backend, bitcode::DEC_SUB_SATURATED)
|
||||
todo!()
|
||||
}
|
||||
_ => internal_error!("invalid return type"),
|
||||
},
|
||||
LowLevel::NumSubSaturated => {
|
||||
self.build_num_sub_saturated(*sym, args[0], args[1], *ret_layout)
|
||||
}
|
||||
LowLevel::NumSubChecked => {
|
||||
self.build_num_sub_checked(sym, &args[0], &args[1], &arg_layouts[0], ret_layout)
|
||||
}
|
||||
LowLevel::NumBitwiseAnd => {
|
||||
if let LayoutRepr::Builtin(Builtin::Int(int_width)) =
|
||||
self.interner().get_repr(*ret_layout)
|
||||
|
@ -2394,16 +2374,6 @@ trait Backend<'a> {
|
|||
layout: &InLayout<'a>,
|
||||
);
|
||||
|
||||
/// build_num_sub_checked stores the sum of src1 and src2 into dst.
|
||||
fn build_num_sub_checked(
|
||||
&mut self,
|
||||
dst: &Symbol,
|
||||
src1: &Symbol,
|
||||
src2: &Symbol,
|
||||
num_layout: &InLayout<'a>,
|
||||
return_layout: &InLayout<'a>,
|
||||
);
|
||||
|
||||
/// build_num_mul stores `src1 * src2` into dst.
|
||||
fn build_num_mul(&mut self, dst: &Symbol, src1: &Symbol, src2: &Symbol, layout: &InLayout<'a>);
|
||||
|
||||
|
@ -2462,6 +2432,25 @@ trait Backend<'a> {
|
|||
layout: &InLayout<'a>,
|
||||
);
|
||||
|
||||
/// build_num_sub_saturated stores the `src1 - src2` difference into dst.
|
||||
fn build_num_sub_saturated(
|
||||
&mut self,
|
||||
dst: Symbol,
|
||||
src1: Symbol,
|
||||
src2: Symbol,
|
||||
layout: InLayout<'a>,
|
||||
);
|
||||
|
||||
/// build_num_sub_checked stores the difference of src1 and src2 into dst.
|
||||
fn build_num_sub_checked(
|
||||
&mut self,
|
||||
dst: &Symbol,
|
||||
src1: &Symbol,
|
||||
src2: &Symbol,
|
||||
num_layout: &InLayout<'a>,
|
||||
return_layout: &InLayout<'a>,
|
||||
);
|
||||
|
||||
/// stores the `src1 & src2` into dst.
|
||||
fn build_int_bitwise_and(
|
||||
&mut self,
|
||||
|
|
|
@ -8,19 +8,18 @@ license.workspace = true
|
|||
version.workspace = true
|
||||
|
||||
[dependencies]
|
||||
morphic_lib = { path = "../../vendor/morphic_lib" }
|
||||
roc_alias_analysis = { path = "../alias_analysis" }
|
||||
roc_bitcode_bc = { path = "../builtins/bitcode/bc" }
|
||||
roc_builtins = { path = "../builtins" }
|
||||
roc_collections = { path = "../collections" }
|
||||
roc_debug_flags = { path = "../debug_flags" }
|
||||
roc_error_macros = { path = "../../error_macros" }
|
||||
roc_module = { path = "../module" }
|
||||
roc_mono = { path = "../mono" }
|
||||
roc_region = { path = "../region" }
|
||||
roc_std = { path = "../../roc_std" }
|
||||
roc_target = { path = "../roc_target" }
|
||||
|
||||
morphic_lib.workspace = true
|
||||
roc_alias_analysis.workspace = true
|
||||
roc_bitcode_bc.workspace = true
|
||||
roc_builtins.workspace = true
|
||||
roc_collections.workspace = true
|
||||
roc_debug_flags.workspace = true
|
||||
roc_error_macros.workspace = true
|
||||
roc_module.workspace = true
|
||||
roc_mono.workspace = true
|
||||
roc_region.workspace = true
|
||||
roc_std.workspace = true
|
||||
roc_target.workspace = true
|
||||
bumpalo.workspace = true
|
||||
inkwell.workspace = true
|
||||
target-lexicon.workspace = true
|
||||
|
|
|
@ -12,8 +12,8 @@ use crate::llvm::refcounting::{
|
|||
use inkwell::attributes::{Attribute, AttributeLoc};
|
||||
use inkwell::types::{BasicType, BasicTypeEnum, StructType};
|
||||
use inkwell::values::{
|
||||
BasicValueEnum, CallSiteValue, FunctionValue, InstructionValue, IntValue, PointerValue,
|
||||
StructValue,
|
||||
BasicValue, BasicValueEnum, CallSiteValue, FunctionValue, InstructionValue, IntValue,
|
||||
PointerValue, StructValue,
|
||||
};
|
||||
use inkwell::AddressSpace;
|
||||
use roc_error_macros::internal_error;
|
||||
|
@ -47,6 +47,28 @@ pub fn call_bitcode_fn<'ctx>(
|
|||
.build_bitcast(ret, env.context.i128_type(), "return_i128")
|
||||
.unwrap();
|
||||
}
|
||||
} else if env.target == roc_target::Target::MacArm64 {
|
||||
// Essentially the same happens on macos arm64, but with array type [2xi64].
|
||||
let i64_type = env.context.i64_type();
|
||||
let arr_type = i64_type.array_type(2);
|
||||
if ret.get_type() == arr_type.into() {
|
||||
let alloca = env
|
||||
.builder
|
||||
.build_array_alloca(i64_type, i64_type.const_int(2, false), "dec_alloca")
|
||||
.unwrap_or_else(|err| internal_error!("failed to build array alloca: {err}"));
|
||||
let instruction = alloca.as_instruction_value().unwrap_or_else(|| {
|
||||
internal_error!("failed to convert pointer to instruction value ({alloca:?})");
|
||||
});
|
||||
instruction.set_alignment(16).unwrap_or_else(|err| {
|
||||
internal_error!(
|
||||
"failed to set 16-byte alignment on instruction ({instruction:?}): {err}"
|
||||
);
|
||||
});
|
||||
env.builder.new_build_store(alloca, ret);
|
||||
return env
|
||||
.builder
|
||||
.new_build_load(env.context.i128_type(), alloca, "return_i128");
|
||||
}
|
||||
}
|
||||
|
||||
ret
|
||||
|
|
|
@ -1908,7 +1908,6 @@ pub(crate) fn build_exp_expr<'a, 'ctx>(
|
|||
Array { elem_layout, elems } => {
|
||||
list_literal(env, layout_interner, scope, *elem_layout, elems)
|
||||
}
|
||||
RuntimeErrorFunction(_) => todo!(),
|
||||
|
||||
UnionAtIndex {
|
||||
tag_id,
|
||||
|
|
|
@ -1758,7 +1758,7 @@ fn build_float_binop<'ctx>(
|
|||
};
|
||||
|
||||
match op {
|
||||
NumAdd => bd.new_build_float_add(lhs, rhs, "add_float").into(),
|
||||
NumAdd | NumAddSaturated => bd.new_build_float_add(lhs, rhs, "add_float").into(),
|
||||
NumAddChecked => {
|
||||
let context = env.context;
|
||||
|
||||
|
@ -1785,7 +1785,7 @@ fn build_float_binop<'ctx>(
|
|||
struct_value.into()
|
||||
}
|
||||
NumAddWrap => unreachable!("wrapping addition is not defined on floats"),
|
||||
NumSub => bd.new_build_float_sub(lhs, rhs, "sub_float").into(),
|
||||
NumSub | NumSubSaturated => bd.new_build_float_sub(lhs, rhs, "sub_float").into(),
|
||||
NumSubChecked => {
|
||||
let context = env.context;
|
||||
|
||||
|
@ -1812,8 +1812,7 @@ fn build_float_binop<'ctx>(
|
|||
struct_value.into()
|
||||
}
|
||||
NumSubWrap => unreachable!("wrapping subtraction is not defined on floats"),
|
||||
NumMul => bd.new_build_float_mul(lhs, rhs, "mul_float").into(),
|
||||
NumMulSaturated => bd.new_build_float_mul(lhs, rhs, "mul_float").into(),
|
||||
NumMul | NumMulSaturated => bd.new_build_float_mul(lhs, rhs, "mul_float").into(),
|
||||
NumMulChecked => {
|
||||
let context = env.context;
|
||||
|
||||
|
@ -1855,7 +1854,7 @@ fn build_float_binop<'ctx>(
|
|||
&bitcode::NUM_POW[float_width],
|
||||
),
|
||||
_ => {
|
||||
unreachable!("Unrecognized int binary operation: {:?}", op);
|
||||
unreachable!("Unrecognized float binary operation: {:?}", op);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2215,6 +2214,7 @@ fn build_dec_unary_op<'a, 'ctx>(
|
|||
|
||||
match op {
|
||||
NumAbs => dec_unary_op(env, bitcode::DEC_ABS, arg),
|
||||
NumNeg => dec_unary_op(env, bitcode::DEC_NEGATE, arg),
|
||||
NumAcos => dec_unary_op(env, bitcode::DEC_ACOS, arg),
|
||||
NumAsin => dec_unary_op(env, bitcode::DEC_ASIN, arg),
|
||||
NumAtan => dec_unary_op(env, bitcode::DEC_ATAN, arg),
|
||||
|
@ -2226,6 +2226,11 @@ fn build_dec_unary_op<'a, 'ctx>(
|
|||
NumFloor => dec_unary_op(env, &bitcode::DEC_FLOOR[int_width()], arg),
|
||||
NumCeiling => dec_unary_op(env, &bitcode::DEC_CEILING[int_width()], arg),
|
||||
|
||||
// return constant value bools
|
||||
NumIsFinite => env.context.bool_type().const_int(1, false).into(),
|
||||
NumIsInfinite => env.context.bool_type().const_int(0, false).into(),
|
||||
NumIsNan => env.context.bool_type().const_int(0, false).into(),
|
||||
|
||||
_ => {
|
||||
unreachable!("Unrecognized dec unary operation: {:?}", op);
|
||||
}
|
||||
|
@ -2280,6 +2285,9 @@ fn build_dec_binop<'a, 'ctx>(
|
|||
rhs,
|
||||
"Decimal multiplication overflowed",
|
||||
),
|
||||
NumAddSaturated => dec_binary_op(env, bitcode::DEC_ADD_SATURATED, lhs, rhs),
|
||||
NumSubSaturated => dec_binary_op(env, bitcode::DEC_SUB_SATURATED, lhs, rhs),
|
||||
NumMulSaturated => dec_binary_op(env, bitcode::DEC_MUL_SATURATED, lhs, rhs),
|
||||
NumDivFrac => dec_binop_with_unchecked(env, bitcode::DEC_DIV, lhs, rhs),
|
||||
|
||||
NumLt => call_bitcode_fn(env, &[lhs, rhs], &bitcode::NUM_LESS_THAN[IntWidth::I128]),
|
||||
|
|
|
@ -8,14 +8,13 @@ license.workspace = true
|
|||
version.workspace = true
|
||||
|
||||
[dependencies]
|
||||
roc_builtins = { path = "../builtins" }
|
||||
roc_collections = { path = "../collections" }
|
||||
roc_error_macros = { path = "../../error_macros" }
|
||||
roc_module = { path = "../module" }
|
||||
roc_mono = { path = "../mono" }
|
||||
roc_std = { path = "../../roc_std" }
|
||||
roc_target = { path = "../roc_target" }
|
||||
roc_wasm_module = { path = "../../wasm_module" }
|
||||
|
||||
roc_builtins.workspace = true
|
||||
roc_collections.workspace = true
|
||||
roc_error_macros.workspace = true
|
||||
roc_module.workspace = true
|
||||
roc_mono.workspace = true
|
||||
roc_std.workspace = true
|
||||
roc_target.workspace = true
|
||||
roc_wasm_module.workspace = true
|
||||
bitvec.workspace = true
|
||||
bumpalo.workspace = true
|
||||
|
|
|
@ -1009,10 +1009,6 @@ impl<'a, 'r> WasmBackend<'a, 'r> {
|
|||
initializer,
|
||||
element_layout,
|
||||
} => self.expr_alloca(*initializer, *element_layout, storage),
|
||||
|
||||
Expr::RuntimeErrorFunction(_) => {
|
||||
todo!("Expression `{}`", expr.to_pretty(100, false))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1624,6 +1624,7 @@ impl<'a> LowLevelCall<'a> {
|
|||
}
|
||||
F32 => backend.code_builder.f32_neg(),
|
||||
F64 => backend.code_builder.f64_neg(),
|
||||
Decimal => self.load_args_and_call_zig(backend, bitcode::DEC_NEGATE),
|
||||
_ => todo!("{:?} for {:?}", self.lowlevel, self.ret_layout),
|
||||
}
|
||||
}
|
||||
|
@ -1828,24 +1829,12 @@ impl<'a> LowLevelCall<'a> {
|
|||
_ => panic_ret_type(),
|
||||
}
|
||||
}
|
||||
NumPowInt => {
|
||||
self.load_args(backend);
|
||||
let base_type = CodeGenNumType::for_symbol(backend, self.arguments[0]);
|
||||
let exponent_type = CodeGenNumType::for_symbol(backend, self.arguments[1]);
|
||||
let ret_type = CodeGenNumType::from(self.ret_layout);
|
||||
|
||||
debug_assert!(base_type == exponent_type);
|
||||
debug_assert!(exponent_type == ret_type);
|
||||
|
||||
let width = match ret_type {
|
||||
CodeGenNumType::I32 => IntWidth::I32,
|
||||
CodeGenNumType::I64 => IntWidth::I64,
|
||||
CodeGenNumType::I128 => todo!("{:?} for I128", self.lowlevel),
|
||||
_ => internal_error!("Invalid return type for pow: {:?}", ret_type),
|
||||
};
|
||||
|
||||
self.load_args_and_call_zig(backend, &bitcode::NUM_POW_INT[width])
|
||||
}
|
||||
NumPowInt => match self.ret_layout_raw {
|
||||
LayoutRepr::Builtin(Builtin::Int(width)) => {
|
||||
self.load_args_and_call_zig(backend, &bitcode::NUM_POW_INT[width])
|
||||
}
|
||||
_ => panic_ret_type(),
|
||||
},
|
||||
|
||||
NumIsNan => num_is_nan(backend, self.arguments[0]),
|
||||
NumIsInfinite => num_is_infinite(backend, self.arguments[0]),
|
||||
|
|
|
@ -8,15 +8,14 @@ license.workspace = true
|
|||
version.workspace = true
|
||||
|
||||
[dependencies]
|
||||
roc_can = { path = "../can" }
|
||||
roc_checkmate = { path = "../checkmate" }
|
||||
roc_collections = { path = "../collections" }
|
||||
roc_derive = { path = "../derive" }
|
||||
roc_error_macros = { path = "../../error_macros" }
|
||||
roc_module = { path = "../module" }
|
||||
roc_solve = { path = "../solve" }
|
||||
roc_solve_schema = { path = "../solve_schema" }
|
||||
roc_types = { path = "../types" }
|
||||
roc_unify = { path = "../unify" }
|
||||
|
||||
roc_can.workspace = true
|
||||
roc_checkmate.workspace = true
|
||||
roc_collections.workspace = true
|
||||
roc_derive.workspace = true
|
||||
roc_error_macros.workspace = true
|
||||
roc_module.workspace = true
|
||||
roc_solve.workspace = true
|
||||
roc_solve_schema.workspace = true
|
||||
roc_types.workspace = true
|
||||
roc_unify.workspace = true
|
||||
bumpalo.workspace = true
|
||||
|
|
|
@ -8,40 +8,38 @@ license.workspace = true
|
|||
version.workspace = true
|
||||
|
||||
[dependencies]
|
||||
roc_can = { path = "../can" }
|
||||
roc_collections = { path = "../collections" }
|
||||
roc_load_internal = { path = "../load_internal" }
|
||||
roc_module = { path = "../module" }
|
||||
roc_packaging = { path = "../../packaging" }
|
||||
roc_reporting = { path = "../../reporting" }
|
||||
roc_solve = { path = "../solve" }
|
||||
roc_target = { path = "../roc_target" }
|
||||
roc_types = { path = "../types" }
|
||||
|
||||
roc_can.workspace = true
|
||||
roc_collections.workspace = true
|
||||
roc_load_internal.workspace = true
|
||||
roc_module.workspace = true
|
||||
roc_packaging.workspace = true
|
||||
roc_reporting.workspace = true
|
||||
roc_solve.workspace = true
|
||||
roc_target.workspace = true
|
||||
roc_types.workspace = true
|
||||
bumpalo.workspace = true
|
||||
|
||||
[build-dependencies]
|
||||
roc_builtins = { path = "../builtins" }
|
||||
roc_can = { path = "../can" }
|
||||
roc_module = { path = "../module" }
|
||||
roc_packaging = { path = "../../packaging" }
|
||||
roc_reporting = { path = "../../reporting" }
|
||||
roc_solve = { path = "../solve" }
|
||||
roc_target = { path = "../roc_target" }
|
||||
roc_error_macros = { path = "../../error_macros" }
|
||||
roc_load_internal = { path = "../load_internal" }
|
||||
roc_builtins.workspace = true
|
||||
roc_can.workspace = true
|
||||
roc_module.workspace = true
|
||||
roc_packaging.workspace = true
|
||||
roc_reporting.workspace = true
|
||||
roc_solve.workspace = true
|
||||
roc_target.workspace = true
|
||||
roc_error_macros.workspace = true
|
||||
roc_load_internal.workspace = true
|
||||
bumpalo.workspace = true
|
||||
|
||||
[dev-dependencies]
|
||||
roc_constrain = { path = "../constrain" }
|
||||
roc_derive = { path = "../derive" }
|
||||
roc_parse = { path = "../parse" }
|
||||
roc_problem = { path = "../problem" }
|
||||
roc_region = { path = "../region" }
|
||||
roc_solve_problem = { path = "../solve_problem" }
|
||||
ven_pretty = { path = "../../vendor/pretty" }
|
||||
roc_test_utils_dir = { path = "../../test_utils_dir" }
|
||||
|
||||
roc_constrain.workspace = true
|
||||
roc_derive.workspace = true
|
||||
roc_parse.workspace = true
|
||||
roc_problem.workspace = true
|
||||
roc_region.workspace = true
|
||||
roc_solve_problem.workspace = true
|
||||
ven_pretty.workspace = true
|
||||
roc_test_utils_dir.workspace = true
|
||||
indoc.workspace = true
|
||||
insta.workspace = true
|
||||
pretty_assertions.workspace = true
|
||||
|
|
|
@ -53,6 +53,7 @@ pub fn infer_expr(
|
|||
function_kind: FunctionKind::LambdaSet,
|
||||
module_params: None,
|
||||
module_params_vars: Default::default(),
|
||||
host_exposed_symbols: None,
|
||||
#[cfg(debug_assertions)]
|
||||
checkmate: None,
|
||||
};
|
||||
|
@ -189,6 +190,24 @@ pub fn can_expr_with<'a>(
|
|||
// rules multiple times unnecessarily.
|
||||
let loc_expr = desugar::desugar_expr(&mut env, &mut scope, &loc_expr);
|
||||
|
||||
let mut scope = Scope::new(
|
||||
home,
|
||||
"TestPath".into(),
|
||||
IdentIds::default(),
|
||||
Default::default(),
|
||||
);
|
||||
|
||||
let dep_idents = IdentIds::exposed_builtins(0);
|
||||
let mut env = Env::new(
|
||||
arena,
|
||||
expr_str,
|
||||
home,
|
||||
Path::new("Test.roc"),
|
||||
&dep_idents,
|
||||
&module_ids,
|
||||
None,
|
||||
roc_can::env::FxMode::PurityInference,
|
||||
);
|
||||
let (loc_expr, output) = canonicalize_expr(
|
||||
&mut env,
|
||||
&mut var_store,
|
||||
|
|
|
@ -11054,8 +11054,8 @@ All branches in an `if` must have the same type!
|
|||
4│ Recursive := [Infinitely Recursive]
|
||||
^^^^^^^^^
|
||||
|
||||
Recursion in opaquees is only allowed if recursion happens behind a
|
||||
tagged union, at least one variant of which is not recursive.
|
||||
Recursion in opaque types is only allowed if recursion happens behind
|
||||
a tagged union, at least one variant of which is not recursive.
|
||||
"
|
||||
);
|
||||
|
||||
|
@ -14975,7 +14975,7 @@ All branches in an `if` must have the same type!
|
|||
Str.trim msg
|
||||
"#
|
||||
),
|
||||
@r###"
|
||||
@r#"
|
||||
── EFFECT IN PURE FUNCTION in /code/proj/Main.roc ──────────────────────────────
|
||||
|
||||
This call to `Effect.putLine!` might produce an effect:
|
||||
|
@ -14992,18 +14992,7 @@ All branches in an `if` must have the same type!
|
|||
|
||||
You can still run the program with this error, which can be helpful
|
||||
when you're debugging.
|
||||
|
||||
── UNNECESSARY EXCLAMATION in /code/proj/Main.roc ──────────────────────────────
|
||||
|
||||
This function is pure, but its name suggests otherwise:
|
||||
|
||||
5│ main! = \{} ->
|
||||
^^^^^
|
||||
|
||||
The exclamation mark at the end is reserved for effectful functions.
|
||||
|
||||
Hint: Did you forget to run an effect? Is the type annotation wrong?
|
||||
"###
|
||||
"#
|
||||
);
|
||||
|
||||
test_report!(
|
||||
|
@ -15586,7 +15575,7 @@ All branches in an `if` must have the same type!
|
|||
pureHigherOrder = \f, x -> f x
|
||||
"#
|
||||
),
|
||||
@r###"
|
||||
@r#"
|
||||
── TYPE MISMATCH in /code/proj/Main.roc ────────────────────────────────────────
|
||||
|
||||
This 1st argument to `pureHigherOrder` has an unexpected type:
|
||||
|
@ -15601,18 +15590,7 @@ All branches in an `if` must have the same type!
|
|||
But `pureHigherOrder` needs its 1st argument to be:
|
||||
|
||||
Str -> {}
|
||||
|
||||
── UNNECESSARY EXCLAMATION in /code/proj/Main.roc ──────────────────────────────
|
||||
|
||||
This function is pure, but its name suggests otherwise:
|
||||
|
||||
5│ main! = \{} ->
|
||||
^^^^^
|
||||
|
||||
The exclamation mark at the end is reserved for effectful functions.
|
||||
|
||||
Hint: Did you forget to run an effect? Is the type annotation wrong?
|
||||
"###
|
||||
"#
|
||||
);
|
||||
|
||||
test_report!(
|
||||
|
@ -15630,7 +15608,7 @@ All branches in an `if` must have the same type!
|
|||
pureHigherOrder = \f, x -> f x
|
||||
"#
|
||||
),
|
||||
@r###"
|
||||
@r#"
|
||||
── TYPE MISMATCH in /code/proj/Main.roc ────────────────────────────────────────
|
||||
|
||||
This 1st argument to `pureHigherOrder` has an unexpected type:
|
||||
|
@ -15645,17 +15623,6 @@ All branches in an `if` must have the same type!
|
|||
But `pureHigherOrder` needs its 1st argument to be:
|
||||
|
||||
Str -> {}
|
||||
|
||||
── UNNECESSARY EXCLAMATION in /code/proj/Main.roc ──────────────────────────────
|
||||
|
||||
This function is pure, but its name suggests otherwise:
|
||||
|
||||
5│ main! = \{} ->
|
||||
^^^^^
|
||||
|
||||
The exclamation mark at the end is reserved for effectful functions.
|
||||
|
||||
Hint: Did you forget to run an effect? Is the type annotation wrong?
|
||||
"###
|
||||
"#
|
||||
);
|
||||
}
|
||||
|
|
|
@ -8,43 +8,40 @@ license.workspace = true
|
|||
version.workspace = true
|
||||
|
||||
[dependencies]
|
||||
roc_builtins = { path = "../builtins" }
|
||||
roc_can = { path = "../can" }
|
||||
roc_work = { path = "../work" }
|
||||
roc_checkmate = { path = "../checkmate" }
|
||||
roc_collections = { path = "../collections" }
|
||||
roc_constrain = { path = "../constrain" }
|
||||
roc_debug_flags = { path = "../debug_flags" }
|
||||
roc_derive = { path = "../derive" }
|
||||
roc_derive_key = { path = "../derive_key" }
|
||||
roc_error_macros = { path = "../../error_macros" }
|
||||
roc_late_solve = { path = "../late_solve" }
|
||||
roc_module = { path = "../module" }
|
||||
roc_mono = { path = "../mono" }
|
||||
roc_packaging = { path = "../../packaging" }
|
||||
roc_parse = { path = "../parse" }
|
||||
roc_problem = { path = "../problem" }
|
||||
roc_region = { path = "../region" }
|
||||
roc_reporting = { path = "../../reporting" }
|
||||
roc_solve = { path = "../solve" }
|
||||
roc_solve_problem = { path = "../solve_problem" }
|
||||
roc_target = { path = "../roc_target" }
|
||||
roc_tracing = { path = "../../tracing" }
|
||||
roc_types = { path = "../types" }
|
||||
roc_unify = { path = "../unify" }
|
||||
roc_worker = { path = "../worker" }
|
||||
roc_lower_params = { path = "../lower_params" }
|
||||
|
||||
ven_pretty = { path = "../../vendor/pretty" }
|
||||
|
||||
roc_builtins.workspace = true
|
||||
roc_can.workspace = true
|
||||
roc_work.workspace = true
|
||||
roc_checkmate.workspace = true
|
||||
roc_collections.workspace = true
|
||||
roc_constrain.workspace = true
|
||||
roc_debug_flags.workspace = true
|
||||
roc_derive.workspace = true
|
||||
roc_derive_key.workspace = true
|
||||
roc_error_macros.workspace = true
|
||||
roc_late_solve.workspace = true
|
||||
roc_module.workspace = true
|
||||
roc_mono.workspace = true
|
||||
roc_packaging.workspace = true
|
||||
roc_parse.workspace = true
|
||||
roc_problem.workspace = true
|
||||
roc_region.workspace = true
|
||||
roc_reporting.workspace = true
|
||||
roc_solve.workspace = true
|
||||
roc_solve_problem.workspace = true
|
||||
roc_target.workspace = true
|
||||
roc_tracing.workspace = true
|
||||
roc_types.workspace = true
|
||||
roc_unify.workspace = true
|
||||
roc_worker.workspace = true
|
||||
roc_lower_params.workspace = true
|
||||
ven_pretty.workspace = true
|
||||
bumpalo.workspace = true
|
||||
crossbeam.workspace = true
|
||||
parking_lot.workspace = true
|
||||
tempfile.workspace = true
|
||||
|
||||
[dev-dependencies]
|
||||
roc_test_utils_dir = { path = "../../test_utils_dir" }
|
||||
|
||||
roc_test_utils_dir.workspace = true
|
||||
indoc.workspace = true
|
||||
maplit.workspace = true
|
||||
pretty_assertions.workspace = true
|
||||
|
|
|
@ -350,6 +350,8 @@ fn start_phase<'a>(
|
|||
None
|
||||
};
|
||||
|
||||
let is_host_exposed = state.root_id == module.module_id;
|
||||
|
||||
BuildTask::solve_module(
|
||||
module,
|
||||
ident_ids,
|
||||
|
@ -367,6 +369,7 @@ fn start_phase<'a>(
|
|||
state.cached_types.clone(),
|
||||
derived_module,
|
||||
state.exec_mode,
|
||||
is_host_exposed,
|
||||
//
|
||||
#[cfg(debug_assertions)]
|
||||
checkmate,
|
||||
|
@ -658,7 +661,7 @@ struct CanAndCon {
|
|||
module_docs: Option<ModuleDocumentation>,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
#[derive(Debug, PartialEq, Eq)]
|
||||
enum PlatformPath<'a> {
|
||||
NotSpecified,
|
||||
Valid(To<'a>),
|
||||
|
@ -922,6 +925,7 @@ enum BuildTask<'a> {
|
|||
cached_subs: CachedTypeState,
|
||||
derived_module: SharedDerivedModule,
|
||||
exec_mode: ExecutionMode,
|
||||
is_host_exposed: bool,
|
||||
|
||||
#[cfg(debug_assertions)]
|
||||
checkmate: Option<roc_checkmate::Collector>,
|
||||
|
@ -1141,7 +1145,6 @@ impl<'a> LoadStart<'a> {
|
|||
|
||||
// Load the root module synchronously; we can't proceed until we have its id.
|
||||
let root_start_time = Instant::now();
|
||||
|
||||
let load_result = load_filename(
|
||||
arena,
|
||||
filename.clone(),
|
||||
|
@ -1286,7 +1289,6 @@ fn handle_root_type<'a>(
|
|||
if let (Some(main_path), Some(cache_dir)) = (main_path.clone(), cache_dir) {
|
||||
let mut messages = Vec::with_capacity(4);
|
||||
messages.push(header_output.msg);
|
||||
|
||||
load_packages_from_main(
|
||||
arena,
|
||||
src_dir.clone(),
|
||||
|
@ -2245,7 +2247,9 @@ fn update<'a>(
|
|||
|
||||
// If we're building an app module, and this was the platform
|
||||
// specified in its header's `to` field, record it as our platform.
|
||||
if state.opt_platform_shorthand == Some(config_shorthand) {
|
||||
if state.opt_platform_shorthand == Some(config_shorthand)
|
||||
|| state.platform_path == PlatformPath::RootIsModule
|
||||
{
|
||||
debug_assert!(state.platform_data.is_none());
|
||||
|
||||
state.platform_data = Some(PlatformData {
|
||||
|
@ -2339,7 +2343,6 @@ fn update<'a>(
|
|||
extend_module_with_builtin_import(parsed, ModuleId::INSPECT);
|
||||
extend_module_with_builtin_import(parsed, ModuleId::TASK);
|
||||
}
|
||||
|
||||
state
|
||||
.module_cache
|
||||
.imports
|
||||
|
@ -4331,6 +4334,7 @@ impl<'a> BuildTask<'a> {
|
|||
cached_subs: CachedTypeState,
|
||||
derived_module: SharedDerivedModule,
|
||||
exec_mode: ExecutionMode,
|
||||
is_host_exposed: bool,
|
||||
|
||||
#[cfg(debug_assertions)] checkmate: Option<roc_checkmate::Collector>,
|
||||
) -> Self {
|
||||
|
@ -4355,6 +4359,7 @@ impl<'a> BuildTask<'a> {
|
|||
cached_subs,
|
||||
derived_module,
|
||||
exec_mode,
|
||||
is_host_exposed,
|
||||
|
||||
#[cfg(debug_assertions)]
|
||||
checkmate,
|
||||
|
@ -4661,6 +4666,7 @@ fn run_solve_solve(
|
|||
var_store: VarStore,
|
||||
module: Module,
|
||||
derived_module: SharedDerivedModule,
|
||||
is_host_exposed: bool,
|
||||
|
||||
#[cfg(debug_assertions)] checkmate: Option<roc_checkmate::Collector>,
|
||||
) -> SolveResult {
|
||||
|
@ -4711,6 +4717,12 @@ fn run_solve_solve(
|
|||
let (solve_output, solved_implementations, exposed_vars_by_symbol) = {
|
||||
let module_id = module.module_id;
|
||||
|
||||
let host_exposed_idents = if is_host_exposed {
|
||||
Some(&exposed_symbols)
|
||||
} else {
|
||||
None
|
||||
};
|
||||
|
||||
let solve_config = SolveConfig {
|
||||
home: module_id,
|
||||
types,
|
||||
|
@ -4724,6 +4736,7 @@ fn run_solve_solve(
|
|||
checkmate,
|
||||
module_params,
|
||||
module_params_vars: imported_param_vars,
|
||||
host_exposed_symbols: host_exposed_idents,
|
||||
};
|
||||
|
||||
let solve_output = roc_solve::module::run_solve(
|
||||
|
@ -4800,6 +4813,7 @@ fn run_solve<'a>(
|
|||
cached_types: CachedTypeState,
|
||||
derived_module: SharedDerivedModule,
|
||||
exec_mode: ExecutionMode,
|
||||
is_host_exposed: bool,
|
||||
|
||||
#[cfg(debug_assertions)] checkmate: Option<roc_checkmate::Collector>,
|
||||
) -> Msg<'a> {
|
||||
|
@ -4831,6 +4845,7 @@ fn run_solve<'a>(
|
|||
var_store,
|
||||
module,
|
||||
derived_module,
|
||||
is_host_exposed,
|
||||
//
|
||||
#[cfg(debug_assertions)]
|
||||
checkmate,
|
||||
|
@ -4863,6 +4878,7 @@ fn run_solve<'a>(
|
|||
var_store,
|
||||
module,
|
||||
derived_module,
|
||||
is_host_exposed,
|
||||
//
|
||||
#[cfg(debug_assertions)]
|
||||
checkmate,
|
||||
|
@ -6256,6 +6272,7 @@ fn run_task<'a>(
|
|||
cached_subs,
|
||||
derived_module,
|
||||
exec_mode,
|
||||
is_host_exposed,
|
||||
|
||||
#[cfg(debug_assertions)]
|
||||
checkmate,
|
||||
|
@ -6275,6 +6292,7 @@ fn run_task<'a>(
|
|||
cached_subs,
|
||||
derived_module,
|
||||
exec_mode,
|
||||
is_host_exposed,
|
||||
//
|
||||
#[cfg(debug_assertions)]
|
||||
checkmate,
|
||||
|
|
|
@ -8,11 +8,10 @@ license.workspace = true
|
|||
version.workspace = true
|
||||
|
||||
[dependencies]
|
||||
roc_can = { path = "../can" }
|
||||
roc_module = { path = "../module" }
|
||||
roc_region = { path = "../region" }
|
||||
roc_types = { path = "../types" }
|
||||
roc_collections = { path = "../collections" }
|
||||
roc_solve_problem = { path = "../solve_problem" }
|
||||
|
||||
roc_can.workspace = true
|
||||
roc_module.workspace = true
|
||||
roc_region.workspace = true
|
||||
roc_types.workspace = true
|
||||
roc_collections.workspace = true
|
||||
roc_solve_problem.workspace = true
|
||||
bumpalo.workspace = true
|
||||
|
|
|
@ -389,7 +389,6 @@ impl<'a> LowerParams<'a> {
|
|||
}
|
||||
| OpaqueWrapFunction(_)
|
||||
| EmptyRecord
|
||||
| TypedHole(_)
|
||||
| RuntimeError(_)
|
||||
| Num(_, _, _, _)
|
||||
| Int(_, _, _, _, _)
|
||||
|
|
|
@ -8,10 +8,10 @@ license.workspace = true
|
|||
version.workspace = true
|
||||
|
||||
[dependencies]
|
||||
roc_collections = { path = "../collections" }
|
||||
roc_error_macros = { path = "../../error_macros" }
|
||||
roc_ident = { path = "../ident" }
|
||||
roc_region = { path = "../region" }
|
||||
roc_collections.workspace = true
|
||||
roc_error_macros.workspace = true
|
||||
roc_ident.workspace = true
|
||||
roc_region.workspace = true
|
||||
|
||||
bumpalo.workspace = true
|
||||
static_assertions.workspace = true
|
||||
|
|
|
@ -8,25 +8,25 @@ license.workspace = true
|
|||
version.workspace = true
|
||||
|
||||
[dependencies]
|
||||
roc_builtins = { path = "../builtins" }
|
||||
roc_can = { path = "../can" }
|
||||
roc_collections = { path = "../collections" }
|
||||
roc_debug_flags = { path = "../debug_flags" }
|
||||
roc_derive = { path = "../derive" }
|
||||
roc_derive_key = { path = "../derive_key" }
|
||||
roc_error_macros = { path = "../../error_macros" }
|
||||
roc_exhaustive = { path = "../exhaustive" }
|
||||
roc_late_solve = { path = "../late_solve" }
|
||||
roc_module = { path = "../module" }
|
||||
roc_problem = { path = "../problem" }
|
||||
roc_region = { path = "../region" }
|
||||
roc_std = { path = "../../roc_std" }
|
||||
roc_target = { path = "../roc_target" }
|
||||
roc_tracing = { path = "../../tracing" }
|
||||
roc_types = { path = "../types" }
|
||||
roc_solve_schema = { path = "../solve_schema" }
|
||||
roc_unify = { path = "../unify" }
|
||||
ven_pretty = { path = "../../vendor/pretty" }
|
||||
roc_builtins.workspace = true
|
||||
roc_can.workspace = true
|
||||
roc_collections.workspace = true
|
||||
roc_debug_flags.workspace = true
|
||||
roc_derive.workspace = true
|
||||
roc_derive_key.workspace = true
|
||||
roc_error_macros.workspace = true
|
||||
roc_exhaustive.workspace = true
|
||||
roc_late_solve.workspace = true
|
||||
roc_module.workspace = true
|
||||
roc_problem.workspace = true
|
||||
roc_region.workspace = true
|
||||
roc_std.workspace = true
|
||||
roc_target.workspace = true
|
||||
roc_tracing.workspace = true
|
||||
roc_types.workspace = true
|
||||
roc_solve_schema.workspace = true
|
||||
roc_unify.workspace = true
|
||||
ven_pretty.workspace = true
|
||||
|
||||
bitvec.workspace = true
|
||||
arrayvec.workspace = true
|
||||
|
@ -34,4 +34,4 @@ bumpalo.workspace = true
|
|||
hashbrown.workspace = true
|
||||
parking_lot.workspace = true
|
||||
static_assertions.workspace = true
|
||||
indoc.workspace = true
|
||||
indoc.workspace = true
|
||||
|
|
|
@ -537,7 +537,6 @@ impl<'a, 'r> Ctx<'a, 'r> {
|
|||
|
||||
None
|
||||
}
|
||||
Expr::RuntimeErrorFunction(_) => None,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -244,8 +244,7 @@ fn specialize_drops_stmt<'a, 'i>(
|
|||
}
|
||||
}
|
||||
Reset { .. } | Expr::ResetRef { .. } => { /* do nothing */ }
|
||||
RuntimeErrorFunction(_)
|
||||
| FunctionPointer { .. }
|
||||
FunctionPointer { .. }
|
||||
| GetTagId { .. }
|
||||
| Alloca { .. }
|
||||
| EmptyArray
|
||||
|
|
|
@ -881,12 +881,8 @@ fn insert_refcount_operations_binding<'a>(
|
|||
}
|
||||
|
||||
match expr {
|
||||
Expr::Literal(_)
|
||||
| Expr::NullPointer
|
||||
| Expr::FunctionPointer { .. }
|
||||
| Expr::EmptyArray
|
||||
| Expr::RuntimeErrorFunction(_) => {
|
||||
// Literals, empty arrays, and runtime errors are not (and have nothing) reference counted.
|
||||
Expr::Literal(_) | Expr::NullPointer | Expr::FunctionPointer { .. } | Expr::EmptyArray => {
|
||||
// Literals and empty arrays are not (and have nothing) reference counted.
|
||||
new_let!(stmt)
|
||||
}
|
||||
|
||||
|
|
|
@ -1947,8 +1947,6 @@ pub enum Expr<'a> {
|
|||
symbol: Symbol,
|
||||
update_mode: UpdateModeId,
|
||||
},
|
||||
|
||||
RuntimeErrorFunction(&'a str),
|
||||
}
|
||||
|
||||
impl<'a> Literal<'a> {
|
||||
|
@ -2111,8 +2109,6 @@ impl<'a> Expr<'a> {
|
|||
} => text!(alloc, "StructAtIndex {} ", index)
|
||||
.append(symbol_to_doc(alloc, *structure, pretty)),
|
||||
|
||||
RuntimeErrorFunction(s) => text!(alloc, "ErrorFunction {}", s),
|
||||
|
||||
GetTagId { structure, .. } => alloc
|
||||
.text("GetTagId ")
|
||||
.append(symbol_to_doc(alloc, *structure, pretty)),
|
||||
|
@ -5897,7 +5893,6 @@ pub fn with_hole<'a>(
|
|||
Stmt::Ret(return_symbol),
|
||||
)
|
||||
}
|
||||
TypedHole(_) => runtime_error(env, "Hit a blank"),
|
||||
RuntimeError(e) => runtime_error(env, env.arena.alloc(e.runtime_message())),
|
||||
Crash { msg, ret_var: _ } => {
|
||||
let msg_sym = possible_reuse_symbol_or_specialize(
|
||||
|
@ -7729,7 +7724,7 @@ fn substitute_in_expr<'a>(
|
|||
use Expr::*;
|
||||
|
||||
match expr {
|
||||
Literal(_) | EmptyArray | RuntimeErrorFunction(_) => None,
|
||||
Literal(_) | EmptyArray => None,
|
||||
|
||||
Call(call) => substitute_in_call(arena, call, subs).map(Expr::Call),
|
||||
|
||||
|
|
|
@ -1070,7 +1070,6 @@ fn expr_contains_symbol(expr: &Expr, needle: Symbol) -> bool {
|
|||
}),
|
||||
Expr::EmptyArray => false,
|
||||
Expr::Reset { symbol, .. } | Expr::ResetRef { symbol, .. } => needle == *symbol,
|
||||
Expr::RuntimeErrorFunction(_) => false,
|
||||
Expr::ErasedMake { value, callee } => {
|
||||
value.map(|v| v == needle).unwrap_or(false) || needle == *callee
|
||||
}
|
||||
|
|
|
@ -11,10 +11,10 @@ version.workspace = true
|
|||
"parse_debug_trace" = []
|
||||
|
||||
[dependencies]
|
||||
roc_collections = { path = "../collections" }
|
||||
roc_module = { path = "../module" }
|
||||
roc_region = { path = "../region" }
|
||||
roc_error_macros = { path = "../../error_macros" }
|
||||
roc_collections.workspace = true
|
||||
roc_module.workspace = true
|
||||
roc_region.workspace = true
|
||||
roc_error_macros.workspace = true
|
||||
|
||||
soa.workspace = true
|
||||
|
||||
|
|
|
@ -35,7 +35,7 @@ use roc_region::all::{Loc, Position, Region};
|
|||
|
||||
use crate::parser::Progress::{self, *};
|
||||
|
||||
fn expr_end<'a>() -> impl Parser<'a, (), EExpr<'a>> {
|
||||
pub fn expr_end<'a>() -> impl Parser<'a, (), EExpr<'a>> {
|
||||
|_arena, state: State<'a>, _min_indent: u32| {
|
||||
if state.has_reached_end() {
|
||||
Ok((NoProgress, (), state))
|
||||
|
@ -545,10 +545,6 @@ fn stmt_start<'a>(
|
|||
EExpr::Expect,
|
||||
expect_help(options, preceding_comment)
|
||||
)),
|
||||
loc(specialize_err(
|
||||
EExpr::Dbg,
|
||||
dbg_stmt_help(options, preceding_comment)
|
||||
)),
|
||||
loc(specialize_err(EExpr::Return, return_help(options))),
|
||||
loc(specialize_err(EExpr::Import, map(import(), Stmt::ValueDef))),
|
||||
map(
|
||||
|
@ -2668,34 +2664,6 @@ fn return_help<'a>(options: ExprParseOptions) -> impl Parser<'a, Stmt<'a>, ERetu
|
|||
.trace("return_help")
|
||||
}
|
||||
|
||||
fn dbg_stmt_help<'a>(
|
||||
options: ExprParseOptions,
|
||||
preceding_comment: Region,
|
||||
) -> impl Parser<'a, Stmt<'a>, EExpect<'a>> {
|
||||
(move |arena: &'a Bump, state: State<'a>, min_indent| {
|
||||
let (_, _, state) =
|
||||
parser::keyword(keyword::DBG, EExpect::Dbg).parse(arena, state, min_indent)?;
|
||||
|
||||
let (_, condition, state) = parse_block(
|
||||
options,
|
||||
arena,
|
||||
state,
|
||||
true,
|
||||
EExpect::IndentCondition,
|
||||
EExpect::Condition,
|
||||
)
|
||||
.map_err(|(_, f)| (MadeProgress, f))?;
|
||||
|
||||
let stmt = Stmt::ValueDef(ValueDef::Dbg {
|
||||
condition: arena.alloc(condition),
|
||||
preceding_comment,
|
||||
});
|
||||
|
||||
Ok((MadeProgress, stmt, state))
|
||||
})
|
||||
.trace("dbg_stmt_help")
|
||||
}
|
||||
|
||||
fn dbg_kw<'a>() -> impl Parser<'a, Expr<'a>, EExpect<'a>> {
|
||||
(move |arena: &'a Bump, state: State<'a>, min_indent: u32| {
|
||||
let (_, _, next_state) =
|
||||
|
@ -3110,12 +3078,43 @@ fn stmts_to_defs<'a>(
|
|||
}
|
||||
Stmt::Expr(e) => {
|
||||
if i + 1 < stmts.len() {
|
||||
defs.push_value_def(
|
||||
ValueDef::Stmt(arena.alloc(Loc::at(sp_stmt.item.region, e))),
|
||||
sp_stmt.item.region,
|
||||
sp_stmt.before,
|
||||
&[],
|
||||
);
|
||||
if let Expr::Apply(
|
||||
Loc {
|
||||
value: Expr::Dbg, ..
|
||||
},
|
||||
args,
|
||||
_,
|
||||
) = e
|
||||
{
|
||||
if args.len() != 1 {
|
||||
// TODO: this should be done in can, not parsing!
|
||||
return Err(EExpr::Dbg(
|
||||
EExpect::DbgArity(sp_stmt.item.region.start()),
|
||||
sp_stmt.item.region.start(),
|
||||
));
|
||||
}
|
||||
let condition = &args[0];
|
||||
let rest = stmts_to_expr(&stmts[i + 1..], arena)?;
|
||||
let e = Expr::DbgStmt(condition, arena.alloc(rest));
|
||||
|
||||
let e = if sp_stmt.before.is_empty() {
|
||||
e
|
||||
} else {
|
||||
arena.alloc(e).before(sp_stmt.before)
|
||||
};
|
||||
|
||||
last_expr = Some(Loc::at(sp_stmt.item.region, e));
|
||||
|
||||
// don't re-process the rest of the statements; they got consumed by the dbg expr
|
||||
break;
|
||||
} else {
|
||||
defs.push_value_def(
|
||||
ValueDef::Stmt(arena.alloc(Loc::at(sp_stmt.item.region, e))),
|
||||
sp_stmt.item.region,
|
||||
sp_stmt.before,
|
||||
&[],
|
||||
);
|
||||
}
|
||||
} else {
|
||||
let e = if sp_stmt.before.is_empty() {
|
||||
e
|
||||
|
@ -3417,9 +3416,6 @@ pub enum RecordField<'a> {
|
|||
SpaceAfter(&'a RecordField<'a>, &'a [CommentOrNewline<'a>]),
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct FoundApplyValue;
|
||||
|
||||
impl<'a> RecordField<'a> {
|
||||
fn is_ignored_value(&self) -> bool {
|
||||
let mut current = self;
|
||||
|
|
|
@ -1465,6 +1465,7 @@ impl<'a> Normalize<'a> for EExpect<'a> {
|
|||
EExpect::Continuation(arena.alloc(inner_err.normalize(arena)), Position::zero())
|
||||
}
|
||||
EExpect::IndentCondition(_) => EExpect::IndentCondition(Position::zero()),
|
||||
EExpect::DbgArity(_) => EExpect::DbgArity(Position::zero()),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue