chapel-lang / chapel

a Productive Parallel Programming Language
https://chapel-lang.org
Other
1.79k stars 420 forks source link

Comparisons with fully defaulted types don't work as expected #26132

Open bradcray opened 4 hours ago

bradcray commented 4 hours ago

I wrote code similar to the following:

record R {
  param flag = true;
}

proc foo(type t) {
  if t == R then
    writeln("Got an R");
  else
    writeln("It seems I didn't get an R, but rather a ", R:string);
}

foo(R);

expecting to get the "Got an R" case, since R is a fully-defaulted generic type and t is that same fully-defaulted type. However, it lands in the second case instead, printing:

It seems I didn't get an R, but rather a R

If I change the comparison to t == R(true) then it works as expected, but that doesn't seem like it should be necessary.

Interestingly, if I change the comparison to t == R(?) I don't get a complaint about comparisons against generic types not being supported, but also don't end up in the "then" clause (where I'd expect one of those two behaviors).

bradcray commented 4 hours ago

This is not actually related to #26114 but it was interesting that both showed up in the same week.