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

better error message for e.g. convert(Tuple{NTuple{2, Int}, Int}, (3,3,3)) #36573

Closed
goretkin opened this issue Jul 8, 2020 · 3 comments
Closed

Comments

@goretkin
Copy link
Contributor

goretkin commented Jul 8, 2020

The convert methods are defined using the structural recursion on tuples, so the error message comes from a nested call:

julia> convert(Tuple{NTuple{2, Int}, Int}, (3,3,3))
ERROR: MethodError: Cannot `convert` an object of type Int64 to an object of type Tuple{Int64,Int64}

It might be better to produce the following error message, if possible.
ERROR: MethodError: Cannot `convert` an object of type Tuple{Int64,Int64,Int64} to an object of type Tuple{Tuple{Int64,Int64},Int64}

@vtjnash
Copy link
Member

vtjnash commented Jul 14, 2020

I'd attempted this in #32427, but had gotten hung up on a type-system bug that made it segfault when I tried to detect this case. I think I've found a workaround.

@ViralBShah
Copy link
Member

With julia master:

julia> convert(Tuple{NTuple{2, Int}, Int}, (3,3,3))
ERROR: MethodError: Cannot `convert` an object of type 
  Tuple{Int64,Int64{},Int64} to an object of type 
  Tuple{Tuple{Int64, Int64},Int64{}}

@vtjnash
Copy link
Member

vtjnash commented Sep 6, 2022

Fixed by #32427

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

3 participants