From 549cf22cdd96464503d33abb9b16b77429aa255b Mon Sep 17 00:00:00 2001 From: KtorZ Date: Thu, 6 Jul 2023 10:21:21 +0200 Subject: [PATCH] Rename (Un)TypedExpr.Int -> (Un)TypedExpr.UInt We do not actually every parse negative values in there, as a negative value is a combination of a 'Negate' and 'UInt' expression. However, for patterns and constant, it'll be simpler to parse whole Int values as there's no ambiguity with arithmetic operations there. To avoid confusion of having some 'Int' constructors containing only non-negative values, and some being on the whole range, I've renamed the constructor to 'UInt' to make this more obvious. --- crates/aiken-lang/src/expr.rs | 20 +++++++++---------- crates/aiken-lang/src/format.rs | 6 +++++- crates/aiken-lang/src/gen_uplc.rs | 2 +- .../src/parser/definition/constant.rs | 4 +--- .../aiken-lang/src/parser/expr/bytearray.rs | 4 +--- crates/aiken-lang/src/parser/expr/int.rs | 4 ++-- .../snapshots/anonymous_function_basic.snap | 2 +- .../parser/expr/snapshots/block_basic.snap | 4 ++-- .../expr/snapshots/function_invoke.snap | 8 ++++---- .../parser/expr/snapshots/if_else_basic.snap | 10 +++++----- .../parser/expr/snapshots/int_hex_bytes.snap | 2 +- .../src/parser/expr/snapshots/int_list.snap | 6 +++--- .../parser/expr/snapshots/int_literal.snap | 2 +- .../parser/expr/snapshots/int_negative.snap | 2 +- .../snapshots/int_numeric_underscore.snap | 6 +++--- .../parser/expr/snapshots/let_bindings.snap | 4 ++-- .../parser/expr/snapshots/list_spread.snap | 4 ++-- .../parser/expr/snapshots/parse_tuple.snap | 8 ++++---- .../parser/expr/snapshots/parse_tuple2.snap | 4 ++-- .../src/parser/expr/snapshots/pipeline.snap | 2 +- .../src/parser/expr/snapshots/plus_binop.snap | 2 +- .../expr/snapshots/record_create_labeled.snap | 2 +- ...cord_create_labeled_with_field_access.snap | 2 +- .../snapshots/record_create_unlabeled.snap | 2 +- crates/aiken-lang/src/parser/expr/string.rs | 5 +---- .../expr/when/snapshots/when_basic.snap | 8 ++++---- crates/aiken-lang/src/parser/literal/mod.rs | 10 +++++++--- .../src/parser/literal/{int.rs => uint.rs} | 0 .../function_ambiguous_sequence.snap | 14 ++++++------- crates/aiken-lang/src/tipo/expr.rs | 10 +++++----- 30 files changed, 80 insertions(+), 79 deletions(-) rename crates/aiken-lang/src/parser/literal/{int.rs => uint.rs} (100%) diff --git a/crates/aiken-lang/src/expr.rs b/crates/aiken-lang/src/expr.rs index 05962a02..cf66cb82 100644 --- a/crates/aiken-lang/src/expr.rs +++ b/crates/aiken-lang/src/expr.rs @@ -15,7 +15,7 @@ use crate::{ #[derive(Debug, Clone, PartialEq)] pub enum TypedExpr { - Int { + UInt { location: Span, tipo: Arc, value: String, @@ -170,7 +170,7 @@ impl TypedExpr { Self::Var { constructor, .. } => constructor.tipo.clone(), Self::Trace { then, .. } => then.tipo(), Self::Fn { tipo, .. } - | Self::Int { tipo, .. } + | Self::UInt { tipo, .. } | Self::ErrorTerm { tipo, .. } | Self::When { tipo, .. } | Self::List { tipo, .. } @@ -195,7 +195,7 @@ impl TypedExpr { pub fn is_literal(&self) -> bool { matches!( self, - Self::Int { .. } + Self::UInt { .. } | Self::List { .. } | Self::Tuple { .. } | Self::String { .. } @@ -211,7 +211,7 @@ impl TypedExpr { pub fn definition_location(&self) -> Option> { match self { TypedExpr::Fn { .. } - | TypedExpr::Int { .. } + | TypedExpr::UInt { .. } | TypedExpr::Trace { .. } | TypedExpr::List { .. } | TypedExpr::Call { .. } @@ -251,7 +251,7 @@ impl TypedExpr { pub fn type_defining_location(&self) -> Span { match self { Self::Fn { location, .. } - | Self::Int { location, .. } + | Self::UInt { location, .. } | Self::Var { location, .. } | Self::Trace { location, .. } | Self::ErrorTerm { location, .. } @@ -286,7 +286,7 @@ impl TypedExpr { pub fn location(&self) -> Span { match self { Self::Fn { location, .. } - | Self::Int { location, .. } + | Self::UInt { location, .. } | Self::Trace { location, .. } | Self::Var { location, .. } | Self::ErrorTerm { location, .. } @@ -319,7 +319,7 @@ impl TypedExpr { match self { TypedExpr::ErrorTerm { .. } | TypedExpr::Var { .. } - | TypedExpr::Int { .. } + | TypedExpr::UInt { .. } | TypedExpr::String { .. } | TypedExpr::ByteArray { .. } | TypedExpr::ModuleSelect { .. } => Some(self), @@ -409,7 +409,7 @@ pub enum FnStyle { #[derive(Debug, Clone, PartialEq)] pub enum UntypedExpr { - Int { + UInt { location: Span, value: String, base: Base, @@ -619,7 +619,7 @@ impl UntypedExpr { Self::TraceIfFalse { location, .. } | Self::Fn { location, .. } | Self::Var { location, .. } - | Self::Int { location, .. } + | Self::UInt { location, .. } | Self::ErrorTerm { location, .. } | Self::When { location, .. } | Self::Call { location, .. } @@ -669,7 +669,7 @@ impl UntypedExpr { pub fn is_simple_constant(&self) -> bool { matches!( self, - Self::String { .. } | Self::Int { .. } | Self::ByteArray { .. } + Self::String { .. } | Self::UInt { .. } | Self::ByteArray { .. } ) } } diff --git a/crates/aiken-lang/src/format.rs b/crates/aiken-lang/src/format.rs index e345875c..0d5f3e31 100644 --- a/crates/aiken-lang/src/format.rs +++ b/crates/aiken-lang/src/format.rs @@ -702,6 +702,10 @@ impl<'comments> Formatter<'comments> { } pub fn int<'a>(&mut self, s: &'a str, base: &Base) -> Document<'a> { + unimplemented!() + } + + pub fn uint<'a>(&mut self, s: &'a str, base: &Base) -> Document<'a> { match base { Base::Decimal { numeric_underscore } if *numeric_underscore => { let s = s @@ -755,7 +759,7 @@ impl<'comments> Formatter<'comments> { one_liner, } => self.pipeline(expressions, *one_liner), - UntypedExpr::Int { value, base, .. } => self.int(value, base), + UntypedExpr::UInt { value, base, .. } => self.uint(value, base), UntypedExpr::String { value, .. } => self.string(value), diff --git a/crates/aiken-lang/src/gen_uplc.rs b/crates/aiken-lang/src/gen_uplc.rs index 59b7f84b..6de17042 100644 --- a/crates/aiken-lang/src/gen_uplc.rs +++ b/crates/aiken-lang/src/gen_uplc.rs @@ -221,7 +221,7 @@ impl<'a> CodeGenerator<'a> { pub(crate) fn build(&mut self, body: &TypedExpr, ir_stack: &mut AirStack) { match body { - TypedExpr::Int { value, .. } => ir_stack.integer(value.to_string()), + TypedExpr::UInt { value, .. } => ir_stack.integer(value.to_string()), TypedExpr::String { value, .. } => ir_stack.string(value.to_string()), TypedExpr::ByteArray { bytes, .. } => ir_stack.byte_array(bytes.to_vec()), TypedExpr::Pipeline { expressions, .. } | TypedExpr::Sequence { expressions, .. } => { diff --git a/crates/aiken-lang/src/parser/definition/constant.rs b/crates/aiken-lang/src/parser/definition/constant.rs index 1e2629ed..834449d9 100644 --- a/crates/aiken-lang/src/parser/definition/constant.rs +++ b/crates/aiken-lang/src/parser/definition/constant.rs @@ -2,9 +2,7 @@ use chumsky::prelude::*; use crate::{ ast, - parser::{ - annotation, error::ParseError, literal::bytearray::parser as bytearray, token::Token, utils, - }, + parser::{annotation, error::ParseError, literal::bytearray, token::Token, utils}, }; pub fn parser() -> impl Parser { diff --git a/crates/aiken-lang/src/parser/expr/bytearray.rs b/crates/aiken-lang/src/parser/expr/bytearray.rs index 2829b8dc..32536880 100644 --- a/crates/aiken-lang/src/parser/expr/bytearray.rs +++ b/crates/aiken-lang/src/parser/expr/bytearray.rs @@ -1,8 +1,6 @@ use chumsky::prelude::*; -use crate::parser::{ - error::ParseError, expr::UntypedExpr, literal::bytearray::parser as bytearray, token::Token, -}; +use crate::parser::{error::ParseError, expr::UntypedExpr, literal::bytearray, token::Token}; pub fn parser() -> impl Parser { bytearray(|bytes, preferred_format, location| UntypedExpr::ByteArray { diff --git a/crates/aiken-lang/src/parser/expr/int.rs b/crates/aiken-lang/src/parser/expr/int.rs index 5ed56f13..47393058 100644 --- a/crates/aiken-lang/src/parser/expr/int.rs +++ b/crates/aiken-lang/src/parser/expr/int.rs @@ -2,11 +2,11 @@ use chumsky::prelude::*; use crate::{ expr::UntypedExpr, - parser::{error::ParseError, literal::int::parser as int, token::Token}, + parser::{error::ParseError, literal::uint, token::Token}, }; pub fn parser() -> impl Parser { - int().map_with_span(|(value, base), span| UntypedExpr::Int { + uint().map_with_span(|(value, base), span| UntypedExpr::UInt { location: span, value, base, diff --git a/crates/aiken-lang/src/parser/expr/snapshots/anonymous_function_basic.snap b/crates/aiken-lang/src/parser/expr/snapshots/anonymous_function_basic.snap index da64b10f..d703169f 100644 --- a/crates/aiken-lang/src/parser/expr/snapshots/anonymous_function_basic.snap +++ b/crates/aiken-lang/src/parser/expr/snapshots/anonymous_function_basic.snap @@ -32,7 +32,7 @@ Fn { location: 21..22, name: "a", }, - right: Int { + right: UInt { location: 25..26, value: "1", base: Decimal { diff --git a/crates/aiken-lang/src/parser/expr/snapshots/block_basic.snap b/crates/aiken-lang/src/parser/expr/snapshots/block_basic.snap index 7d07f718..437ab513 100644 --- a/crates/aiken-lang/src/parser/expr/snapshots/block_basic.snap +++ b/crates/aiken-lang/src/parser/expr/snapshots/block_basic.snap @@ -9,7 +9,7 @@ Assignment { expressions: [ Assignment { location: 12..21, - value: Int { + value: UInt { location: 20..21, value: "4", base: Decimal { @@ -30,7 +30,7 @@ Assignment { location: 25..26, name: "x", }, - right: Int { + right: UInt { location: 29..30, value: "5", base: Decimal { diff --git a/crates/aiken-lang/src/parser/expr/snapshots/function_invoke.snap b/crates/aiken-lang/src/parser/expr/snapshots/function_invoke.snap index 411a7f4f..294b34a8 100644 --- a/crates/aiken-lang/src/parser/expr/snapshots/function_invoke.snap +++ b/crates/aiken-lang/src/parser/expr/snapshots/function_invoke.snap @@ -12,7 +12,7 @@ Sequence { CallArg { label: None, location: 16..17, - value: Int { + value: UInt { location: 16..17, value: "3", base: Decimal { @@ -124,21 +124,21 @@ Sequence { value: List { location: 77..88, elements: [ - Int { + UInt { location: 79..80, value: "1", base: Decimal { numeric_underscore: false, }, }, - Int { + UInt { location: 82..83, value: "2", base: Decimal { numeric_underscore: false, }, }, - Int { + UInt { location: 85..86, value: "3", base: Decimal { diff --git a/crates/aiken-lang/src/parser/expr/snapshots/if_else_basic.snap b/crates/aiken-lang/src/parser/expr/snapshots/if_else_basic.snap index 32cbd034..4493776d 100644 --- a/crates/aiken-lang/src/parser/expr/snapshots/if_else_basic.snap +++ b/crates/aiken-lang/src/parser/expr/snapshots/if_else_basic.snap @@ -13,14 +13,14 @@ If { body: BinOp { location: 12..17, name: AddInt, - left: Int { + left: UInt { location: 12..13, value: "1", base: Decimal { numeric_underscore: false, }, }, - right: Int { + right: UInt { location: 16..17, value: "1", base: Decimal { @@ -38,7 +38,7 @@ If { location: 28..29, name: "a", }, - right: Int { + right: UInt { location: 32..33, value: "1", base: Decimal { @@ -46,7 +46,7 @@ If { }, }, }, - body: Int { + body: UInt { location: 38..39, value: "3", base: Decimal { @@ -56,7 +56,7 @@ If { location: 28..41, }, ], - final_else: Int { + final_else: UInt { location: 51..52, value: "4", base: Decimal { diff --git a/crates/aiken-lang/src/parser/expr/snapshots/int_hex_bytes.snap b/crates/aiken-lang/src/parser/expr/snapshots/int_hex_bytes.snap index 56ab77ec..8ccc01ef 100644 --- a/crates/aiken-lang/src/parser/expr/snapshots/int_hex_bytes.snap +++ b/crates/aiken-lang/src/parser/expr/snapshots/int_hex_bytes.snap @@ -2,7 +2,7 @@ source: crates/aiken-lang/src/parser/expr/int.rs description: "Code:\n\n0x01" --- -Int { +UInt { location: 0..4, value: "1", base: Hexadecimal, diff --git a/crates/aiken-lang/src/parser/expr/snapshots/int_list.snap b/crates/aiken-lang/src/parser/expr/snapshots/int_list.snap index a2040224..683a88aa 100644 --- a/crates/aiken-lang/src/parser/expr/snapshots/int_list.snap +++ b/crates/aiken-lang/src/parser/expr/snapshots/int_list.snap @@ -5,21 +5,21 @@ description: "Code:\n\n[1, 2, 3]" List { location: 0..9, elements: [ - Int { + UInt { location: 1..2, value: "1", base: Decimal { numeric_underscore: false, }, }, - Int { + UInt { location: 4..5, value: "2", base: Decimal { numeric_underscore: false, }, }, - Int { + UInt { location: 7..8, value: "3", base: Decimal { diff --git a/crates/aiken-lang/src/parser/expr/snapshots/int_literal.snap b/crates/aiken-lang/src/parser/expr/snapshots/int_literal.snap index da7cb54b..4ff4eac3 100644 --- a/crates/aiken-lang/src/parser/expr/snapshots/int_literal.snap +++ b/crates/aiken-lang/src/parser/expr/snapshots/int_literal.snap @@ -2,7 +2,7 @@ source: crates/aiken-lang/src/parser/expr/int.rs description: "Code:\n\n1" --- -Int { +UInt { location: 0..1, value: "1", base: Decimal { diff --git a/crates/aiken-lang/src/parser/expr/snapshots/int_negative.snap b/crates/aiken-lang/src/parser/expr/snapshots/int_negative.snap index fcf40a1d..dc2e4880 100644 --- a/crates/aiken-lang/src/parser/expr/snapshots/int_negative.snap +++ b/crates/aiken-lang/src/parser/expr/snapshots/int_negative.snap @@ -5,7 +5,7 @@ description: "Code:\n\n-1" UnOp { op: Negate, location: 0..2, - value: Int { + value: UInt { location: 1..2, value: "1", base: Decimal { diff --git a/crates/aiken-lang/src/parser/expr/snapshots/int_numeric_underscore.snap b/crates/aiken-lang/src/parser/expr/snapshots/int_numeric_underscore.snap index 566e732e..5f1db19c 100644 --- a/crates/aiken-lang/src/parser/expr/snapshots/int_numeric_underscore.snap +++ b/crates/aiken-lang/src/parser/expr/snapshots/int_numeric_underscore.snap @@ -7,7 +7,7 @@ Sequence { expressions: [ Assignment { location: 4..21, - value: Int { + value: UInt { location: 12..21, value: "1234567", base: Decimal { @@ -23,7 +23,7 @@ Sequence { }, Assignment { location: 24..41, - value: Int { + value: UInt { location: 32..41, value: "1000000", base: Decimal { @@ -42,7 +42,7 @@ Sequence { value: UnOp { op: Negate, location: 52..59, - value: Int { + value: UInt { location: 53..59, value: "10000", base: Decimal { diff --git a/crates/aiken-lang/src/parser/expr/snapshots/let_bindings.snap b/crates/aiken-lang/src/parser/expr/snapshots/let_bindings.snap index 71e556c8..ef8eef02 100644 --- a/crates/aiken-lang/src/parser/expr/snapshots/let_bindings.snap +++ b/crates/aiken-lang/src/parser/expr/snapshots/let_bindings.snap @@ -7,14 +7,14 @@ Assignment { value: List { location: 12..23, elements: [ - Int { + UInt { location: 14..15, value: "1", base: Decimal { numeric_underscore: false, }, }, - Int { + UInt { location: 17..18, value: "2", base: Decimal { diff --git a/crates/aiken-lang/src/parser/expr/snapshots/list_spread.snap b/crates/aiken-lang/src/parser/expr/snapshots/list_spread.snap index 2009bc42..c90e69bc 100644 --- a/crates/aiken-lang/src/parser/expr/snapshots/list_spread.snap +++ b/crates/aiken-lang/src/parser/expr/snapshots/list_spread.snap @@ -5,14 +5,14 @@ description: "Code:\n\n[1, 2, ..[]]" List { location: 0..12, elements: [ - Int { + UInt { location: 1..2, value: "1", base: Decimal { numeric_underscore: false, }, }, - Int { + UInt { location: 4..5, value: "2", base: Decimal { diff --git a/crates/aiken-lang/src/parser/expr/snapshots/parse_tuple.snap b/crates/aiken-lang/src/parser/expr/snapshots/parse_tuple.snap index 857616c8..4fa94b9e 100644 --- a/crates/aiken-lang/src/parser/expr/snapshots/parse_tuple.snap +++ b/crates/aiken-lang/src/parser/expr/snapshots/parse_tuple.snap @@ -10,28 +10,28 @@ Sequence { value: Tuple { location: 12..24, elems: [ - Int { + UInt { location: 13..14, value: "1", base: Decimal { numeric_underscore: false, }, }, - Int { + UInt { location: 16..17, value: "2", base: Decimal { numeric_underscore: false, }, }, - Int { + UInt { location: 19..20, value: "3", base: Decimal { numeric_underscore: false, }, }, - Int { + UInt { location: 22..23, value: "4", base: Decimal { diff --git a/crates/aiken-lang/src/parser/expr/snapshots/parse_tuple2.snap b/crates/aiken-lang/src/parser/expr/snapshots/parse_tuple2.snap index 634d6184..ede9ec5a 100644 --- a/crates/aiken-lang/src/parser/expr/snapshots/parse_tuple2.snap +++ b/crates/aiken-lang/src/parser/expr/snapshots/parse_tuple2.snap @@ -12,7 +12,7 @@ Sequence { CallArg { label: None, location: 12..14, - value: Int { + value: UInt { location: 12..14, value: "14", base: Decimal { @@ -41,7 +41,7 @@ Sequence { location: 17..18, name: "a", }, - Int { + UInt { location: 20..22, value: "42", base: Decimal { diff --git a/crates/aiken-lang/src/parser/expr/snapshots/pipeline.snap b/crates/aiken-lang/src/parser/expr/snapshots/pipeline.snap index f98b6a8c..e033386b 100644 --- a/crates/aiken-lang/src/parser/expr/snapshots/pipeline.snap +++ b/crates/aiken-lang/src/parser/expr/snapshots/pipeline.snap @@ -11,7 +11,7 @@ PipeLine { location: 0..1, name: "a", }, - right: Int { + right: UInt { location: 4..5, value: "2", base: Decimal { diff --git a/crates/aiken-lang/src/parser/expr/snapshots/plus_binop.snap b/crates/aiken-lang/src/parser/expr/snapshots/plus_binop.snap index 397597ec..4510b839 100644 --- a/crates/aiken-lang/src/parser/expr/snapshots/plus_binop.snap +++ b/crates/aiken-lang/src/parser/expr/snapshots/plus_binop.snap @@ -9,7 +9,7 @@ BinOp { location: 0..1, name: "a", }, - right: Int { + right: UInt { location: 4..5, value: "1", base: Decimal { diff --git a/crates/aiken-lang/src/parser/expr/snapshots/record_create_labeled.snap b/crates/aiken-lang/src/parser/expr/snapshots/record_create_labeled.snap index 13c2c433..d6274e00 100644 --- a/crates/aiken-lang/src/parser/expr/snapshots/record_create_labeled.snap +++ b/crates/aiken-lang/src/parser/expr/snapshots/record_create_labeled.snap @@ -36,7 +36,7 @@ Call { "thing", ), location: 27..35, - value: Int { + value: UInt { location: 34..35, value: "2", base: Decimal { diff --git a/crates/aiken-lang/src/parser/expr/snapshots/record_create_labeled_with_field_access.snap b/crates/aiken-lang/src/parser/expr/snapshots/record_create_labeled_with_field_access.snap index f1f46e9b..f4738e38 100644 --- a/crates/aiken-lang/src/parser/expr/snapshots/record_create_labeled_with_field_access.snap +++ b/crates/aiken-lang/src/parser/expr/snapshots/record_create_labeled_with_field_access.snap @@ -36,7 +36,7 @@ Call { "thing", ), location: 39..47, - value: Int { + value: UInt { location: 46..47, value: "2", base: Decimal { diff --git a/crates/aiken-lang/src/parser/expr/snapshots/record_create_unlabeled.snap b/crates/aiken-lang/src/parser/expr/snapshots/record_create_unlabeled.snap index 2f9f629c..b14a4a00 100644 --- a/crates/aiken-lang/src/parser/expr/snapshots/record_create_unlabeled.snap +++ b/crates/aiken-lang/src/parser/expr/snapshots/record_create_unlabeled.snap @@ -7,7 +7,7 @@ Call { CallArg { label: None, location: 18..19, - value: Int { + value: UInt { location: 18..19, value: "1", base: Decimal { diff --git a/crates/aiken-lang/src/parser/expr/string.rs b/crates/aiken-lang/src/parser/expr/string.rs index ed8f4f75..01f24a48 100644 --- a/crates/aiken-lang/src/parser/expr/string.rs +++ b/crates/aiken-lang/src/parser/expr/string.rs @@ -2,10 +2,7 @@ use chumsky::prelude::*; use crate::{ expr::UntypedExpr, - parser::{ - error::ParseError, literal::bytearray::utf8_string, literal::string::parser as string, - token::Token, - }, + parser::{error::ParseError, literal::string, literal::utf8_string, token::Token}, }; pub fn parser() -> impl Parser { diff --git a/crates/aiken-lang/src/parser/expr/when/snapshots/when_basic.snap b/crates/aiken-lang/src/parser/expr/when/snapshots/when_basic.snap index 7d5056b6..53a3665a 100644 --- a/crates/aiken-lang/src/parser/expr/when/snapshots/when_basic.snap +++ b/crates/aiken-lang/src/parser/expr/when/snapshots/when_basic.snap @@ -39,7 +39,7 @@ When { ), }, ), - then: Int { + then: UInt { location: 28..29, value: "3", base: Decimal { @@ -78,7 +78,7 @@ When { expressions: [ Assignment { location: 51..66, - value: Int { + value: UInt { location: 65..66, value: "5", base: Decimal { @@ -111,7 +111,7 @@ When { }, ], guard: None, - then: Int { + then: UInt { location: 90..91, value: "9", base: Decimal { @@ -128,7 +128,7 @@ When { }, ], guard: None, - then: Int { + then: UInt { location: 99..100, value: "4", base: Decimal { diff --git a/crates/aiken-lang/src/parser/literal/mod.rs b/crates/aiken-lang/src/parser/literal/mod.rs index 6a67a32e..cc5dd8c6 100644 --- a/crates/aiken-lang/src/parser/literal/mod.rs +++ b/crates/aiken-lang/src/parser/literal/mod.rs @@ -1,3 +1,7 @@ -pub(crate) mod bytearray; -pub(crate) mod int; -pub(crate) mod string; +mod bytearray; +mod string; +mod uint; + +pub use bytearray::{array_of_bytes, hex_string, parser as bytearray, utf8_string}; +pub use string::parser as string; +pub use uint::parser as uint; diff --git a/crates/aiken-lang/src/parser/literal/int.rs b/crates/aiken-lang/src/parser/literal/uint.rs similarity index 100% rename from crates/aiken-lang/src/parser/literal/int.rs rename to crates/aiken-lang/src/parser/literal/uint.rs diff --git a/crates/aiken-lang/src/snapshots/function_ambiguous_sequence.snap b/crates/aiken-lang/src/snapshots/function_ambiguous_sequence.snap index 0f6292b0..08fec703 100644 --- a/crates/aiken-lang/src/snapshots/function_ambiguous_sequence.snap +++ b/crates/aiken-lang/src/snapshots/function_ambiguous_sequence.snap @@ -26,7 +26,7 @@ Module { kind: Let, annotation: None, }, - Int { + UInt { location: 30..32, value: "40", base: Decimal { @@ -64,7 +64,7 @@ Module { kind: Let, annotation: None, }, - Int { + UInt { location: 67..69, value: "40", base: Decimal { @@ -91,14 +91,14 @@ Module { value: BinOp { location: 98..102, name: AddInt, - left: Int { + left: UInt { location: 98..100, value: "40", base: Decimal { numeric_underscore: false, }, }, - right: Int { + right: UInt { location: 101..102, value: "2", base: Decimal { @@ -136,7 +136,7 @@ Module { CallArg { label: None, location: 134..136, - value: Int { + value: UInt { location: 134..136, value: "42", base: Decimal { @@ -168,7 +168,7 @@ Module { location: 141..142, name: "a", }, - right: Int { + right: UInt { location: 145..147, value: "14", base: Decimal { @@ -176,7 +176,7 @@ Module { }, }, }, - right: Int { + right: UInt { location: 151..153, value: "42", base: Decimal { diff --git a/crates/aiken-lang/src/tipo/expr.rs b/crates/aiken-lang/src/tipo/expr.rs index f4a39b06..1a712230 100644 --- a/crates/aiken-lang/src/tipo/expr.rs +++ b/crates/aiken-lang/src/tipo/expr.rs @@ -199,9 +199,9 @@ impl<'a, 'b> ExprTyper<'a, 'b> { UntypedExpr::Var { location, name, .. } => self.infer_var(name, location), - UntypedExpr::Int { + UntypedExpr::UInt { location, value, .. - } => Ok(self.infer_int(value, location)), + } => Ok(self.infer_uint(value, location)), UntypedExpr::Sequence { expressions, @@ -1520,8 +1520,8 @@ impl<'a, 'b> ExprTyper<'a, 'b> { Ok((args, body)) } - fn infer_int(&mut self, value: String, location: Span) -> TypedExpr { - TypedExpr::Int { + fn infer_uint(&mut self, value: String, location: Span) -> TypedExpr { + TypedExpr::UInt { location, value, tipo: int(), @@ -1943,7 +1943,7 @@ fn assert_no_assignment(expr: &UntypedExpr) -> Result<(), Error> { | UntypedExpr::ErrorTerm { .. } | UntypedExpr::FieldAccess { .. } | UntypedExpr::If { .. } - | UntypedExpr::Int { .. } + | UntypedExpr::UInt { .. } | UntypedExpr::List { .. } | UntypedExpr::PipeLine { .. } | UntypedExpr::RecordUpdate { .. }