mirror of
https://github.com/zaphar/ucg.git
synced 2025-07-22 18:19:54 -04:00
CLEANUP: Don't use file everywhere in error messages.
This commit is contained in:
parent
163420ff55
commit
8d73b5f648
@ -59,12 +59,7 @@ impl Val {
|
||||
)
|
||||
}
|
||||
|
||||
pub fn equal(
|
||||
&self,
|
||||
target: &Self,
|
||||
file_name: &str,
|
||||
pos: Position,
|
||||
) -> Result<bool, error::BuildError> {
|
||||
pub fn equal(&self, target: &Self, pos: Position) -> Result<bool, error::BuildError> {
|
||||
// first we do a type equality comparison
|
||||
match (self, target) {
|
||||
// Empty values are always equal.
|
||||
@ -78,7 +73,7 @@ impl Val {
|
||||
Ok(false)
|
||||
} else {
|
||||
for (i, lv) in ldef.iter().enumerate() {
|
||||
try!(lv.equal(rdef[i].as_ref(), file_name, pos.clone()));
|
||||
try!(lv.equal(rdef[i].as_ref(), pos.clone()));
|
||||
}
|
||||
Ok(true)
|
||||
}
|
||||
@ -94,11 +89,7 @@ impl Val {
|
||||
return Ok(false);
|
||||
} else {
|
||||
// field value equality.
|
||||
if !try!(lv.1.equal(
|
||||
field_target.1.as_ref(),
|
||||
file_name,
|
||||
lv.0.pos.clone()
|
||||
)) {
|
||||
if !try!(lv.1.equal(field_target.1.as_ref(), lv.0.pos.clone())) {
|
||||
return Ok(false);
|
||||
}
|
||||
}
|
||||
@ -107,17 +98,17 @@ impl Val {
|
||||
}
|
||||
}
|
||||
(&Val::Macro(_), &Val::Macro(_)) => Err(error::BuildError::new(
|
||||
format!("Macros are not comparable in file: {}", file_name),
|
||||
"Macros are not comparable",
|
||||
error::ErrorType::TypeFail,
|
||||
pos,
|
||||
)),
|
||||
(&Val::Module(_), &Val::Module(_)) => Err(error::BuildError::new(
|
||||
format!("Module are not comparable in file: {}", file_name),
|
||||
"Module are not comparable",
|
||||
error::ErrorType::TypeFail,
|
||||
pos,
|
||||
)),
|
||||
(me, tgt) => Err(error::BuildError::new(
|
||||
format!("Types differ for {}, {} in file: {}", me, tgt, file_name),
|
||||
format!("Types differ for {}, {}", me, tgt),
|
||||
error::ErrorType::TypeFail,
|
||||
pos,
|
||||
)),
|
||||
|
@ -210,11 +210,7 @@ impl Builder {
|
||||
&Value::Symbol(ref s) => {
|
||||
self.lookup_sym(&(s.into()))
|
||||
.ok_or(Box::new(error::BuildError::new(
|
||||
format!(
|
||||
"Unable to find {} in file: {}",
|
||||
s.val,
|
||||
self.file.to_string_lossy()
|
||||
),
|
||||
format!("Unable to find binding {}", s.val,),
|
||||
error::ErrorType::NoSuchSymbol,
|
||||
v.pos().clone(),
|
||||
)))
|
||||
@ -375,9 +371,8 @@ impl Builder {
|
||||
format!(
|
||||
"Binding \
|
||||
for {:?} already \
|
||||
exists in file: {}",
|
||||
exists",
|
||||
e.key(),
|
||||
self.file.to_string_lossy(),
|
||||
),
|
||||
error::ErrorType::DuplicateBinding,
|
||||
def.name.pos.clone(),
|
||||
@ -480,10 +475,8 @@ impl Builder {
|
||||
format!(
|
||||
"Unable to \
|
||||
match element {} in selector \
|
||||
path [{}] in file: {}",
|
||||
next.1,
|
||||
sl,
|
||||
self.file.to_string_lossy(),
|
||||
path [{}]",
|
||||
next.1, sl,
|
||||
),
|
||||
error::ErrorType::NoSuchSymbol,
|
||||
next.0.clone(),
|
||||
@ -507,10 +500,8 @@ impl Builder {
|
||||
format!(
|
||||
"Unable to \
|
||||
match element {} in selector \
|
||||
path [{}] in file: {}",
|
||||
next.1,
|
||||
sl,
|
||||
self.file.to_string_lossy(),
|
||||
path [{}]",
|
||||
next.1, sl,
|
||||
),
|
||||
error::ErrorType::NoSuchSymbol,
|
||||
next.0.clone(),
|
||||
@ -720,11 +711,9 @@ impl Builder {
|
||||
left: Rc<Val>,
|
||||
right: Rc<Val>,
|
||||
) -> Result<Rc<Val>, Box<Error>> {
|
||||
Ok(Rc::new(Val::Boolean(try!(left.equal(
|
||||
right.as_ref(),
|
||||
&self.file.to_string_lossy(),
|
||||
pos.clone()
|
||||
)))))
|
||||
Ok(Rc::new(Val::Boolean(try!(
|
||||
left.equal(right.as_ref(), pos.clone())
|
||||
))))
|
||||
}
|
||||
|
||||
fn do_not_deep_equal(
|
||||
@ -733,11 +722,9 @@ impl Builder {
|
||||
left: Rc<Val>,
|
||||
right: Rc<Val>,
|
||||
) -> Result<Rc<Val>, Box<Error>> {
|
||||
Ok(Rc::new(Val::Boolean(!try!(left.equal(
|
||||
right.as_ref(),
|
||||
&self.file.to_string_lossy(),
|
||||
pos.clone()
|
||||
)))))
|
||||
Ok(Rc::new(Val::Boolean(!try!(
|
||||
left.equal(right.as_ref(), pos.clone())
|
||||
))))
|
||||
}
|
||||
|
||||
fn do_gt(&self, pos: &Position, left: Rc<Val>, right: Rc<Val>) -> Result<Rc<Val>, Box<Error>> {
|
||||
|
@ -140,7 +140,7 @@ fn test_eval_simple_lookup_error() {
|
||||
|
||||
// Include nested for each.
|
||||
#[test]
|
||||
#[should_panic(expected = "Unable to find tpl1")]
|
||||
#[should_panic(expected = "Unable to find binding tpl1")]
|
||||
fn test_expr_copy_no_such_tuple() {
|
||||
let cache = Rc::new(RefCell::new(MemoryCache::new()));
|
||||
let b = Builder::new(std::env::current_dir().unwrap(), cache);
|
||||
@ -221,7 +221,7 @@ fn test_expr_copy_field_type_error() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
#[should_panic(expected = "Unable to find arg1")]
|
||||
#[should_panic(expected = "Unable to find binding arg1")]
|
||||
fn test_macro_hermetic() {
|
||||
let cache = Rc::new(RefCell::new(MemoryCache::new()));
|
||||
let mut b = Builder::new(std::env::current_dir().unwrap(), cache);
|
||||
|
Loading…
x
Reference in New Issue
Block a user