New Issue: Using 'manage' incorrectly needs better errors

24721, "jabraham17", "Using 'manage' incorrectly needs better errors", "2024-03-29T19:07:35Z"

I found 3 different bugs with the manage statement, all related to the misuse of it

  1. Using a non-aggregate type in a manage statement causes an internal error
var a = 1;
manage a {}
$CHPL_HOME/modules/internal/ChapelContext.chpl:37: internal error: seg fault [util/misc.cpp:1041]
Note: This source location is a guess.

future: test/statements/manage/manageNonAggregate.chpl

  1. Using a type as the management object does not default construct the object
record myManager: contextManager {
  var x: int = 0;

  proc ref enterContext() ref: int {
    writeln('x is: ', x);
    return x;
  }

  proc exitContext(in err: owned Error?) {
    if err then halt(err!.message());
    writeln('x is: ', x);
  }
}
manage myManager() as x {
  x = 1;
}

No errors are printed when compiling this, but there are some warnings about unnecessary type construction call

'x' is printed as some garbage value

x is: 86540388
x is: 1

future: test/statements/manage/missingNew.chpl

  1. When compiling case 2 a warning is thrown about unnecessary type construction call, which suggests removing (). Following that suggestion results in an internal error
record myManager: contextManager {
  var x: int = 0;

  proc ref enterContext() ref: int {
    writeln('x is: ', x);
    return x;
  }

  proc exitContext(in err: owned Error?) {
    if err then halt(err!.message());
    writeln('x is: ', x);
  }
}
manage myManager as x {
  x = 1;
}
missingNew.chpl:14: internal error: misuse of codegenAddrOf [codegen/cg-expr.cpp:1674]
Note: This source location is a guess.

future: test/statements/manage/missingNewNoParen.chpl

All three of these cases should have better error messages