-
Notifications
You must be signed in to change notification settings - Fork 425
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Using List and Map of user classes in a Record fails to compile #18005
Comments
I think this is a case where the program shouldn't compile but we need a better error message. With this version, I see the same (unhelpful) error message with both foo and bar fields or either one commented out. 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);
}
var x = new R();
writeln(x); The problem here is that It might be possible or reasonable to make list/map issue an error if the element type is generic. However this might go against some partial instantiation scenarios (maybe I want to say |
today this provides a much nicer, helpful error message that helped me change the code to compile, so I will close this as it seems addressed. |
@arezaii : Would you consider filing a test locking this behavior in (if there isn't obviously one already)? |
I found the test |
Adds a test for partial instantiation of a generic to serve as a regression test against #18005. TESTING: - [x] paratest `[Summary: #Successes = 17375 | #Failures = 0 | #Futures = 921]` - [x] paratest gasnet `[Summary: #Successes = 17556 | #Failures = 0 | #Futures = 927]` [reviewed by @DanilaFe - thanks!]
Summary of Problem
Using both
Map
andList
in arecord
, without specifying deallocation strategy keywordsowned
orshared
for user classes, results in a compilation error.Steps to Reproduce
Source Code:
Compile command:
chpl exampleCode.chpl
Output
Note
Curiously, the code above compiles if either
map
orlist
is omitted, but not when both are present in therecord
. 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:
OR
Alternatively, specifying a deallocation strategy for user classes
A
andB
will successfully compile, e.g:Configuration Information
chpl --version
:chpl version 1.25.0 pre-release (75a0eeea87)
$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
gcc --version
orclang --version
:The text was updated successfully, but these errors were encountered: