New Issue: Confusing error message when casting to generic Class

20502, "jeremiah-corrado", "Confusing error message when casting to generic Class", "2022-08-24T19:49:11Z"

The following program does not compile because Child is a generic class (foo can have any type), therefore a cast to Child is illegal:

class Parent { }
class Child: Parent { var foo; }

var cp : Parent = new Child("hello");
var cc = cp:Child?;

This can be solved by adding a type specifier to the cast itself (i.e. :Child(string)?), or by constraining foo's type in the Class definition.

However, the compiler currently produces the following error message:

downcasting.chpl:5: error: illegal cast to non-type

This could be very confusing for users, especially those who are not yet familiar with generic types in Chapel. I would propose that the error message for this case is modified to be something like:

error: illegal cast to unconstrained-type. The class 'Child' has generic fields; please provide type specifiers.