Typecheck numeric literals with suffixes in expressions

Part of #2350
This commit is contained in:
ayazhafiz 2022-01-31 17:58:59 -05:00
parent 320827167f
commit e03592930f
21 changed files with 1165 additions and 369 deletions

View file

@ -1,4 +1,6 @@
use crate::builtins::{empty_list_type, float_literal, int_literal, list_type, str_type};
use crate::builtins::{
empty_list_type, float_literal, int_literal, list_type, num_literal, str_type,
};
use crate::pattern::{constrain_pattern, PatternState};
use roc_can::annotation::IntroducedVariables;
use roc_can::constraint::Constraint::{self, *};
@ -96,20 +98,11 @@ pub fn constrain_expr(
expected: Expected<Type>,
) -> Constraint {
match expr {
// TODO constrain with bound
Int(var, precision, _, _, _bound) => int_literal(*var, *precision, expected, region),
// TODO constrain with bound
Num(var, _, _, _bound) => exists(
vec![*var],
Eq(
crate::builtins::num_num(Type::Variable(*var)),
expected,
Category::Num,
region,
),
),
// TODO constrain with bound
Float(var, precision, _, _, _bound) => float_literal(*var, *precision, expected, region),
&Int(var, precision, _, _, bound) => int_literal(var, precision, expected, region, bound),
&Num(var, _, _, bound) => num_literal(var, expected, region, bound),
&Float(var, precision, _, _, bound) => {
float_literal(var, precision, expected, region, bound)
}
EmptyRecord => constrain_empty_record(region, expected),
Expr::Record { record_var, fields } => {
if fields.is_empty() {