fix(splat): stop char-spreading leftover primitive metas into info - #362
Open
abhu85 wants to merge 1 commit into
Open
fix(splat): stop char-spreading leftover primitive metas into info#362abhu85 wants to merge 1 commit into
abhu85 wants to merge 1 commit into
Conversation
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
format.splat()merges any splat arguments beyond the interpolation tokens intoinfoviaObject.assign. When a leftover argument is a primitive string,Object.assignspreads its characters into index-keyed properties.Fixes #109
Problem
After
%sconsumes'two', the leftover'three'is a string, andObject.assign(info, 'three')treats it like an object with enumerable index keys, pollutinginfowith{0:'t',1:'h',...}.Solution
In
Splatter._splat, only merge a leftover meta intoinfowhen it is a non-null object (typeof meta === 'object' && meta !== null). Object and array metas are unchanged; primitive leftovers are no longer char-spread.Test Plan
'one %s'+[SPLAT] = ['two','three']yieldsmessage === 'one two'with no0..4index properties oninfo.info[0] === 't'), passes after.170 passing, 0 failing. Lint: 0 errors.Compatibility
Object/array metas (the documented use case) behave exactly as before — covered by existing passing tests. Only the spurious character-index pollution from primitive leftovers is removed. The separate no-token code path is intentionally left untouched to avoid contradicting its existing test.