New Issue: misleading error message when initializing an array with the wrong type

20511, "jhh67", "misleading error message when initializing an array with the wrong type", "2022-08-25T16:44:56Z"

Summary of Problem

Compiling the code below results in the following error message:

assign.chpl:5: In initializer:
assign.chpl:6: error: cannot iterate over values of type int(64)

The error is that the array elements are a different type from the initial value, not that the initial value cannot be iterated over.


### Steps to Reproduce

**Source Code:**

```chapel
class Dummy {}

class Foo {
    var x: [0..1] unmanaged Dummy;
    proc init() {
        this.x = 42;
    }
}

var foo = new Foo();

Compile command:

chpl assign.chpl

Execution command:

./assign.chpl

Associated Future Test(s):

Configuration Information

  • Output of chpl --version:
chpl version 1.28.0 pre-release (b131550ff3)
Copyright 2020-2022 Hewlett Packard Enterprise Development LP
Copyright 2004-2019 Cray Inc.
(See LICENSE file for more details)
  • Output of $CHPL_HOME/util/printchplenv --anonymize:
CHPL_TARGET_PLATFORM: darwin
CHPL_TARGET_COMPILER: clang
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: none
CHPL_HWLOC: bundled
CHPL_RE2: bundled
CHPL_LLVM: unset
CHPL_AUX_FILESYS: none
  • Back-end compiler and version, e.g. gcc --version or clang --version:
Apple clang version 13.1.6 (clang-1316.0.21.2.5)
Target: x86_64-apple-darwin21.6.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
  • (For Cray systems only) Output of module list: