Skip to content

Commit

Permalink
Force enum payloads (#1890)
Browse files Browse the repository at this point in the history
* Force enum payloads

* Add tests
  • Loading branch information
jneem authored Apr 15, 2024
1 parent b731a43 commit 0534393
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
7 changes: 7 additions & 0 deletions core/src/eval/operation.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1121,6 +1121,13 @@ impl<R: ImportResolver, C: Cache> VirtualMachine<R, C> {
// For an enum variant, `force x` is simply equivalent to `deep_seq x x`, as
// there's no lazy pending contract to apply.
Term::EnumVariant { tag, arg, attrs } => {
let arg = mk_term::op1(
UnaryOp::Force {
ignore_not_exported,
},
arg,
)
.closurize(&mut self.cache, env.clone());
let cont = RichTerm::new(
Term::EnumVariant {
tag,
Expand Down
7 changes: 7 additions & 0 deletions core/tests/integration/inputs/adts/deep_seq_enum2.ncl
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# test.type = 'error'
#
# [test.metadata]
# error = 'EvalError::NAryPrimopTypeError'

# Check that deep_seq correctly deeply evaluates the content of an enum variant
%deep_seq% ('Foo { bar = 5 + "a" }) null
7 changes: 7 additions & 0 deletions core/tests/integration/inputs/adts/force_enum2.ncl
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
# test.type = 'error'
#
# [test.metadata]
# error = 'EvalError::NAryPrimopTypeError'

# Check that force correctly deeply evaluates the content of an enum variant
%force% ('Foo { bar = 5 + "a" })

0 comments on commit 0534393

Please sign in to comment.