mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-30 15:21:12 +00:00
fix: should not check args.is_empty()
This commit is contained in:
parent
e91fc2f1ff
commit
b734b3de58
3 changed files with 25 additions and 18 deletions
|
@ -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),
|
||||
|
|
|
@ -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,
|
||||
};
|
||||
|
||||
|
|
|
@ -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),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue