18005, "arezaii", "Using List and Map of user classes in a Record fails to compile ", "2021-06-29T22:01:09Z"
Summary of Problem
Using both Map
and List
in a record
, without specifying deallocation strategy keywords owned
or shared
for user classes, results in a compilation error.
Steps to Reproduce
Source Code:
use List;
use Map;
class A {
var msg:string;
}
class B {
var name:string;
}
record R {
var foo: list(A);
var bar: map(string, B);
}
Compile command:
chpl exampleCode.chpl
Output
exampleCode.chpl:13: In method 'foo':
exampleCode.chpl:13: internal error: invalid attempt to get reference type [AST/primitive.cpp:235]
Note
Curiously, the code above compiles if either map
or list
is omitted, but not when both are present in the record
. I would expect to see similar behavior to the above in either of these cases.
so changing the example code to either of the below examples will result in successful compilation:
record R {
var foo: A;
var bar: map(string, B);
}
OR
record R {
var foo: list(A);
var bar: B;
}
Alternatively, specifying a deallocation strategy for user classes A
and B
will successfully compile, e.g:
record R {
var foo: list(owned A);
var bar: map(string, shared B);
}
Configuration Information
- Output of
chpl --version
:chpl version 1.25.0 pre-release (75a0eeea87)
- 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: bundled
CHPL_HWLOC: bundled
CHPL_RE2: bundled
CHPL_LLVM: none *
CHPL_AUX_FILESYS: none
- Back-end compiler and version, e.g.
gcc --version
orclang --version
:
Apple clang version 12.0.5 (clang-1205.0.22.9)
Target: x86_64-apple-darwin20.5.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin