From 0e6d3d961bc24eed58cd4ec8b060bdfe8fc1b7d8 Mon Sep 17 00:00:00 2001 From: Joe Neeman Date: Fri, 12 Apr 2024 14:10:18 -0500 Subject: [PATCH 1/2] Force enum payloads --- core/src/eval/operation.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/core/src/eval/operation.rs b/core/src/eval/operation.rs index 469fb2550d..fa88a69ed2 100644 --- a/core/src/eval/operation.rs +++ b/core/src/eval/operation.rs @@ -1121,6 +1121,13 @@ impl VirtualMachine { // 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, From 0dcda141747c4c24f34c1378494830487362dc2d Mon Sep 17 00:00:00 2001 From: Joe Neeman Date: Fri, 12 Apr 2024 14:23:58 -0500 Subject: [PATCH 2/2] Add tests --- core/tests/integration/inputs/adts/deep_seq_enum2.ncl | 7 +++++++ core/tests/integration/inputs/adts/force_enum2.ncl | 7 +++++++ 2 files changed, 14 insertions(+) create mode 100644 core/tests/integration/inputs/adts/deep_seq_enum2.ncl create mode 100644 core/tests/integration/inputs/adts/force_enum2.ncl diff --git a/core/tests/integration/inputs/adts/deep_seq_enum2.ncl b/core/tests/integration/inputs/adts/deep_seq_enum2.ncl new file mode 100644 index 0000000000..e21674055f --- /dev/null +++ b/core/tests/integration/inputs/adts/deep_seq_enum2.ncl @@ -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 diff --git a/core/tests/integration/inputs/adts/force_enum2.ncl b/core/tests/integration/inputs/adts/force_enum2.ncl new file mode 100644 index 0000000000..ee7be7ab2a --- /dev/null +++ b/core/tests/integration/inputs/adts/force_enum2.ncl @@ -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" })