Move out-slice len adjustment from symbol_copy_to_slice to its caller. #1063
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.
In general this is not a correct adjustment to make in symbol_copy_to_slice because that function takes an arbitrary input pos in the symbol it's copying from (like all the buffer-copy host functions). It is correct only in the case where pos == 0 and even then it represents a bit of a footgun by papering over real errors in the caller (passing too long a slice, which the caller might incorrectly assume is entirely filled by the call if the call silently succeeded).
This adjustment was added in 0bc4029 presumably in order to "make tests pass". Removing it does break tests but only because of one call path that uses this host function, where a host SymbolObject is converted to a fixed-length guest SymbolStr. This is a caller in which a zero pos is already being passed and the adjustment is appropriate, so in this commit we change that call site to do the adjustment itself (which causes all tests to pass again).