New Issue: Copy initializer with compilerError() complains about fields not being initialized

16225, “bradcray”, “Copy initializer with compilerError() complains about fields not being initialized”, “2020-08-11T05:52:11Z”

Summary of Problem

As a Chapel programmer, I was hoping to create an error overload of a copy initializer to create a custom error message for users of my type, but because the type is generic, the compiler seems to complain that I haven’t initialized that field rather than simply generating the error message. while I can assign it a dummy value, it seems like it would be preferable not to have to.

Steps to Reproduce

Source Code:

proc R {
  type t;

  proc init=(other: int) {
    compilerError("Cannot initialize R from an int");
  }
}

var myR = 42;

Compile command:
chpl testit.chpl

Expected output:

Cannot initialize R from an int

Actual output:

testit.chpl:1: In function 'R':
testit.chpl:2: error: type alias 't' is not initialized

Configuration Information

  • Output of chpl --version: chpl version 1.23.0 pre-release (5308d008d4)