You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Today, writing for _ in 1..10 will lead to a generic "syntax error". This is not an ideal error message, but seems like it ought to be easy enough to make it a nice error message. For instance, it would be nice to note that _ can only be used in declaration context like var _ = ... and loop tuple-expressions.
The text was updated successfully, but these errors were encountered:
Fixes#25000 (what a fun
issue number!).
This PR disallows writing `(_)`, to match the already-disallowed `_`.
Prior to this PR, the following program did not parse:
```Chapel
var x = _;
```
But the following alternate version did:
```Chapel
var x = (_);
```
This was because the parenthesized-expression grammar rule used
`tuple_component`, which allows `_` (`(_, )` can be used to unpack
1-tuples in loops). As a result, this fixes the odd issue in which
writing a loop over `(_)` resulted in an internal error, while `_`
resulted in a normal syntax error.
This raised some follow-up concerns:
1. should we have a nicer error message when a user writes `_` where it
doesn't belong? #25001
2. should we really allow `_` in all tuple expressions? currently we do.
#25002
In the meantime, this PR turns the error in #25000 from an internal
error into a syntax error.
Reviewed by @vasslitvinov -- thanks!
## Testing
- [x] paratest
Today, writing
for _ in 1..10
will lead to a generic "syntax error". This is not an ideal error message, but seems like it ought to be easy enough to make it a nice error message. For instance, it would be nice to note that_
can only be used in declaration context likevar _ = ...
and loop tuple-expressions.The text was updated successfully, but these errors were encountered: