chapel-lang / chapel

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

Internal compiler error when using `owned aRecord` as a type actual. #20505

Open DanilaFe opened 2 years ago

DanilaFe commented 2 years ago

Summary of Problem

I get an internal compiler error in the following code:

record r{}
record s { type t; }
var x: s(owned r);

It originally came up when I was trying to make a list of owned records, but seems like use in any type actual will do. The error without developer mode is on line 3 (invalid code, by the way, since records cannot be owned). In debug mode, the compiler reports the following:

$CHPL_HOME/modules/internal/OwnedObject.chpl:433: internal error: assertion error [AST/DecoratedClassType.cpp:246]
Note: This source location is a guess.

Steps to Reproduce

Compile command: chpl minimal-owned-record.chpl

Configuration Information

lydia-duncan commented 2 years ago

This seems like it has the potential to be an easy fix, but I'd be worried about having a wandering developer try to handle it if we marked it as easy.

bradcray commented 2 years ago

I agree with Lydia. It shouldn't be hard for us to catch when the class management flavors are applied to non-classes. In fact, it makes me curious what would happen if that assertion were turned into a conditional that simply said something like USR_FATAL("Can't apply class management types to non-classes"); and was run through parallel testing. I can give it a shot if nobody else is already trying something similar (or wants to).

(This seemed familiar, and I think it's because of the following PR which is thematically related, but also different: https://github.com/chapel-lang/chapel/pull/18757)