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,6 +1,6 @@
use crate::ast::{
AliasHeader, AssignedField, Collection, CommentOrNewline, Def, Expr, ExtractSpaces,
NumericBound, Pattern, Spaceable, TypeAnnotation,
AliasHeader, AssignedField, Collection, CommentOrNewline, Def, Expr, ExtractSpaces, Pattern,
Spaceable, TypeAnnotation,
};
use crate::blankspace::{space0_after_e, space0_around_ee, space0_before_e, space0_e};
use crate::ident::{lowercase_ident, parse_ident, Ident};
@ -16,6 +16,7 @@ use crate::type_annotation;
use bumpalo::collections::Vec;
use bumpalo::Bump;
use roc_module::called_via::{BinOp, CalledVia, UnaryOp};
use roc_module::numeric::NumericBound;
use roc_region::all::{Loc, Position, Region};
use crate::parser::Progress::{self, *};
@ -377,7 +378,7 @@ impl<'a> ExprState<'a> {
} else {
let region = self.expr.region;
let mut value = Expr::Num("", NumericBound::None);
let mut value = Expr::Num("", NumericBound::None { width_variable: () });
std::mem::swap(&mut self.expr.value, &mut value);
self.expr = arena
@ -1454,6 +1455,7 @@ fn expr_to_pattern_help<'a>(arena: &'a Bump, expr: &Expr<'a>) -> Result<Pattern<
&Expr::Float(string, bound) => Ok(Pattern::FloatLiteral(string, bound)),
&Expr::Num(string, bound) => Ok(Pattern::NumLiteral(string, bound)),
&Expr::Int(string, bound) => Ok(Pattern::IntLiteral(string, bound)),
Expr::NonBase10Int {
string,
base,
@ -2325,6 +2327,7 @@ fn positive_number_literal_help<'a>() -> impl Parser<'a, Expr<'a>, ENumber> {
match literal {
Num(s, bound) => Expr::Num(s, bound),
Float(s, bound) => Expr::Float(s, bound),
Int(s, bound) => Expr::Int(s, bound),
NonBase10Int {
string,
base,
@ -2348,6 +2351,7 @@ fn number_literal_help<'a>() -> impl Parser<'a, Expr<'a>, ENumber> {
match literal {
Num(s, bound) => Expr::Num(s, bound),
Float(s, bound) => Expr::Float(s, bound),
Int(s, bound) => Expr::Int(s, bound),
NonBase10Int {
string,
base,