dyno: fix string -> bytes cast, disallow casts that are disallowed by production. #25164
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Reviewed by @benharsh -- thanks!
Testing