FIX: More error reporting improvements.

This commit is contained in:
Jeremy Wall 2019-02-03 20:56:21 -06:00
parent efef2bc3d2
commit 276c155264
2 changed files with 24 additions and 1 deletions

View File

@ -396,3 +396,25 @@ fn test_incomplete_tuple_key_value_missing_value_compile_failure() {
],
)
}
#[test]
fn test_format_expr_missing_expr_compile_error() {
assert_build_failure(
"\"foo\" %",
vec![
Regex::new(r"Expected format arguments").unwrap(),
Regex::new(r"at <eval> line: 1, column: 8").unwrap(),
],
)
}
#[test]
fn test_format_expr_unclosed_parens_compile_failure() {
assert_build_failure(
"\"foo\" % (1",
vec![
Regex::new(r"Expected \(\)\) but got \(\)").unwrap(),
Regex::new(r"at <eval> line: 1, column: 9").unwrap(),
],
)
}

View File

@ -503,7 +503,8 @@ make_fn!(
do_each!(
tmpl => match_type!(STR),
_ => punct!("%"),
args => either!(simple_format_args, expression_format_args),
args => wrap_err!(must!(either!(simple_format_args, expression_format_args)),
"Expected format arguments"),
(Expression::Format(FormatDef {
template: tmpl.fragment.to_string(),
args: args,