Skip to content
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

Inconsistent Matrix creation with tuples #23246

Closed
Jackels opened this issue Aug 14, 2017 · 1 comment
Closed

Inconsistent Matrix creation with tuples #23246

Jackels opened this issue Aug 14, 2017 · 1 comment

Comments

@Jackels
Copy link

Jackels commented Aug 14, 2017

Julia v0.6

a::Int64 = 5
b::Tuple{Int64, Int64} = (a, a)
Matrix{Int64}(b)

This code works, but if you replace all instances of Int64 with Int32 it does not work anymore.

ERROR: MethodError: Cannot `convert` an object of type Tuple{Int32,Int32} to an object of type Array{Int32,2}
This may have arisen from a call to the constructor Array{Int32,2}(...),
since type constructors fall back to convert methods.

But if you write it a bit different

a::Int64 = 5
Matrix{Int64}(a, a)

this will work with either Int32 or Int64.

I think my first sample should work with any integer-version.

@fredrikekre
Copy link
Member

Closing in favor of #23029. See also #23032, #17372 (comment)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants