New Issue: Compiler internal error while instantiating generic owned fields

20500, "riftEmber", "Compiler internal error while instantiating generic owned fields", "2022-08-24T18:14:23Z"

Summary of Problem

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)
  • Output of $CHPL_HOME/util/printchplenv --anonymize: CHPL_TARGET_PLATFORM: darwin
    CHPL_TARGET_COMPILER: clang
    CHPL_TARGET_ARCH: arm64
    CHPL_TARGET_CPU: native
    CHPL_LOCALE_MODEL: flat
    CHPL_COMM: none *
    CHPL_TASKS: fifo *
    CHPL_LAUNCHER: none
    CHPL_TIMERS: generic
    CHPL_UNWIND: none
    CHPL_MEM: cstdlib *
    CHPL_ATOMICS: cstdlib
    CHPL_GMP: none *
    CHPL_HWLOC: none
    CHPL_RE2: none *
    CHPL_LLVM: none *
    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: arm64-apple-darwin21.6.0
    Thread model: posix
    InstalledDir: /Library/Developer/CommandLineTools/usr/bin