Repository navigation
parser: pass an array argument as the parameter array - #20
Merged
Merged
Conversation
When the '+' operator merged the operands of a nested string.Concat
call, it took the only argument of the call for the array created for
the expanded form. Another overload with one argument failed with
InvalidCastException: for example, 'string.Concat("x") + "y"' calls
Concat(object).
Merge only the elements of an array created for the expanded form, and
keep other single-argument calls as one operand.
The arguments for a params parameter were always wrapped in a new
array, even when the call was resolved in its normal form with an
array passed directly. As a result, 'string.Join(",", words)' with a
string[] failed with "No coercion operator is defined between types
'System.String[]' and 'System.String'", and a string[] passed to
'params object[]' became the only element of a new array.
Pass the only argument for the parameter array as the array itself
when it converts to the array type, as C# does. In other cases the
arguments are still wrapped in an array.
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.
A call with a
paramsparameter always wrapped its arguments in a new array, even when the method resolver had selected the normal form because an array was passed directly. As a result,string.Join(",", words)with astring[]failed withNo coercion operator is defined between types 'System.String[]' and 'System.String', and astring[]passed toparams object[]became the only element of a new array.This PR passes the only argument for the parameter array as the array itself when it converts to the array type, as C# does. An
int[]passed toparams object[]still becomes a single element, as in C#.The
+operator merged the operands of a nestedstring.Concatcall and took its only argument for an array created for the expanded form. It now merges only such arrays and keeps other single-argument calls as one operand, sostring.Concat(objects) + "!"concatenates the elements of the array, andstring.Concat("x") + "y"no longer fails withInvalidCastException.