Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move out-slice len adjustment from symbol_copy_to_slice to its caller.
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).
- Loading branch information