[rlox] Add boolean literals

This commit is contained in:
ctsk
2023-10-08 20:44:11 +02:00
parent ef7c53a55c
commit 8ace98a215
3 changed files with 36 additions and 4 deletions

View File

@@ -77,6 +77,8 @@ impl VM {
Op::Return => print!("{:?}", self.pop()?),
Op::Constant { offset } => self.push(chunk.constants[offset]),
Op::Nil => self.push(Value::Nil),
Op::True => self.push(Value::Bool(true)),
Op::False => self.push(Value::Bool(false)),
Op::Negate => {
let new_val = -self.pop_num()?;
self.push(new_val.into());
@@ -143,7 +145,7 @@ mod tests {
}
#[test]
fn runtime_type_error() {
fn nil_error() {
let chunk = Chunk::new_with(
vec![Op::Nil, Op::Negate],
vec![],