17085, “rchinmay”, “Recursive iterator produces internal error while printing it, or using break in for loop in its iteration.”, “2021-02-04T13:04:12Z”
Summary of Problem
Printing a recursive iterator’s yielded values using writeln()
produces internal error on compilation. But, if it were expanded with a for loop on its elements and then print its elements, it does not produce any error, and also executes as expected. But in such a loop, if we use a break condition inside the for loop, then it produces internal error. In the source code given below, if the for b in a(n-1) do {
is replaced by for b in 1..(n-1) by -1 do {
, then it works as expected. So, I assumed this problem was arising because of the recursive part in iterator. I don’t know any reasons for which such statements should not compile. I was expecting it to produce similar output as using 1..(n-1) by -1
in the place of a(n-1)
.
Steps to Reproduce
Source Code:
iter a(n):int {
yield n;
if n!=1 then {
for b in a(n-1) do { //replacing with for b in 1..(n-1) by -1 works
yield b;
}
}
}
writeln(a(10)); //Cauing internal error
for p in a(10) do {
write(p, ' ');
if p<5 then break; //Causing internal error
}
writeln();
Compile command:
chpl Chapel_Program.chpl
Output on compilation:
internal error: UTI-MIS-0788 chpl version 1.23.0
Internal errors indicate a bug in the Chapel compiler ("It's us, not you"),
and we're sorry for the hassle. We would appreciate your reporting this bug --
please see https://chapel-lang.org/bugs.html for instructions. In the meantime,
the filename + line number above may be useful in working around the issue.
Execution command:
If the writeln(a(10));
and if p<5 then break;
are commented or for b in a(n-1) do {
is replaced by for b in 1..(n-1) by -1 do {
, then using ./Chapel_Program
for execution works well.
Configuration Information
- Output of
chpl --version
:
chpl version 1.23.0
Copyright 2020 Hewlett Packard Enterprise Development LP
Copyright 2004-2019 Cray Inc.
(See LICENSE file for more details)
- Output of
$CHPL_HOME/util/printchplenv --anonymize
:
CHPL_TARGET_PLATFORM: linux64
CHPL_TARGET_COMPILER: gnu
CHPL_TARGET_ARCH: x86_64
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_REGEXP: none *
CHPL_LLVM: none *
CHPL_AUX_FILESYS: none
- Back-end compiler and version, e.g.
gcc --version
orclang --version
:
gcc (Ubuntu 9.3.0-17ubuntu1~20.04) 9.3.0
Copyright (C) 2019 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.