chapel-lang / chapel

a Productive Parallel Programming Language
https://chapel-lang.org
Other
1.8k stars 422 forks source link

Map of class problems when map.table not default initialized #15960

Open daviditen opened 4 years ago

daviditen commented 4 years ago

Presently, map.table is default initialized, but it is running into issue #15929. A suggested workaround was to instead declare it as:

  var table = new chpl__hashtable(keyType, valType);

However, after changing it to the above, some cases of maps of classes fail with internal compiler errors. Failures include building mason, and test/library/standard/Map/testBorrowedMap.chpl. I attempted to tease this error apart from map, but was unsuccessful.

The errors are along the lines of:

$CHPL_HOME/modules/standard/Map.chpl:74: internal error: invalid attempt to get reference type [AST/primitive.cpp:235]
mppf commented 4 years ago

From https://github.com/chapel-lang/chapel/issues/15929#issuecomment-650130825 - Here it looks like the problem is that the compiler is trying to resolve PRIM_ADDR_OF with a chpl__hashtable variable that has generic type

daviditen commented 4 years ago

I simplified a test case down to

use ChapelHashtable;

record mmap {
  type keyType;
  type valType;

  pragma "no doc"
  var table = new chpl__hashtable(keyType, valType);

  proc method() {
    for slot in table.allSlots() { }
  }
}

class C {
  var i: int;
}

var m: mmap(int, borrowed C);

m.method();