Skip to content

Commit 3ad8d7d

Browse files
committed
feedback
1 parent 971fb22 commit 3ad8d7d

File tree

2 files changed

+29
-3
lines changed

2 files changed

+29
-3
lines changed

src/actions.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,9 @@ impl EGraph {
392392
function.remove(args, self.timestamp);
393393
}
394394
Change::Subsume => {
395-
if function.decl.subtype != FunctionSubtype::Constructor {
395+
if function.decl.subtype != FunctionSubtype::Constructor
396+
&& function.decl.subtype != FunctionSubtype::Relation
397+
{
396398
return Err(Error::SubsumeMergeError(*f));
397399
}
398400
function

tests/integration_test.rs

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -350,8 +350,9 @@ fn test_subsume() {
350350
}
351351

352352
#[test]
353-
fn test_subsume_primitive() {
354-
// Test that we can subsume a primitive
353+
fn test_subsume_custom() {
354+
// Test that we can't subsume a custom function
355+
// Only relations and constructors are allowed to be subsumed
355356

356357
let mut egraph = EGraph::default();
357358
let res = egraph.parse_and_run_program(
@@ -365,6 +366,29 @@ fn test_subsume_primitive() {
365366
assert!(res.is_err());
366367
}
367368

369+
#[test]
370+
fn test_subsume_ok() {
371+
let mut egraph = EGraph::default();
372+
let res = egraph.parse_and_run_program(
373+
None,
374+
r#"
375+
(sort E)
376+
(constructor one () E)
377+
(constructor two () E)
378+
(one)
379+
(subsume (one))
380+
;; subsuming a non-existent tuple
381+
(subsume (two))
382+
383+
(relation R (i64))
384+
(R 1)
385+
(subsume (R 1))
386+
(subsume (R 2))
387+
"#,
388+
);
389+
assert!(res.is_ok());
390+
}
391+
368392
#[test]
369393
fn test_cant_subsume_merge() {
370394
// Test that we can't subsume something with a merge function

0 commit comments

Comments
 (0)