deal with unknown types at the syntax phase

This commit is contained in:
2023-12-27 10:58:05 -08:00
parent 5936f5a0d9
commit 7101b62efb
4 changed files with 48 additions and 1 deletions

View File

@@ -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)),