summaryrefslogtreecommitdiff
path: root/dhall/src
diff options
context:
space:
mode:
authorNadrieril2020-05-10 19:32:34 +0100
committerNadrieril2020-10-28 20:18:17 +0000
commit9e3f68fc54babf24133cf66ae6be7d069ba2c271 (patch)
treeac3f0782fb90c8f6b03b3d29d1032d06d637e4ee /dhall/src
parent2b4ba42b7f0a44893f17548f069cec1e60819aa4 (diff)
Prefer u64/i64 to usize/isize
Diffstat (limited to 'dhall/src')
-rw-r--r--dhall/src/builtins.rs6
-rw-r--r--dhall/src/syntax/ast/expr.rs5
-rw-r--r--dhall/src/syntax/text/parser.rs6
3 files changed, 8 insertions, 9 deletions
diff --git a/dhall/src/builtins.rs b/dhall/src/builtins.rs
index e80bf6b..41a9f75 100644
--- a/dhall/src/builtins.rs
+++ b/dhall/src/builtins.rs
@@ -348,7 +348,7 @@ fn apply_builtin(b: Builtin, args: Vec<Nir>, env: NzEnv) -> NirKind {
_ => Ret::DoneAsIs,
},
(Builtin::NaturalToInteger, [n]) => match &*n.kind() {
- Num(Natural(n)) => Ret::NirKind(Num(Integer(*n as isize))),
+ Num(Natural(n)) => Ret::NirKind(Num(Integer(*n as i64))),
_ => Ret::DoneAsIs,
},
(Builtin::NaturalShow, [n]) => match &*n.kind() {
@@ -449,7 +449,7 @@ fn apply_builtin(b: Builtin, args: Vec<Nir>, env: NzEnv) -> NirKind {
}
(Builtin::ListLength, [_, l]) => match &*l.kind() {
EmptyListLit(_) => Ret::NirKind(Num(Natural(0))),
- NEListLit(xs) => Ret::NirKind(Num(Natural(xs.len()))),
+ NEListLit(xs) => Ret::NirKind(Num(Natural(xs.len() as u64))),
_ => Ret::DoneAsIs,
},
(Builtin::ListHead, [_, l]) => match &*l.kind() {
@@ -495,7 +495,7 @@ fn apply_builtin(b: Builtin, args: Vec<Nir>, env: NzEnv) -> NirKind {
let mut kvs = HashMap::new();
kvs.insert(
"index".into(),
- Nir::from_kind(Num(Natural(i))),
+ Nir::from_kind(Num(Natural(i as u64))),
);
kvs.insert("value".into(), e.clone());
Nir::from_kind(RecordLit(kvs))
diff --git a/dhall/src/syntax/ast/expr.rs b/dhall/src/syntax/ast/expr.rs
index d9badb9..b1a978f 100644
--- a/dhall/src/syntax/ast/expr.rs
+++ b/dhall/src/syntax/ast/expr.rs
@@ -7,9 +7,8 @@ use crate::semantics::Universe;
use crate::syntax::visitor;
use crate::syntax::*;
-// TODO: `usize` was a mistake. Should use `u64`.
-pub type Integer = isize;
-pub type Natural = usize;
+pub type Integer = i64;
+pub type Natural = u64;
pub type Double = NaiveDouble;
/// Double with bitwise equality
diff --git a/dhall/src/syntax/text/parser.rs b/dhall/src/syntax/text/parser.rs
index 377f5e4..37f28e5 100644
--- a/dhall/src/syntax/text/parser.rs
+++ b/dhall/src/syntax/text/parser.rs
@@ -378,7 +378,7 @@ impl DhallParser {
let s = input.as_str().trim();
if s.starts_with("0x") {
let without_prefix = s.trim_start_matches("0x");
- usize::from_str_radix(without_prefix, 16)
+ u64::from_str_radix(without_prefix, 16)
.map_err(|e| input.error(format!("{}", e)))
} else {
s.parse().map_err(|e| input.error(format!("{}", e)))
@@ -391,7 +391,7 @@ impl DhallParser {
if rest.starts_with("0x") {
let without_prefix =
sign.to_owned() + rest.trim_start_matches("0x");
- isize::from_str_radix(&without_prefix, 16)
+ i64::from_str_radix(&without_prefix, 16)
.map_err(|e| input.error(format!("{}", e)))
} else {
s.parse().map_err(|e| input.error(format!("{}", e)))
@@ -408,7 +408,7 @@ impl DhallParser {
fn variable(input: ParseInput) -> ParseResult<V> {
Ok(match_nodes!(input.into_children();
- [label(l), natural_literal(idx)] => V(l, idx),
+ [label(l), natural_literal(idx)] => V(l, idx as usize),
[label(l)] => V(l, 0),
))
}