chapel-lang / chapel

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

Missing check for concrete memory management #14704

Open vasslitvinov opened 4 years ago

vasslitvinov commented 4 years ago

When creating a variable of a class/record type that has a field of a generic type, the compiler needs to check that the instantiated field's type has concrete nilability and memory management. Otherwise it does not make sense and the compiler crashes, for example:

class C {
  var x;
}

var c: unmanaged C(object?)?;

writeln(c!.x.type:string);
benharsh commented 1 month ago

At this time we print an error message rather than crashing, but the message itself isn't ideal:

bar.chpl:1: In module 'bar':
bar.chpl:5: warning: the 'object' abstract root class has been deprecated; please use 'RootClass' instead
bar.chpl:2: error: could not determine the concrete type for the generic return type 'anymanaged object?'

We'd rather the error message say something about C, rather than the somewhat confusing "return type" aspect.