Ran into this while writing an expression tree class for https://github.com/Cray/chapel-private/issues/3721.
Compiling the below code results in ExpressionTree.chpl:49: internal error: RES-FUN-ION-2618 chpl version 1.28.0 pre-release (dc228b96ba), or in dev mode ExpressionTree.chpl:49: internal error: assertion error [resolution/functionResolution.cpp:2618]. The Chapel source line referenced is the one where an AddExp is instantiated, and the compiler source line is the assertion NT_ASSERT(at->symbol->hasFlag(FLAG_GENERIC) == false);.
Steps to Reproduce
Source Code:
module ExpressionTree {
class Exp {
proc eval() : int {
halt("Expression subclasses must override eval");
}
}
class VarExp : Exp {
var value : int;
proc init(value : int) { this.value = value; }
override proc eval() : int { return value; }
}
class BinExp : Exp {
var leftChild : owned;
var rightChild : owned;
proc init(in left : owned Exp, in right : owned Exp) {
leftChild = left;
rightChild = right;
}
}
class AddExp : BinExp {
proc init(in left : owned Exp, in right : owned Exp) {
super.init(left, right);
}
override proc eval() : int { return leftChild.eval() + rightChild.eval(); }
}
proc main() {
var tree = new AddExp(new VarExp(2), new VarExp(3));
var result = tree.eval();
writeln("Evaluation result: ", result);
}
}
Compile command: chpl ExpressionTree.chpl
Execution command:
./ExpressionTree
Associated Future Test(s):
None
Configuration Information
Output of chpl --version: chpl version 1.28.0 pre-release (dc228b96ba)
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: arm64-apple-darwin21.6.0
Thread model: posix
InstalledDir: /Library/Developer/CommandLineTools/usr/bin