Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better error for tuple variable declarations with non-tuple type expression #26873

Open
benharsh opened this issue Mar 7, 2025 · 0 comments
Open

Comments

@benharsh
Copy link
Member

benharsh commented Mar 7, 2025

Consider the following program:

proc main() {
  var a = (1, 2, 3);
  var (x,y,z): int = a;
}

This gives the error:

baz.chpl:1: In function 'main':
baz.chpl:3: error: illegal tuple variable declaration with non-tuple initializer

Personally, I find this error message to be rather unhelpful as it suggests something about the initialization expression is wrong, rather than the type expression. I initially wrote this with multi-decl rules in mind, and thought I was specifying the element type of each tuple component. So when I first saw this error, I thought it might be a compiler bug with normalization or something rather than doing the wrong thing myself.

Changing int to 3*int gets things working, and it would be nice if the error message could suggest something along these lines.

@benharsh benharsh changed the title Better error for tuple variable declarations interact with non-tuple type expression Better error for tuple variable declarations with non-tuple type expression Mar 7, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant