mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-28 06:14:46 +00:00
remove PartialEq for a bunch of types that we should not compare
This commit is contained in:
parent
b59d33a1d5
commit
8b144c446d
15 changed files with 94 additions and 205 deletions
|
@ -75,7 +75,7 @@ use crate::mem_pool::shallow_clone::ShallowClone;
|
||||||
// Ranks are used to limit the number of type variables considered for generalization. Only those inside
|
// Ranks are used to limit the number of type variables considered for generalization. Only those inside
|
||||||
// of the let (so those used in inferring the type of `\x -> x`) are considered.
|
// of the let (so those used in inferring the type of `\x -> x`) are considered.
|
||||||
|
|
||||||
#[derive(PartialEq, Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub enum TypeError {
|
pub enum TypeError {
|
||||||
BadExpr(Region, Category, ErrorType, Expected<ErrorType>),
|
BadExpr(Region, Category, ErrorType, Expected<ErrorType>),
|
||||||
BadPattern(Region, PatternCategory, ErrorType, PExpected<ErrorType>),
|
BadPattern(Region, PatternCategory, ErrorType, PExpected<ErrorType>),
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
use crate::env::Env;
|
use crate::env::Env;
|
||||||
use crate::scope::Scope;
|
use crate::scope::Scope;
|
||||||
use roc_collections::{ImMap, MutMap, MutSet, SendMap, VecSet};
|
use roc_collections::{ImMap, MutMap, MutSet, SendMap, VecMap, VecSet};
|
||||||
use roc_module::ident::{Ident, Lowercase, TagName};
|
use roc_module::ident::{Ident, Lowercase, TagName};
|
||||||
use roc_module::symbol::{IdentIds, ModuleId, Symbol};
|
use roc_module::symbol::{IdentIds, ModuleId, Symbol};
|
||||||
use roc_parse::ast::{AssignedField, ExtractSpaces, Pattern, Tag, TypeAnnotation, TypeHeader};
|
use roc_parse::ast::{AssignedField, ExtractSpaces, Pattern, Tag, TypeAnnotation, TypeHeader};
|
||||||
|
@ -11,7 +11,7 @@ use roc_types::types::{
|
||||||
Alias, AliasCommon, AliasKind, LambdaSet, Problem, RecordField, Type, TypeExtension,
|
Alias, AliasCommon, AliasKind, LambdaSet, Problem, RecordField, Type, TypeExtension,
|
||||||
};
|
};
|
||||||
|
|
||||||
#[derive(Clone, Debug, PartialEq)]
|
#[derive(Clone, Debug)]
|
||||||
pub struct Annotation {
|
pub struct Annotation {
|
||||||
pub typ: Type,
|
pub typ: Type,
|
||||||
pub introduced_variables: IntroducedVariables,
|
pub introduced_variables: IntroducedVariables,
|
||||||
|
@ -53,14 +53,14 @@ pub struct AbleVariable {
|
||||||
pub first_seen: Region,
|
pub first_seen: Region,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, PartialEq, Default)]
|
#[derive(Clone, Debug, Default)]
|
||||||
pub struct IntroducedVariables {
|
pub struct IntroducedVariables {
|
||||||
pub wildcards: Vec<Loc<Variable>>,
|
pub wildcards: Vec<Loc<Variable>>,
|
||||||
pub lambda_sets: Vec<Variable>,
|
pub lambda_sets: Vec<Variable>,
|
||||||
pub inferred: Vec<Loc<Variable>>,
|
pub inferred: Vec<Loc<Variable>>,
|
||||||
pub named: VecSet<NamedVariable>,
|
pub named: VecSet<NamedVariable>,
|
||||||
pub able: VecSet<AbleVariable>,
|
pub able: VecSet<AbleVariable>,
|
||||||
pub host_exposed_aliases: MutMap<Symbol, Variable>,
|
pub host_exposed_aliases: VecMap<Symbol, Variable>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl IntroducedVariables {
|
impl IntroducedVariables {
|
||||||
|
|
|
@ -601,7 +601,7 @@ impl Constraints {
|
||||||
|
|
||||||
roc_error_macros::assert_sizeof_default!(Constraint, 3 * 8);
|
roc_error_macros::assert_sizeof_default!(Constraint, 3 * 8);
|
||||||
|
|
||||||
#[derive(Clone, PartialEq)]
|
#[derive(Clone)]
|
||||||
pub enum Constraint {
|
pub enum Constraint {
|
||||||
Eq(
|
Eq(
|
||||||
EitherIndex<Type, Variable>,
|
EitherIndex<Type, Variable>,
|
||||||
|
@ -643,13 +643,13 @@ pub enum Constraint {
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Default)]
|
#[derive(Debug, Clone, Copy, Default)]
|
||||||
pub struct DefTypes {
|
pub struct DefTypes {
|
||||||
pub types: Slice<Type>,
|
pub types: Slice<Type>,
|
||||||
pub loc_symbols: Slice<(Symbol, Region)>,
|
pub loc_symbols: Slice<(Symbol, Region)>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct LetConstraint {
|
pub struct LetConstraint {
|
||||||
pub rigid_vars: Slice<Variable>,
|
pub rigid_vars: Slice<Variable>,
|
||||||
pub flex_vars: Slice<Variable>,
|
pub flex_vars: Slice<Variable>,
|
||||||
|
@ -657,7 +657,7 @@ pub struct LetConstraint {
|
||||||
pub defs_and_ret_constraint: Index<(Constraint, Constraint)>,
|
pub defs_and_ret_constraint: Index<(Constraint, Constraint)>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq)]
|
#[derive(Debug, Clone)]
|
||||||
pub struct IncludesTag {
|
pub struct IncludesTag {
|
||||||
pub type_index: Index<Type>,
|
pub type_index: Index<Type>,
|
||||||
pub tag_name: TagName,
|
pub tag_name: TagName,
|
||||||
|
|
|
@ -29,7 +29,7 @@ use std::collections::HashMap;
|
||||||
use std::fmt::Debug;
|
use std::fmt::Debug;
|
||||||
use ven_graph::{strongly_connected_components, topological_sort};
|
use ven_graph::{strongly_connected_components, topological_sort};
|
||||||
|
|
||||||
#[derive(Clone, Debug, PartialEq)]
|
#[derive(Clone, Debug)]
|
||||||
pub struct Def {
|
pub struct Def {
|
||||||
pub loc_pattern: Loc<Pattern>,
|
pub loc_pattern: Loc<Pattern>,
|
||||||
pub loc_expr: Loc<Expr>,
|
pub loc_expr: Loc<Expr>,
|
||||||
|
@ -38,7 +38,7 @@ pub struct Def {
|
||||||
pub annotation: Option<Annotation>,
|
pub annotation: Option<Annotation>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, PartialEq)]
|
#[derive(Clone, Debug)]
|
||||||
pub struct Annotation {
|
pub struct Annotation {
|
||||||
pub signature: Type,
|
pub signature: Type,
|
||||||
pub introduced_variables: IntroducedVariables,
|
pub introduced_variables: IntroducedVariables,
|
||||||
|
@ -56,7 +56,7 @@ pub struct CanDefs {
|
||||||
/// A Def that has had patterns and type annnotations canonicalized,
|
/// A Def that has had patterns and type annnotations canonicalized,
|
||||||
/// but no Expr canonicalization has happened yet. Also, it has had spaces
|
/// but no Expr canonicalization has happened yet. Also, it has had spaces
|
||||||
/// and nesting resolved, and knows whether annotations are standalone or not.
|
/// and nesting resolved, and knows whether annotations are standalone or not.
|
||||||
#[derive(Debug, Clone, PartialEq)]
|
#[derive(Debug, Clone)]
|
||||||
enum PendingValueDef<'a> {
|
enum PendingValueDef<'a> {
|
||||||
/// A standalone annotation with no body
|
/// A standalone annotation with no body
|
||||||
AnnotationOnly(
|
AnnotationOnly(
|
||||||
|
@ -79,7 +79,7 @@ enum PendingValueDef<'a> {
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq)]
|
#[derive(Debug, Clone)]
|
||||||
enum PendingTypeDef<'a> {
|
enum PendingTypeDef<'a> {
|
||||||
/// A structural or opaque type alias, e.g. `Ints : List Int` or `Age := U32` respectively.
|
/// A structural or opaque type alias, e.g. `Ints : List Int` or `Age := U32` respectively.
|
||||||
Alias {
|
Alias {
|
||||||
|
@ -105,7 +105,7 @@ enum PendingTypeDef<'a> {
|
||||||
}
|
}
|
||||||
|
|
||||||
// See github.com/rtfeldman/roc/issues/800 for discussion of the large_enum_variant check.
|
// See github.com/rtfeldman/roc/issues/800 for discussion of the large_enum_variant check.
|
||||||
#[derive(Clone, Debug, PartialEq)]
|
#[derive(Clone, Debug)]
|
||||||
#[allow(clippy::large_enum_variant)]
|
#[allow(clippy::large_enum_variant)]
|
||||||
pub enum Declaration {
|
pub enum Declaration {
|
||||||
Declare(Def),
|
Declare(Def),
|
||||||
|
|
|
@ -2,7 +2,7 @@ use crate::pattern::Pattern;
|
||||||
use roc_region::all::{Loc, Region};
|
use roc_region::all::{Loc, Region};
|
||||||
use roc_types::types::{AnnotationSource, PReason, Reason};
|
use roc_types::types::{AnnotationSource, PReason, Reason};
|
||||||
|
|
||||||
#[derive(Debug, Clone, PartialEq)]
|
#[derive(Debug, Clone)]
|
||||||
pub enum Expected<T> {
|
pub enum Expected<T> {
|
||||||
NoExpectation(T),
|
NoExpectation(T),
|
||||||
FromAnnotation(Loc<Pattern>, usize, AnnotationSource, T),
|
FromAnnotation(Loc<Pattern>, usize, AnnotationSource, T),
|
||||||
|
@ -10,7 +10,7 @@ pub enum Expected<T> {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Like Expected, but for Patterns.
|
/// Like Expected, but for Patterns.
|
||||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
#[derive(Debug, Clone)]
|
||||||
pub enum PExpected<T> {
|
pub enum PExpected<T> {
|
||||||
NoExpectation(T),
|
NoExpectation(T),
|
||||||
ForReason(PReason, T, Region),
|
ForReason(PReason, T, Region),
|
||||||
|
|
|
@ -9,7 +9,7 @@ use crate::num::{
|
||||||
use crate::pattern::{canonicalize_pattern, Pattern};
|
use crate::pattern::{canonicalize_pattern, Pattern};
|
||||||
use crate::procedure::References;
|
use crate::procedure::References;
|
||||||
use crate::scope::Scope;
|
use crate::scope::Scope;
|
||||||
use roc_collections::{MutMap, MutSet, SendMap, VecSet};
|
use roc_collections::{MutMap, MutSet, SendMap, VecMap, VecSet};
|
||||||
use roc_module::called_via::CalledVia;
|
use roc_module::called_via::CalledVia;
|
||||||
use roc_module::ident::{ForeignSymbol, Lowercase, TagName};
|
use roc_module::ident::{ForeignSymbol, Lowercase, TagName};
|
||||||
use roc_module::low_level::LowLevel;
|
use roc_module::low_level::LowLevel;
|
||||||
|
@ -23,12 +23,12 @@ use roc_types::types::{Alias, LambdaSet, Type};
|
||||||
use std::fmt::{Debug, Display};
|
use std::fmt::{Debug, Display};
|
||||||
use std::{char, u32};
|
use std::{char, u32};
|
||||||
|
|
||||||
#[derive(Clone, Default, Debug, PartialEq)]
|
#[derive(Clone, Default, Debug)]
|
||||||
pub struct Output {
|
pub struct Output {
|
||||||
pub references: References,
|
pub references: References,
|
||||||
pub tail_call: Option<Symbol>,
|
pub tail_call: Option<Symbol>,
|
||||||
pub introduced_variables: IntroducedVariables,
|
pub introduced_variables: IntroducedVariables,
|
||||||
pub aliases: SendMap<Symbol, Alias>,
|
pub aliases: VecMap<Symbol, Alias>,
|
||||||
pub non_closures: VecSet<Symbol>,
|
pub non_closures: VecSet<Symbol>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -62,7 +62,7 @@ impl Display for IntValue {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, PartialEq)]
|
#[derive(Clone, Debug)]
|
||||||
pub enum Expr {
|
pub enum Expr {
|
||||||
// Literals
|
// Literals
|
||||||
|
|
||||||
|
@ -194,7 +194,7 @@ pub enum Expr {
|
||||||
// Compiles, but will crash if reached
|
// Compiles, but will crash if reached
|
||||||
RuntimeError(RuntimeError),
|
RuntimeError(RuntimeError),
|
||||||
}
|
}
|
||||||
#[derive(Clone, Debug, PartialEq)]
|
#[derive(Clone, Debug)]
|
||||||
pub struct ClosureData {
|
pub struct ClosureData {
|
||||||
pub function_type: Variable,
|
pub function_type: Variable,
|
||||||
pub closure_type: Variable,
|
pub closure_type: Variable,
|
||||||
|
@ -271,7 +271,7 @@ impl AccessorData {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, PartialEq)]
|
#[derive(Clone, Debug)]
|
||||||
pub struct Field {
|
pub struct Field {
|
||||||
pub var: Variable,
|
pub var: Variable,
|
||||||
// The region of the full `foo: f bar`, rather than just `f bar`
|
// The region of the full `foo: f bar`, rather than just `f bar`
|
||||||
|
@ -286,7 +286,7 @@ pub enum Recursive {
|
||||||
TailRecursive = 2,
|
TailRecursive = 2,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, PartialEq)]
|
#[derive(Clone, Debug)]
|
||||||
pub struct WhenBranch {
|
pub struct WhenBranch {
|
||||||
pub patterns: Vec<Loc<Pattern>>,
|
pub patterns: Vec<Loc<Pattern>>,
|
||||||
pub value: Loc<Expr>,
|
pub value: Loc<Expr>,
|
||||||
|
|
|
@ -17,7 +17,7 @@ use roc_types::types::{LambdaSet, Type};
|
||||||
|
|
||||||
/// A pattern, including possible problems (e.g. shadowing) so that
|
/// A pattern, including possible problems (e.g. shadowing) so that
|
||||||
/// codegen can generate a runtime error if this pattern is reached.
|
/// codegen can generate a runtime error if this pattern is reached.
|
||||||
#[derive(Clone, Debug, PartialEq)]
|
#[derive(Clone, Debug)]
|
||||||
pub enum Pattern {
|
pub enum Pattern {
|
||||||
Identifier(Symbol),
|
Identifier(Symbol),
|
||||||
AppliedTag {
|
AppliedTag {
|
||||||
|
@ -82,7 +82,7 @@ pub enum Pattern {
|
||||||
MalformedPattern(MalformedPatternProblem, Region),
|
MalformedPattern(MalformedPatternProblem, Region),
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, PartialEq)]
|
#[derive(Clone, Debug)]
|
||||||
pub struct RecordDestruct {
|
pub struct RecordDestruct {
|
||||||
pub var: Variable,
|
pub var: Variable,
|
||||||
pub label: Lowercase,
|
pub label: Lowercase,
|
||||||
|
@ -90,7 +90,7 @@ pub struct RecordDestruct {
|
||||||
pub typ: DestructType,
|
pub typ: DestructType,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, PartialEq)]
|
#[derive(Clone, Debug)]
|
||||||
pub enum DestructType {
|
pub enum DestructType {
|
||||||
Required,
|
Required,
|
||||||
Optional(Variable, Loc<Expr>),
|
Optional(Variable, Loc<Expr>),
|
||||||
|
|
|
@ -5,7 +5,7 @@ use roc_module::symbol::Symbol;
|
||||||
use roc_region::all::{Loc, Region};
|
use roc_region::all::{Loc, Region};
|
||||||
use roc_types::subs::Variable;
|
use roc_types::subs::Variable;
|
||||||
|
|
||||||
#[derive(Clone, Debug, PartialEq)]
|
#[derive(Clone, Debug)]
|
||||||
pub struct Procedure {
|
pub struct Procedure {
|
||||||
pub name: Option<Box<str>>,
|
pub name: Option<Box<str>>,
|
||||||
pub is_self_tail_recursive: bool,
|
pub is_self_tail_recursive: bool,
|
||||||
|
|
|
@ -1,110 +0,0 @@
|
||||||
#[macro_use]
|
|
||||||
extern crate pretty_assertions;
|
|
||||||
#[macro_use]
|
|
||||||
extern crate indoc;
|
|
||||||
|
|
||||||
extern crate bumpalo;
|
|
||||||
extern crate roc_can;
|
|
||||||
extern crate roc_parse;
|
|
||||||
extern crate roc_region;
|
|
||||||
|
|
||||||
mod helpers;
|
|
||||||
|
|
||||||
#[cfg(test)]
|
|
||||||
mod can_inline {
|
|
||||||
use crate::helpers::{can_expr_with, test_home};
|
|
||||||
use bumpalo::Bump;
|
|
||||||
use roc_can::expr::inline_calls;
|
|
||||||
use roc_can::expr::Expr::{self, *};
|
|
||||||
use roc_can::scope::Scope;
|
|
||||||
use roc_types::subs::VarStore;
|
|
||||||
|
|
||||||
fn assert_inlines_to(input: &str, expected: Expr, var_store: &mut VarStore) {
|
|
||||||
let arena = Bump::new();
|
|
||||||
let scope = &mut Scope::new(test_home(), var_store);
|
|
||||||
let actual_out = can_expr_with(&arena, test_home(), input);
|
|
||||||
let actual = inline_calls(var_store, scope, actual_out.loc_expr.value);
|
|
||||||
|
|
||||||
assert_eq!(actual, expected);
|
|
||||||
}
|
|
||||||
|
|
||||||
#[test]
|
|
||||||
fn inline_empty_record() {
|
|
||||||
// fn inline_list_len() {
|
|
||||||
let var_store = &mut VarStore::default();
|
|
||||||
|
|
||||||
assert_inlines_to(
|
|
||||||
indoc!(
|
|
||||||
r#"
|
|
||||||
{}
|
|
||||||
"#
|
|
||||||
),
|
|
||||||
EmptyRecord,
|
|
||||||
var_store,
|
|
||||||
);
|
|
||||||
|
|
||||||
// TODO testing with hardcoded variables is very brittle.
|
|
||||||
// Should find a better way to test this!
|
|
||||||
// (One idea would be to traverse both Exprs and zero out all the Variables,
|
|
||||||
// so they always pass equality.)
|
|
||||||
// let aliases = SendMap::default();
|
|
||||||
// assert_inlines_to(
|
|
||||||
// indoc!(
|
|
||||||
// r#"
|
|
||||||
// Int.isZero 5
|
|
||||||
// "#
|
|
||||||
// ),
|
|
||||||
// LetNonRec(
|
|
||||||
// Box::new(Def {
|
|
||||||
// loc_pattern: Located {
|
|
||||||
// region: Region::zero(),
|
|
||||||
// value: Pattern::Identifier(Symbol::ARG_1),
|
|
||||||
// },
|
|
||||||
// pattern_vars: SendMap::default(),
|
|
||||||
// loc_expr: Located {
|
|
||||||
// region: Region::new(0, 0, 11, 12),
|
|
||||||
// value: Num(unsafe { Variable::unsafe_test_debug_variable(7) }, 5),
|
|
||||||
// },
|
|
||||||
// expr_var: unsafe { Variable::unsafe_test_debug_variable(8) },
|
|
||||||
// annotation: None,
|
|
||||||
// }),
|
|
||||||
// Box::new(Located {
|
|
||||||
// region: Region::zero(),
|
|
||||||
// value: Expr::Call(
|
|
||||||
// Box::new((
|
|
||||||
// unsafe { Variable::unsafe_test_debug_variable(138) },
|
|
||||||
// Located {
|
|
||||||
// region: Region::zero(),
|
|
||||||
// value: Expr::Var(Symbol::BOOL_EQ),
|
|
||||||
// },
|
|
||||||
// unsafe { Variable::unsafe_test_debug_variable(139) },
|
|
||||||
// )),
|
|
||||||
// vec![
|
|
||||||
// (
|
|
||||||
// unsafe { Variable::unsafe_test_debug_variable(140) },
|
|
||||||
// Located {
|
|
||||||
// region: Region::zero(),
|
|
||||||
// value: Var(Symbol::ARG_1),
|
|
||||||
// },
|
|
||||||
// ),
|
|
||||||
// (
|
|
||||||
// unsafe { Variable::unsafe_test_debug_variable(141) },
|
|
||||||
// Located {
|
|
||||||
// region: Region::zero(),
|
|
||||||
// value: Int(
|
|
||||||
// unsafe { Variable::unsafe_test_debug_variable(137) },
|
|
||||||
// 0,
|
|
||||||
// ),
|
|
||||||
// },
|
|
||||||
// ),
|
|
||||||
// ],
|
|
||||||
// CalledVia::Space,
|
|
||||||
// ),
|
|
||||||
// }),
|
|
||||||
// unsafe { Variable::unsafe_test_debug_variable(198) },
|
|
||||||
// aliases,
|
|
||||||
// ),
|
|
||||||
// var_store,
|
|
||||||
// )
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -20,11 +20,32 @@ mod test_can {
|
||||||
use roc_region::all::{Position, Region};
|
use roc_region::all::{Position, Region};
|
||||||
use std::{f64, i64};
|
use std::{f64, i64};
|
||||||
|
|
||||||
fn assert_can(input: &str, expected: Expr) {
|
fn assert_can_runtime_error(input: &str, expected: RuntimeError) {
|
||||||
let arena = Bump::new();
|
let arena = Bump::new();
|
||||||
let actual_out = can_expr_with(&arena, test_home(), input);
|
let actual_out = can_expr_with(&arena, test_home(), input);
|
||||||
|
|
||||||
assert_eq!(actual_out.loc_expr.value, expected);
|
match actual_out.loc_expr.value {
|
||||||
|
Expr::RuntimeError(actual) => {
|
||||||
|
assert_eq!(expected, actual);
|
||||||
|
}
|
||||||
|
actual => {
|
||||||
|
panic!("Expected a Float, but got: {:?}", actual);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn assert_can_string(input: &str, expected: &str) {
|
||||||
|
let arena = Bump::new();
|
||||||
|
let actual_out = can_expr_with(&arena, test_home(), input);
|
||||||
|
|
||||||
|
match actual_out.loc_expr.value {
|
||||||
|
Expr::Str(actual) => {
|
||||||
|
assert_eq!(expected, &*actual);
|
||||||
|
}
|
||||||
|
actual => {
|
||||||
|
panic!("Expected a Float, but got: {:?}", actual);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn assert_can_float(input: &str, expected: f64) {
|
fn assert_can_float(input: &str, expected: f64) {
|
||||||
|
@ -69,10 +90,6 @@ mod test_can {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn expr_str(contents: &str) -> Expr {
|
|
||||||
Expr::Str(contents.into())
|
|
||||||
}
|
|
||||||
|
|
||||||
// NUMBER LITERALS
|
// NUMBER LITERALS
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
|
@ -81,14 +98,14 @@ mod test_can {
|
||||||
|
|
||||||
let string = "340_282_366_920_938_463_463_374_607_431_768_211_456".to_string();
|
let string = "340_282_366_920_938_463_463_374_607_431_768_211_456".to_string();
|
||||||
|
|
||||||
assert_can(
|
assert_can_runtime_error(
|
||||||
&string.clone(),
|
&string.clone(),
|
||||||
RuntimeError(RuntimeError::InvalidInt(
|
RuntimeError::InvalidInt(
|
||||||
IntErrorKind::Overflow,
|
IntErrorKind::Overflow,
|
||||||
Base::Decimal,
|
Base::Decimal,
|
||||||
Region::zero(),
|
Region::zero(),
|
||||||
string.into_boxed_str(),
|
string.into_boxed_str(),
|
||||||
)),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -98,14 +115,14 @@ mod test_can {
|
||||||
|
|
||||||
let string = "-170_141_183_460_469_231_731_687_303_715_884_105_729".to_string();
|
let string = "-170_141_183_460_469_231_731_687_303_715_884_105_729".to_string();
|
||||||
|
|
||||||
assert_can(
|
assert_can_runtime_error(
|
||||||
&string.clone(),
|
&string.clone(),
|
||||||
RuntimeError(RuntimeError::InvalidInt(
|
RuntimeError::InvalidInt(
|
||||||
IntErrorKind::Underflow,
|
IntErrorKind::Underflow,
|
||||||
Base::Decimal,
|
Base::Decimal,
|
||||||
Region::zero(),
|
Region::zero(),
|
||||||
string.into(),
|
string.into(),
|
||||||
)),
|
),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -114,13 +131,9 @@ mod test_can {
|
||||||
let string = format!("{}1.0", f64::MAX);
|
let string = format!("{}1.0", f64::MAX);
|
||||||
let region = Region::zero();
|
let region = Region::zero();
|
||||||
|
|
||||||
assert_can(
|
assert_can_runtime_error(
|
||||||
&string.clone(),
|
&string.clone(),
|
||||||
RuntimeError(RuntimeError::InvalidFloat(
|
RuntimeError::InvalidFloat(FloatErrorKind::PositiveInfinity, region, string.into()),
|
||||||
FloatErrorKind::PositiveInfinity,
|
|
||||||
region,
|
|
||||||
string.into(),
|
|
||||||
)),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -129,13 +142,9 @@ mod test_can {
|
||||||
let string = format!("{}1.0", f64::MIN);
|
let string = format!("{}1.0", f64::MIN);
|
||||||
let region = Region::zero();
|
let region = Region::zero();
|
||||||
|
|
||||||
assert_can(
|
assert_can_runtime_error(
|
||||||
&string.clone(),
|
&string.clone(),
|
||||||
RuntimeError(RuntimeError::InvalidFloat(
|
RuntimeError::InvalidFloat(FloatErrorKind::NegativeInfinity, region, string.into()),
|
||||||
FloatErrorKind::NegativeInfinity,
|
|
||||||
region,
|
|
||||||
string.into(),
|
|
||||||
)),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -144,13 +153,9 @@ mod test_can {
|
||||||
let string = "1.1.1";
|
let string = "1.1.1";
|
||||||
let region = Region::zero();
|
let region = Region::zero();
|
||||||
|
|
||||||
assert_can(
|
assert_can_runtime_error(
|
||||||
string.clone(),
|
string.clone(),
|
||||||
RuntimeError(RuntimeError::InvalidFloat(
|
RuntimeError::InvalidFloat(FloatErrorKind::Error, region, string.into()),
|
||||||
FloatErrorKind::Error,
|
|
||||||
region,
|
|
||||||
string.into(),
|
|
||||||
)),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1582,27 +1587,27 @@ mod test_can {
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn string_with_valid_unicode_escapes() {
|
fn string_with_valid_unicode_escapes() {
|
||||||
assert_can(r#""x\u(00A0)x""#, expr_str("x\u{00A0}x"));
|
assert_can_string(r#""x\u(00A0)x""#, "x\u{00A0}x");
|
||||||
assert_can(r#""x\u(101010)x""#, expr_str("x\u{101010}x"));
|
assert_can_string(r#""x\u(101010)x""#, "x\u{101010}x");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
fn block_string() {
|
fn block_string() {
|
||||||
assert_can(
|
assert_can_string(
|
||||||
r#"
|
r#"
|
||||||
"""foobar"""
|
"""foobar"""
|
||||||
"#,
|
"#,
|
||||||
expr_str("foobar"),
|
"foobar",
|
||||||
);
|
);
|
||||||
|
|
||||||
assert_can(
|
assert_can_string(
|
||||||
indoc!(
|
indoc!(
|
||||||
r#"
|
r#"
|
||||||
"""foo
|
"""foo
|
||||||
bar"""
|
bar"""
|
||||||
"#
|
"#
|
||||||
),
|
),
|
||||||
expr_str("foo\nbar"),
|
"foo\nbar",
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,7 +4,9 @@
|
||||||
|
|
||||||
pub mod all;
|
pub mod all;
|
||||||
pub mod soa;
|
pub mod soa;
|
||||||
|
mod vec_map;
|
||||||
mod vec_set;
|
mod vec_set;
|
||||||
|
|
||||||
pub use all::{default_hasher, BumpMap, ImEntry, ImMap, ImSet, MutMap, MutSet, SendMap};
|
pub use all::{default_hasher, BumpMap, ImEntry, ImMap, ImSet, MutMap, MutSet, SendMap};
|
||||||
|
pub use vec_map::VecMap;
|
||||||
pub use vec_set::VecSet;
|
pub use vec_set::VecSet;
|
||||||
|
|
|
@ -112,13 +112,11 @@ mod test_load {
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
assert_eq!(
|
assert!(loaded_module
|
||||||
loaded_module
|
.type_problems
|
||||||
.type_problems
|
.remove(&home)
|
||||||
.remove(&home)
|
.unwrap_or_default()
|
||||||
.unwrap_or_default(),
|
.is_empty(),);
|
||||||
Vec::new()
|
|
||||||
);
|
|
||||||
|
|
||||||
Ok(loaded_module)
|
Ok(loaded_module)
|
||||||
}
|
}
|
||||||
|
@ -208,13 +206,11 @@ mod test_load {
|
||||||
loaded_module.can_problems.remove(&home).unwrap_or_default(),
|
loaded_module.can_problems.remove(&home).unwrap_or_default(),
|
||||||
Vec::new()
|
Vec::new()
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert!(loaded_module
|
||||||
loaded_module
|
.type_problems
|
||||||
.type_problems
|
.remove(&home)
|
||||||
.remove(&home)
|
.unwrap_or_default()
|
||||||
.unwrap_or_default(),
|
.is_empty());
|
||||||
Vec::new()
|
|
||||||
);
|
|
||||||
|
|
||||||
let expected_name = loaded_module
|
let expected_name = loaded_module
|
||||||
.interns
|
.interns
|
||||||
|
@ -261,13 +257,11 @@ mod test_load {
|
||||||
loaded_module.can_problems.remove(&home).unwrap_or_default(),
|
loaded_module.can_problems.remove(&home).unwrap_or_default(),
|
||||||
Vec::new()
|
Vec::new()
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert!(loaded_module
|
||||||
loaded_module
|
.type_problems
|
||||||
.type_problems
|
.remove(&home)
|
||||||
.remove(&home)
|
.unwrap_or_default()
|
||||||
.unwrap_or_default(),
|
.is_empty());
|
||||||
Vec::new()
|
|
||||||
);
|
|
||||||
|
|
||||||
for decl in loaded_module.declarations_by_id.remove(&home).unwrap() {
|
for decl in loaded_module.declarations_by_id.remove(&home).unwrap() {
|
||||||
match decl {
|
match decl {
|
||||||
|
@ -365,13 +359,11 @@ mod test_load {
|
||||||
loaded_module.can_problems.remove(&home).unwrap_or_default(),
|
loaded_module.can_problems.remove(&home).unwrap_or_default(),
|
||||||
Vec::new()
|
Vec::new()
|
||||||
);
|
);
|
||||||
assert_eq!(
|
assert!(loaded_module
|
||||||
loaded_module
|
.type_problems
|
||||||
.type_problems
|
.remove(&home)
|
||||||
.remove(&home)
|
.unwrap_or_default()
|
||||||
.unwrap_or_default(),
|
.is_empty(),);
|
||||||
Vec::new()
|
|
||||||
);
|
|
||||||
|
|
||||||
let def_count: usize = loaded_module
|
let def_count: usize = loaded_module
|
||||||
.declarations_by_id
|
.declarations_by_id
|
||||||
|
|
|
@ -108,7 +108,7 @@ pub struct EntryPoint<'a> {
|
||||||
#[derive(Clone, Copy, Debug)]
|
#[derive(Clone, Copy, Debug)]
|
||||||
pub struct PartialProcId(usize);
|
pub struct PartialProcId(usize);
|
||||||
|
|
||||||
#[derive(Clone, Debug, PartialEq)]
|
#[derive(Clone, Debug)]
|
||||||
pub struct PartialProcs<'a> {
|
pub struct PartialProcs<'a> {
|
||||||
/// maps a function name (symbol) to an index
|
/// maps a function name (symbol) to an index
|
||||||
symbols: Vec<'a, Symbol>,
|
symbols: Vec<'a, Symbol>,
|
||||||
|
@ -190,7 +190,7 @@ impl<'a> PartialProcs<'a> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Clone, Debug, PartialEq)]
|
#[derive(Clone, Debug)]
|
||||||
pub struct PartialProc<'a> {
|
pub struct PartialProc<'a> {
|
||||||
pub annotation: Variable,
|
pub annotation: Variable,
|
||||||
pub pattern_symbols: &'a [Symbol],
|
pub pattern_symbols: &'a [Symbol],
|
||||||
|
|
|
@ -79,7 +79,7 @@ pub struct IncompleteAbilityImplementation {
|
||||||
pub missing_members: Vec<Loc<Symbol>>,
|
pub missing_members: Vec<Loc<Symbol>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(PartialEq, Debug, Clone)]
|
#[derive(Debug, Clone)]
|
||||||
pub enum TypeError {
|
pub enum TypeError {
|
||||||
BadExpr(Region, Category, ErrorType, Expected<ErrorType>),
|
BadExpr(Region, Category, ErrorType, Expected<ErrorType>),
|
||||||
BadPattern(Region, PatternCategory, ErrorType, PExpected<ErrorType>),
|
BadPattern(Region, PatternCategory, ErrorType, PExpected<ErrorType>),
|
||||||
|
|
|
@ -129,7 +129,7 @@ fn compiles_to_ir(test_name: &str, src: &str) {
|
||||||
println!("Ignoring {} canonicalization problems", can_problems.len());
|
println!("Ignoring {} canonicalization problems", can_problems.len());
|
||||||
}
|
}
|
||||||
|
|
||||||
assert_eq!(type_problems, Vec::new());
|
assert!(type_problems.is_empty());
|
||||||
assert_eq!(mono_problems, Vec::new());
|
assert_eq!(mono_problems, Vec::new());
|
||||||
|
|
||||||
debug_assert_eq!(exposed_to_host.values.len(), 1);
|
debug_assert_eq!(exposed_to_host.values.len(), 1);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue