19570, "abhishekingit", "Compilation error "expected expression before" when trying to return generic domain from a class method", "2022-03-30T09:42:43Z"
Summary of Problem
I was trying to write an overriding class method that returns a generic domain, and I came across a generated code compilation error.
Steps to Reproduce
Source Code:
class AbstractParent {
// less generic fields
const rank: int;
proc init(rank: int) {
this.rank = rank;
}
proc getDomain(): domain {
halt("Pure virutal method");
}
}
class DerivedChild: AbstractParent {
param rank: int;
param stridable: bool;
var dom: domain(rank, stridable = stridable);
//generic fields
proc init(size: domain) {
super.init(size.rank);
this.rank = size.rank;
this.stridable = size.stridable;
this.dom = size;
}
override proc getDomain(): domain {
return this.dom;
}
}
var d1: domain(2) = {1..2, 1..3};
var dervChild1 = new shared DerivedChild(d1);
writeln(dervChild1.getDomain());
Compile command:
chpl test.chpl
Execution command:
./test
Configuration Information
- Output of
chpl --version
:chpl version 1.25.0 pre-release (67621f5dd5) built with LLVM version 11.0.1
- Output of
$CHPL_HOME/util/printchplenv --anonymize
:
CHPL_TARGET_PLATFORM: linux64
CHPL_TARGET_COMPILER: gnu
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: bundled +
CHPL_AUX_FILESYS: none
- Back-end compiler and version, e.g.
gcc --version
:gcc (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0