mirror of
https://github.com/zaphar/ucg.git
synced 2025-07-23 18:29:50 -04:00
FIX: Better error reporting for copy calls
This commit is contained in:
parent
c3025c710e
commit
a1bc81ee89
@ -507,3 +507,25 @@ fn test_let_missing_semicolon_compile_failure() {
|
|||||||
],
|
],
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_copy_expression_not_a_tuple_compile_failure() {
|
||||||
|
assert_build_failure(
|
||||||
|
"let foo = 1;\nfoo{};",
|
||||||
|
vec![
|
||||||
|
Regex::new(r"Expected Tuple or Module but got \(1\)").unwrap(),
|
||||||
|
Regex::new(r"at <eval> line: 2, column: 1").unwrap(),
|
||||||
|
],
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_copy_expression_wrong_field_type_compile_failure() {
|
||||||
|
assert_build_failure(
|
||||||
|
"let foo = {bar=1};\nfoo{bar=[]};",
|
||||||
|
vec![
|
||||||
|
Regex::new(r"Expected type Integer for field bar but got \(List\)").unwrap(),
|
||||||
|
Regex::new(r"at <eval> line: 2, column: 5").unwrap(),
|
||||||
|
],
|
||||||
|
)
|
||||||
|
}
|
||||||
|
@ -1042,7 +1042,7 @@ impl<'a> FileBuilder<'a> {
|
|||||||
} else {
|
} else {
|
||||||
return Err(Box::new(error::BuildError::new(
|
return Err(Box::new(error::BuildError::new(
|
||||||
format!(
|
format!(
|
||||||
"Expected type {} for field {} but got {}",
|
"Expected type {} for field {} but got ({})",
|
||||||
src_val.1.type_name(),
|
src_val.1.type_name(),
|
||||||
key.fragment,
|
key.fragment,
|
||||||
expr_result.type_name()
|
expr_result.type_name()
|
||||||
@ -1130,7 +1130,7 @@ impl<'a> FileBuilder<'a> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
Err(Box::new(error::BuildError::new(
|
Err(Box::new(error::BuildError::new(
|
||||||
format!("Expected Tuple or Module got {}", v),
|
format!("Expected Tuple or Module but got ({})", v),
|
||||||
error::ErrorType::TypeFail,
|
error::ErrorType::TypeFail,
|
||||||
def.selector.pos().clone(),
|
def.selector.pos().clone(),
|
||||||
)))
|
)))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user