chapel-lang / chapel

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

Internal compiler error in memory management generic iterator method #20504

Closed DanilaFe closed 1 year ago

DanilaFe commented 2 years ago

Summary of Problem

I get an internal compiler error when compiling the following code:

class Expr {
  iter nodes(): Expr {}
}

var node: owned Expr = new Expr();

for childNode in node.nodes() {}

I believe that the code technically is not valid (childNode is generic, and I don't think that's allowed?), but a compiler error is not the right way to go. In developer mode, the error is reported as follows:

minimal-explosion.chpl:2: internal error: every return type must also have a ref type. [AST/checkAST.cpp:331]

The regular error message points to line 2 as the source of the issue.

Steps to Reproduce

Compile command: chpl minimal-explosion.chpl

bradcray commented 2 years ago

Just to make sure I'm understanding the salient features here, I'm guessing that this works if:

Anyway, I agree that an internal error is always a bug, so am not trying to brush this aside... just trying to understand how likely it is to come up in practice. Thanks!

DanilaFe commented 1 year ago

At the time of writing (bc583a2afd059782bd0f8cae55f06dec08ca3f7a) this no longer causes an internal error. Closing.