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

dyno: fix string -> bytes cast, disallow casts that are disallowed by production. #25164

Merged
merged 5 commits into from
Jun 5, 2024

Conversation

DanilaFe
Copy link
Contributor

@DanilaFe DanilaFe commented Jun 4, 2024

Closes #25154.

It turns out there's a case missing for casting from {strings, bytes} to {strings, bytes}. Strictly speaking, only string -> string and string -> bytes casts are allowed, but all of them would be implemented the same way (by just copying the string data). This is how the production compiler does it.

To match production's "invalid cast" errors, this PR adds some logic that matches that of preFold.cpp, which just checks the from- and to- types of the cast, and doesn't attempt casting if the pair is not allowed.

Of course, the PR also adds tests on top of that.

This fixes the hover-on-string bug, too.

Screen Shot 2024-06-03 at 8 57 58 PM

Reviewed by @benharsh -- thanks!

Testing

  • paratest

This is how it's done in production, too.

Signed-off-by: Danila Fedorin <daniel.fedorin@hpe.com>
Signed-off-by: Danila Fedorin <daniel.fedorin@hpe.com>
Signed-off-by: Danila Fedorin <daniel.fedorin@hpe.com>
Signed-off-by: Danila Fedorin <daniel.fedorin@hpe.com>
Signed-off-by: Danila Fedorin <daniel.fedorin@hpe.com>
@DanilaFe DanilaFe changed the title dyno: dix string -> bytes cast, disallow casts that are disallowed by production. dyno: fix string -> bytes cast, disallow casts that are disallowed by production. Jun 4, 2024
@benharsh benharsh self-requested a review June 4, 2024 16:17
Copy link
Member

@benharsh benharsh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good to me, though I somewhat wonder about the logic in cast_code.cpp getting out of sync with paramCastAllowed. Do you think it would be viable to add an 'invalid' field to Immediate that we could set in such cases, and check that instead?

@DanilaFe
Copy link
Contributor Author

DanilaFe commented Jun 4, 2024

I've opened a follow-up issue (https://github.com/Cray/chapel-private/issues/6373) to track this.

@DanilaFe DanilaFe merged commit 7fb1585 into chapel-lang:main Jun 5, 2024
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Dyno asserts when casting a param string to bytes
2 participants