diff --git a/compiler/constrain/src/uniq.rs b/compiler/constrain/src/uniq.rs index ebc529f375..07c530761c 100644 --- a/compiler/constrain/src/uniq.rs +++ b/compiler/constrain/src/uniq.rs @@ -12,7 +12,6 @@ use roc_module::ident::{Ident, Lowercase}; use roc_module::symbol::{ModuleId, Symbol}; use roc_region::all::{Located, Region}; use roc_types::boolean_algebra::Bool; -use roc_types::builtin_aliases; use roc_types::subs::{VarStore, Variable}; use roc_types::types::AnnotationSource::{self, *}; use roc_types::types::Type::{self, *}; @@ -167,9 +166,9 @@ fn constrain_pattern( } NumLiteral(inner_var, _) => { - let (num_uvar, val_uvar, num_type, num_var) = unique_unbound_num(*inner_var, var_store); + let (num_var, num_type) = unique_unbound_num(*inner_var, var_store); state.constraints.push(exists( - vec![val_uvar, num_uvar, num_var, *inner_var], + vec![num_var, *inner_var], Constraint::Pattern(pattern.region, PatternCategory::Num, num_type, expected), )); } @@ -407,21 +406,16 @@ fn constrain_pattern( } } -fn unique_unbound_num( - inner_var: Variable, - var_store: &mut VarStore, -) -> (Variable, Variable, Type, Variable) { +fn unique_unbound_num(inner_var: Variable, var_store: &mut VarStore) -> (Variable, Type) { let num_var = var_store.fresh(); - let num_uvar = var_store.fresh(); - let val_uvar = var_store.fresh(); let val_type = Type::Variable(inner_var); - let val_utype = attr_type(Bool::variable(val_uvar), val_type); + let val_utype = attr_type(Bool::variable(num_var), val_type); let num_utype = num_num(val_utype); - let num_type = attr_type(Bool::variable(num_uvar), num_utype); + let num_type = attr_type(Bool::variable(num_var), num_utype); - (num_uvar, val_uvar, num_type, num_var) + (num_var, num_type) } fn unique_int(var_store: &mut VarStore) -> (Variable, Type) { @@ -464,10 +458,10 @@ pub fn constrain_expr( match expr { Num(inner_var, _) => { let var = var_store.fresh(); - let (num_uvar, val_uvar, num_type, num_var) = unique_unbound_num(*inner_var, var_store); + let (num_var, num_type) = unique_unbound_num(*inner_var, var_store); exists( - vec![var, *inner_var, val_uvar, num_uvar, num_var], + vec![var, *inner_var, num_var], And(vec![ Eq( Type::Variable(var), diff --git a/compiler/reporting/src/error/type.rs b/compiler/reporting/src/error/type.rs index 1decdf059d..c5beb5dfc3 100644 --- a/compiler/reporting/src/error/type.rs +++ b/compiler/reporting/src/error/type.rs @@ -1643,6 +1643,17 @@ fn to_diff<'b>( ErrorType::Type(Symbol::NUM_F64, _) => true, ErrorType::Alias(Symbol::NUM_F64, _, _) => true, + ErrorType::Type(Symbol::NUM_NUM, args) => match &args.get(0) { + Some(ErrorType::Type(Symbol::NUM_FLOATINGPOINT, _)) => true, + Some(ErrorType::Alias(Symbol::NUM_FLOATINGPOINT, _, _)) => true, + _ => false, + }, + ErrorType::Alias(Symbol::NUM_NUM, args, _) => match &args.get(0) { + Some((_, ErrorType::Type(Symbol::NUM_FLOATINGPOINT, _))) => true, + Some((_, ErrorType::Alias(Symbol::NUM_FLOATINGPOINT, _, _))) => true, + _ => false, + }, + _ => false, }; diff --git a/compiler/types/src/pretty_print.rs b/compiler/types/src/pretty_print.rs index d2dd43db1c..22602ae94e 100644 --- a/compiler/types/src/pretty_print.rs +++ b/compiler/types/src/pretty_print.rs @@ -77,6 +77,8 @@ fn find_names_needed( use crate::subs::Content::*; use crate::subs::FlatType::*; + dbg!(variable); + while let Some((recursive, _chain)) = subs.occurs(variable) { let content = subs.get_without_compacting(recursive).content; match content { @@ -753,10 +755,10 @@ fn write_apply( match &arg_content { Content::Structure(FlatType::Apply(symbol, nested_args)) => match *symbol { - Symbol::NUM_INTEGER if nested_args.is_empty() => { + Symbol::NUM_INTEGER if nested_args.len() == 1 => { buf.push_str("I64"); } - Symbol::NUM_FLOATINGPOINT if nested_args.is_empty() => { + Symbol::NUM_FLOATINGPOINT if nested_args.len() == 1 => { buf.push_str("F64"); } Symbol::ATTR_ATTR => match nested_args @@ -767,10 +769,10 @@ fn write_apply( double_nested_symbol, double_nested_args, ))) => match double_nested_symbol { - Symbol::NUM_INTEGER if double_nested_args.is_empty() => { + Symbol::NUM_INTEGER if double_nested_args.len() == 1 => { buf.push_str("I64"); } - Symbol::NUM_FLOATINGPOINT if double_nested_args.is_empty() => { + Symbol::NUM_FLOATINGPOINT if double_nested_args.len() == 1 => { buf.push_str("F64"); } _ => default_case(subs, arg_content),