mirror of
https://github.com/zaphar/ucg.git
synced 2025-07-22 18:19:54 -04:00
DEV: Better error messages on cast failures.
This commit is contained in:
parent
cca249de2b
commit
7b28fd9d6c
@ -221,9 +221,8 @@ where
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn op_cast(&mut self, t: CastType) -> Result<(), Error> {
|
||||
let (val, pos) = self.pop()?;
|
||||
if let Value::P(ref p) = val.as_ref() {
|
||||
fn do_cast(&mut self, t: CastType, val: &Value, pos: Position) -> Result<(), Error> {
|
||||
if let Value::P(ref p) = val {
|
||||
self.push(
|
||||
Rc::new(match t {
|
||||
CastType::Str => Value::P(Primitive::Str(format!("{}", p))),
|
||||
@ -236,6 +235,10 @@ where
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
fn op_cast(&mut self, t: CastType) -> Result<(), Error> {
|
||||
let (val, pos) = self.pop()?;
|
||||
decorate_error!(pos => self.do_cast(t, &val, pos.clone()))
|
||||
}
|
||||
|
||||
fn op_typ(&mut self) -> Result<(), Error> {
|
||||
let (val, pos) = self.pop()?;
|
||||
|
Loading…
x
Reference in New Issue
Block a user