Make eval primitive object test pass
This commit is contained in:
parent
59956903f2
commit
856e74cb5e
@ -136,9 +136,9 @@ enum Primitive {
|
|||||||
impl Primitive {
|
impl Primitive {
|
||||||
fn to_repl(&self) -> String {
|
fn to_repl(&self) -> String {
|
||||||
match self {
|
match self {
|
||||||
Primitive::Object { type_id, items, .. } => {
|
Primitive::Object { type_id, items, .. } if items.len() == 0 => format!("{}", type_id.local_name()),
|
||||||
format!("{}{}", type_id.local_name(), paren_wrapped(items.iter().map(|item| item.to_repl())))
|
Primitive::Object { type_id, items, .. } =>
|
||||||
},
|
format!("{}{}", type_id.local_name(), paren_wrapped(items.iter().map(|item| item.to_repl()))),
|
||||||
Primitive::Literal(lit) => match lit {
|
Primitive::Literal(lit) => match lit {
|
||||||
Literal::Nat(n) => format!("{}", n),
|
Literal::Nat(n) => format!("{}", n),
|
||||||
Literal::Int(i) => format!("{}", i),
|
Literal::Int(i) => format!("{}", i),
|
||||||
@ -258,6 +258,9 @@ impl<'a> State<'a> {
|
|||||||
Primitive::unit()
|
Primitive::unit()
|
||||||
},
|
},
|
||||||
Expression::Call { box f, args } => self.call_expression(f, args)?,
|
Expression::Call { box f, args } => self.call_expression(f, args)?,
|
||||||
|
Expression::Callable(Callable::DataConstructor { type_id, arity, tag }) if arity == 0 => Primitive::Object {
|
||||||
|
type_id, tag, items: vec![]
|
||||||
|
},
|
||||||
Expression::Callable(func) => Primitive::Callable(func),
|
Expression::Callable(func) => Primitive::Callable(func),
|
||||||
Expression::ReductionError(e) => return Err(e.into()),
|
Expression::ReductionError(e) => return Err(e.into()),
|
||||||
})
|
})
|
||||||
|
@ -70,9 +70,9 @@ fn adt_output_1() {
|
|||||||
type Option<T> = Some(T) | None
|
type Option<T> = Some(T) | None
|
||||||
let a = Option::None
|
let a = Option::None
|
||||||
let b = Option::Some(10)
|
let b = Option::Some(10)
|
||||||
(a, b)
|
(b, a)
|
||||||
"#;
|
"#;
|
||||||
eval_assert(source, "(Option::None, Option::Some(10))");
|
eval_assert(source, "(Some(10), None)");
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
Loading…
Reference in New Issue
Block a user