Fixing System.Array constructor#107266
Merged
michaelgsharp merged 2 commits intodotnet:mainfrom Sep 16, 2024
Merged
Conversation
This was referenced Sep 3, 2024
stephentoub
reviewed
Sep 4, 2024
src/libraries/System.Numerics.Tensors/src/System/Numerics/Tensors/netcore/TensorSpan.cs
Show resolved
Hide resolved
| return; // returns default | ||
| } | ||
| if (!typeof(T).IsValueType && array.GetType() != typeof(T[])) | ||
| if (array.GetType().GetElementType() != typeof(T)) |
Member
There was a problem hiding this comment.
This looks like a correct fix. But I'd like us to get an issue logged around this, as this seems like a pit of failure here.
In particular, since Array is "untyped" and due to how new[] {...} works, it means that users can get into these types of silent failures; when they likely expected it to be implicitly typed as double[] like [...] would've been.
So I think we may want to consider if this should be a constructor or instead some named Create* method where * is an appropriate suffix.
tannergooding
approved these changes
Sep 9, 2024
Contributor
Author
|
/backport to release/9.0 |
Contributor
|
Started backporting to release/9.0: https://github.com/dotnet/runtime/actions/runs/10779752164 |
4 tasks
Contributor
Author
|
/azp run |
|
You have several pipelines (over 10) configured to build pull requests in this repository. Specify which pipelines you would like to run by using /azp run [pipelines] command. You can specify multiple pipelines using a comma separated list. |
a706e72 to
bee3313
Compare
jtschuster
pushed a commit
to jtschuster/runtime
that referenced
this pull request
Sep 17, 2024
* fixing System.Array constructor * adding back in co-varience check and tests
sirntar
pushed a commit
to sirntar/runtime
that referenced
this pull request
Sep 30, 2024
* fixing System.Array constructor * adding back in co-varience check and tests
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Fixes #106534. Fixes the check in the System.Array constructor to make sure the type of the Array matches the
Tthat was used.