17472, "e-kayrakli", "Generic error type aliases cannot be used in 'catch' blocks", "2021-03-26T16:37:09Z"
Summary of Problem
When you alias an error type, you cannot use it in a catch block
Steps to Reproduce
Source Code:
class MyError: Error {
var msg: string;
proc init(msg:string) {
this.msg = msg;
}
override proc message() {
return this.msg;
}
}
// remove `owned` and what happens is:
// the type alias remains generic at the end of resolution, so it is removed,
// then at error handling time it causes memory corruption because
// `MyErrorAlias` has no defPoint. This is caught by `--verify` or
// AddressSanitizer
type MyErrorAlias = owned MyError;
try! {
writeln("hello");
}
catch e: MyErrorAlias {
writeln("Caught error");
}
Compile command:
chpl foo.chpl --verify
or compile on a build with CHPL_SANITIZE=address