forked from chapel-lang/chapel
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Dyno: fix decls with tuple type expressions and initialization expres…
…sions (chapel-lang#25951) Closes Cray/chapel-private#6385; prior to this PR, the following program: ```Chapel var x: 2*int = (7,3); ``` Produced an error: ``` ─── error in onetuple.chpl:1 [IncompatibleTypeAndInit] ─── Type mismatch between declared type of 'x' and initialization expression. In the following declaration: | 1 | var x: 2*int = (7,3); | ⎺⎺⎺⎺⎺ ⎺⎺⎺⎺⎺ | the type specifier has type '(int(64), int(64))', while the initial value has type '(int(64), int(64))'. ``` The (chapel syntax) output is quite confusing in the error message, but the difference between the specified type and the actual type are the intents of the components. On the left hand site we have a 'type' tuple, but on the right we have a value tuple. There is already logic on `main` to adjust the type of the declaration _at the end_ to mark the tuple components 'var' or 'ref', etc. However, the type-value mismatch happens while the type of the declaration is being inferred, before the final adjustment. The solution seems to be to adjust the type of the tuple's components using the same rules as "usual" (described, I believe, in the [specification here](https://chapel-lang.org/docs/language/spec/tuples.html#tuple-argument-intents)). So, this PR extracts the "adjustment" process, runs it once on the type expression to ensure it's compatible with the value, then again on the final type. Reviewed by @benharsh -- thanks! ## Testing - [x] dyno tests
- Loading branch information
Showing
2 changed files
with
77 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters