deal with unknown types at the syntax phase
This commit is contained in:
@@ -45,6 +45,11 @@ impl Program {
|
||||
let value = env
|
||||
.get(&name.clone().intern())
|
||||
.ok_or_else(|| EvalError::LookupFailed(loc.clone(), name.name.clone()))?;
|
||||
let value = if let Value::Number(x) = value {
|
||||
Value::U64(*x)
|
||||
} else {
|
||||
value.clone()
|
||||
};
|
||||
let line = format!("{} = {}\n", name, value);
|
||||
stdout.push_str(&line);
|
||||
last_result = Value::Void;
|
||||
@@ -64,7 +69,7 @@ impl Expression {
|
||||
match self {
|
||||
Expression::Value(_, v) => match v {
|
||||
super::Value::Number(_, ty, v) => match ty {
|
||||
None => Ok(Value::U64(*v)),
|
||||
None => Ok(Value::Number(*v)),
|
||||
// FIXME: make these types validate their input size
|
||||
Some(ConstantType::Void) => Ok(Value::Void),
|
||||
Some(ConstantType::I8) => Ok(Value::I8(*v as i8)),
|
||||
|
||||
Reference in New Issue
Block a user