chapel-lang / chapel

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

[Bug]: BUI-0906 internal build error on single variable discard in for-loop #25000

Closed etscheelk closed 6 months ago

etscheelk commented 6 months ago

Summary of Problem

Description:

Attempted to discard single loop variable like (_) results in build error BUI-0906. Expected it to behave like how you can discard a variable in a tuple iterators, e.g. (x, _) in ...

repeat.chpl:15: internal error: BUI-0906 chpl version 2.0.0
Note: This source location is a guess.

Internal errors indicate a bug in the Chapel compiler,
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.

Is this a blocking issue with no known work-arounds?

Yes (besides not trying to discard variable)

Steps to Reproduce

Source Code:

for (_) in 1..4 {}

Compile command:

chpl rp.chpl

Execution command:

N/A

Associated Future Test(s):

No.

Configuration Information

bradcray commented 6 months ago

@etscheelk : Thanks very much for filing this, as it definitely should not be giving you an internal error as it is!

The way we currently write this pattern in Chapel is to drop any mention of an index variable at all, using for 1..4 {}.

There was recently a brief discussion about whether Chapel should permit for _ in 1..4 {} in https://github.com/chapel-lang/chapel/issues/24149. If you'd be a proponent of supporting that, that'd be interesting to know, and potentially worth opening a feature request issue for (depending on how strongly you feel about it).

DanilaFe commented 6 months ago

I will take a look at why this is an internal error.

DanilaFe commented 6 months ago

I've opened https://github.com/chapel-lang/chapel/pull/25003 to fix this issue. Like Brad said, for _ is not valid in Chapel (https://github.com/chapel-lang/chapel/issues/24149 notwithstanding), so a syntax error is emitted.

etscheelk commented 6 months ago

If you'd be a proponent of supporting that, that'd be interesting to know

I think this would provide some parity between the methods of ignoring the iterating variable. While for 1..10 is nifty, if I know about the tuple component dropping, that's where my mind goes first. I believe rust allows dropping variables like this too.

At any rate, glad to get it converted to a syntax issue for the immediate future.