summaryrefslogtreecommitdiff
path: root/dhall
diff options
context:
space:
mode:
Diffstat (limited to 'dhall')
-rw-r--r--dhall/src/typecheck.rs12
-rw-r--r--dhall/tests/common/mod.rs20
-rw-r--r--dhall/tests/typecheck.rs6
3 files changed, 30 insertions, 8 deletions
diff --git a/dhall/src/typecheck.rs b/dhall/src/typecheck.rs
index becabbd..fe9f68c 100644
--- a/dhall/src/typecheck.rs
+++ b/dhall/src/typecheck.rs
@@ -17,40 +17,50 @@ impl Resolved {
}
}
impl Typed {
+ #[inline(always)]
fn as_expr(&self) -> &SubExpr<X, X> {
&self.0
}
+ #[inline(always)]
fn into_expr(self) -> SubExpr<X, X> {
self.0
}
+ #[inline(always)]
pub fn get_type<'a>(&'a self) -> Type<'a> {
self.1.reborrow()
}
}
impl Normalized {
+ #[inline(always)]
fn as_expr(&self) -> &SubExpr<X, X> {
&self.0
}
+ #[inline(always)]
fn into_expr(self) -> SubExpr<X, X> {
self.0
}
+ #[inline(always)]
pub fn get_type<'a>(&'a self) -> Type<'a> {
self.1.reborrow()
}
+ #[inline(always)]
fn into_type(self) -> Type<'static> {
crate::expr::Type(Cow::Owned(TypeInternal::Expr(Box::new(self))))
}
}
impl<'a> Type<'a> {
+ #[inline(always)]
fn into_owned(self) -> Type<'static> {
Type(Cow::Owned(self.0.into_owned()))
}
+ #[inline(always)]
fn reborrow<'b>(&'b self) -> Type<'b> {
match &self.0 {
Cow::Owned(x) => crate::expr::Type(Cow::Borrowed(x)),
Cow::Borrowed(x) => crate::expr::Type(Cow::Borrowed(x)),
}
}
+ #[inline(always)]
fn as_expr(&'a self) -> Result<&'a SubExpr<X, X>, TypeError<X>> {
use TypeInternal::*;
match self.0.as_ref() {
@@ -62,6 +72,7 @@ impl<'a> Type<'a> {
)),
}
}
+ #[inline(always)]
fn into_expr(self) -> Result<SubExpr<X, X>, TypeError<X>> {
use TypeInternal::*;
match self.0.into_owned() {
@@ -73,6 +84,7 @@ impl<'a> Type<'a> {
)),
}
}
+ #[inline(always)]
pub fn get_type<'b>(&'b self) -> Type<'b> {
use TypeInternal::*;
match self.0.as_ref() {
diff --git a/dhall/tests/common/mod.rs b/dhall/tests/common/mod.rs
index 861df63..3c2fc3c 100644
--- a/dhall/tests/common/mod.rs
+++ b/dhall/tests/common/mod.rs
@@ -113,11 +113,21 @@ pub fn run_test(base_path: &str, feature: Feature) {
typecheck::type_of(expr).unwrap_err();
}
TypecheckSuccess => {
- let expr_file_path = base_path.clone() + "A.dhall";
- let expected_file_path = base_path + "B.dhall";
- let expr = rc(read_dhall_file(&expr_file_path).unwrap());
- let expected = rc(read_dhall_file(&expected_file_path).unwrap());
- typecheck::type_of(rc(ExprF::Annot(expr, expected))).unwrap();
+ // Many tests stack overflow in debug mode
+ std::thread::Builder::new()
+ .stack_size(4 * 1024 * 1024)
+ .spawn(|| {
+ let expr_file_path = base_path.clone() + "A.dhall";
+ let expected_file_path = base_path + "B.dhall";
+ let expr = rc(read_dhall_file(&expr_file_path).unwrap());
+ let expected =
+ rc(read_dhall_file(&expected_file_path).unwrap());
+ typecheck::type_of(rc(ExprF::Annot(expr, expected)))
+ .unwrap();
+ })
+ .unwrap()
+ .join()
+ .unwrap();
}
TypeInferenceFailure => {
let file_path = base_path + ".dhall";
diff --git a/dhall/tests/typecheck.rs b/dhall/tests/typecheck.rs
index 56a8823..6e05a87 100644
--- a/dhall/tests/typecheck.rs
+++ b/dhall/tests/typecheck.rs
@@ -87,8 +87,8 @@ tc_success!(spec_typecheck_success_prelude_List_replicate_0, "prelude/List/repli
tc_success!(spec_typecheck_success_prelude_List_replicate_1, "prelude/List/replicate/1");
tc_success!(spec_typecheck_success_prelude_List_reverse_0, "prelude/List/reverse/0");
tc_success!(spec_typecheck_success_prelude_List_reverse_1, "prelude/List/reverse/1");
-// tc_success!(spec_typecheck_success_prelude_List_shifted_0, "prelude/List/shifted/0");
-// tc_success!(spec_typecheck_success_prelude_List_shifted_1, "prelude/List/shifted/1");
+tc_success!(spec_typecheck_success_prelude_List_shifted_0, "prelude/List/shifted/0");
+tc_success!(spec_typecheck_success_prelude_List_shifted_1, "prelude/List/shifted/1");
tc_success!(spec_typecheck_success_prelude_List_unzip_0, "prelude/List/unzip/0");
tc_success!(spec_typecheck_success_prelude_List_unzip_1, "prelude/List/unzip/1");
tc_success!(spec_typecheck_success_prelude_Monoid_00, "prelude/Monoid/00");
@@ -96,7 +96,7 @@ tc_success!(spec_typecheck_success_prelude_Monoid_01, "prelude/Monoid/01");
tc_success!(spec_typecheck_success_prelude_Monoid_02, "prelude/Monoid/02");
tc_success!(spec_typecheck_success_prelude_Monoid_03, "prelude/Monoid/03");
tc_success!(spec_typecheck_success_prelude_Monoid_04, "prelude/Monoid/04");
-// tc_success!(spec_typecheck_success_prelude_Monoid_05, "prelude/Monoid/05");
+tc_success!(spec_typecheck_success_prelude_Monoid_05, "prelude/Monoid/05");
tc_success!(spec_typecheck_success_prelude_Monoid_06, "prelude/Monoid/06");
tc_success!(spec_typecheck_success_prelude_Monoid_07, "prelude/Monoid/07");
tc_success!(spec_typecheck_success_prelude_Monoid_08, "prelude/Monoid/08");