New Issue: Confusing error when introducing deliberate read before write error in managed unsafeAssigned block

19590, "stonea", "Confusing error when introducing deliberate read before write error in managed unsafeAssigned block", "2022-04-01T21:44:41Z"

Summary of Problem

I'm playing around with the new unsafeAssigned manager (very cool BTW!).

If I deliberately introduce a "read before write" in the managed block I'll get the error:

foo.chpl:10: error: halt reached - argument to ! is nil

Obviously what I'm doing shouldn't be allowed but I feel the error could be improved. It seems like it's revealing something about how things are working "under the hood" so to speak (within the managed block are you internally storing the new values in an array of nillable values?)

Anyway would it be difficult to detect this use case and present a better error, something like:

  can not read value A[2] in managed unsafeAssign block before it has been assigned

Steps to Reproduce

class C {
  var prop : int;
  proc init(x) { prop = x; }
}

var D = {0..0};
var A: [D] shared C = [new shared C(0)];

manage D.unsafeAssign({0..2}, checks=true) as mgr {
  mgr.initialize(A, 1, new shared C(A[2].prop));
  mgr.initialize(A, 2, new shared C(A[1].prop));
}
writeln(A)

Compile command:
chpl foo.chpl

Execution command:
./foo

Configuration Information

$ chpl --version
chpl version 1.27.0 pre-release (a4373b47a9)
  built with LLVM version 11.1.0
Copyright 2020-2022 Hewlett Packard Enterprise Development LP
Copyright 2004-2019 Cray Inc.
(See LICENSE file for more details)

$ $CHPL_HOME/util/printchplenv --anonymize
CHPL_TARGET_PLATFORM: darwin
CHPL_TARGET_COMPILER: llvm
CHPL_TARGET_ARCH: x86_64
CHPL_TARGET_CPU: native
CHPL_LOCALE_MODEL: flat
CHPL_COMM: none
CHPL_TASKS: qthreads
CHPL_LAUNCHER: none
CHPL_TIMERS: generic
CHPL_UNWIND: none
CHPL_MEM: jemalloc
CHPL_ATOMICS: cstdlib
CHPL_GMP: bundled
CHPL_HWLOC: bundled
CHPL_RE2: bundled
CHPL_LLVM: system
CHPL_AUX_FILESYS: none

$ clang --version
Apple clang version 12.0.0 (clang-1200.0.32.29)
Target: x86_64-apple-darwin20.6.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin