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