-
Notifications
You must be signed in to change notification settings - Fork 7.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Casting a (single) number to System.Collections.IEnumerable
inappropriately converts to a (single) string
#18987
Comments
In 7.3.1 (Linux) it returned error
|
You have a typo: |
The Engine WG reviewed this issue today and agree that it is a bug that needs to be investigated for a potential fix. |
Here is a similar error where # works
[Collections.Generic.List[Object]]$names = 'bob', 'jen'
$names.AddRange(@( 'sue', 'bill'))
# errors
[Collections.Generic.List[String]]$names2 = 'bob', 'jen'
$names2.AddRange(@( 'sue', 'bill')) Cannot convert argument "collection" with
value: "Object[]",
for "AddRange"
to type "IEnumerable`1[String]":
"Cannot convert the "Object[]" value
of type "Object[]"
to type "IEnumerable`1[String]"." |
This works |
This issue has not had any activity in 6 months, if there is no further activity in 7 days, the issue will be closed automatically. Activity in this case refers only to comments on the issue. If the issue is closed and you are the author, you can re-open the issue using the button below. Please add more information to be considered during retriage. If you are not the author but the issue is impacting you after it has been closed, please submit a new issue with updated details and a link to this issue and the original. |
Prerequisites
Steps to reproduce
Note:
IEnumerable
should fail, consistently.[IEnumerable]
(or[IEnumerable[char]]
) from a string works correctly, given that[string]
implements those interfaces, for enumeration of a string's characters)Expected behavior
The cast should fail, given that
[int]
doesn't implementIEnumerable
.Actual behavior
'System.String'
is output, implying that the cast converted the[int]
operand to[string]
Error details
No response
Environment data
Visuals
No response
The text was updated successfully, but these errors were encountered: