External Issue: Similar ordered sets with different comparators

18656, "rj-jesus", "Similar ordered sets with different comparators", "2021-10-29T12:00:02Z"

I might be doing something wrong, but it seems I can't have two similar ordered sets using different comparators. For example, consider the following code:

use OrderedSet;

enum E { A = 0, B, C, D, };

record R1 { proc key(a) return  a:int; };
record R2 { proc key(a) return -a:int; };

const comp1: R1, comp2: R2;

var v1 = new orderedSet(E, false, comp1);
var v2 = new orderedSet(E, false, comp2);

for l in E {
  v1.add(l);
  v2.add(l);
}

writeln(v1);  // [ A B C D ]
writeln(v2);  // [ D C B A ]

I'd expect it to produce the two sets I've indicated in the comments. However, it doesn't compile:

$CHPL_HOME/modules/packages/OrderedSet.chpl:64: In initializer:
$CHPL_HOME/modules/packages/OrderedSet.chpl:69: error: Cannot replace an instantiated field with another type
$CHPL_HOME/modules/packages/OrderedSet.chpl:69: note: field 'instance' has type 'treap(E,false,R1,unmanaged _treapNode(E)?)' but is set to 'treap(E,false,R2,unmanaged _treapNode(E)?)'
  zzz.chpl:164: called as orderedSet.init(type eltType = E, param parSafe = false, comparator: R2)
note: generic instantiations are underlined in the above callstack

Indeed, the code works fine iff only one of v1 and v2 exists.