New Issue: Cast operator methods get confusing error about number of formals

17325, "bradcray", "Cast operator methods get confusing error about number of formals", "2021-03-03T16:58:15Z"

Summary of Problem

Attempting to make use of the new cast operator support in combination with the new operator method capability, I wrote the following program:

record R {
  var x: sync int;

  proc init=(x: int) {
    this.x = x;

  operator :(x: int, type t: R) {
    return new R(x);

var myR: R = 3;
var myR2 = myR;

which generates the following error message:

testit.chpl:8: error: cast function should have two formals

which is confusing since it does have two formals. Moving the cast operator to a standalone operator (rather than a method) solves the problem, but prevents the cast from being associated with a type.

Steps to Reproduce

Associated Future Test(s):


Configuration Information

  • Output of chpl --version: chpl version 1.24.0 pre-release (ce03a6ea8a)