Regression test for typechecking invalid syntax
@@ -395,6 +395,18 @@ mod tests {
p.eval_full()
}
+ fn typecheck(s: &str) -> Result<(), Error> {
+ let src = Cursor::new(s);
+
+ let mut p = Program::new_from_source(src, "<test>").map_err(|io_err| {
+ Error::EvalError(EvalError::Other(
+ format!("IO error: {}", io_err),
+ TermPos::None,
+ ))
+ })?;
+ p.typecheck()
+ }
+
#[test]
fn evaluation_full() {
use crate::mk_record;
@@ -438,4 +450,14 @@ mod tests {
// that this test fails.
eval_full("{y = fun x => x, x = fun y => y}").unwrap();
}
+
+ #[test]
+ // Regression test for issue 715 (https://github.com/tweag/nickel/issues/715)
+ // Check that program::typecheck() fail on parse error
+ fn typecheck_invalid_input() {
+ assert_matches!(
+ typecheck("{foo = 1 + `, bar : Str = \"a\"}"),
+ Err(Error::ParseErrors(_))
+ );
+ }
}
