New Issue: Overloading paren-less vs. paren-ful routines should result in an ambiguity error

18177, "bradcray", "Overloading paren-less vs. paren-ful routines should result in an ambiguity error", "2021-08-07T00:31:55Z"

Summary of Problem

For years, I've been mistakenly thinking and saying that Chapel would give an ambiguity error when a program contains overloads of a routine with and without parenthesis since, in cases like the following, there's no clear answer as to which routine should be called:

proc foo {
  return [1.0, 2.0];
}

proc foo(x: int) {
  return x+1;
}

writeln(foo(1));

However, in Chapel 1.24.1 and a few other versions I've checked back to Chapel 1.10.0, I'm finding that instead it just arbitrarily picks one of them (seemingly whichever overload is defined second?). This seems problematic to me since it can represent confusion on the part of a user and is somewhat similar to overloading a variable and a procedure or a field and a method.

It can also come up in more subtle cases like class hierarchies:

class C {
  proc foo {
    writeln("In C.foo");
  }
}

class D: C {
  proc foo(x: int) {
    writeln("In D.foo");
  }
}

var D = new D();
D.foo(1);

where it seems we pick the parent class method.

Configuration Information

  • Output of chpl --version: chpl version 1.25.0 pre-release (2bf652fc09)