File tree Expand file tree Collapse file tree 2 files changed +29
-3
lines changed
Expand file tree Collapse file tree 2 files changed +29
-3
lines changed Original file line number Diff line number Diff 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
Original file line number Diff line number Diff 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]
369393fn test_cant_subsume_merge ( ) {
370394 // Test that we can't subsume something with a merge function
You can’t perform that action at this time.
0 commit comments