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

ERROR: - has no method matching -(::Uint8, ::Char) #717

Closed
milktrader opened this issue Nov 3, 2014 · 7 comments · Fixed by #718
Closed

ERROR: - has no method matching -(::Uint8, ::Char) #717

milktrader opened this issue Nov 3, 2014 · 7 comments · Fixed by #718

Comments

@milktrader
Copy link

This error is cropping up on Julia v0.4 tests in a couple packages (NLreg, Quandl). Not sure this is a DataFrames issue but that is a common link

ERROR: `-` has no method matching -(::Uint8, ::Char)
 in bytestotype at /home/idunning/pkgtest/.julia/v0.4/DataFrames/src/dataframe/io.jl:410
 in builddf at /home/idunning/pkgtest/.julia/v0.4/DataFrames/src/dataframe/io.jl:570
 in readtable! at /home/idunning/pkgtest/.julia/v0.4/DataFrames/src/dataframe/io.jl:783
 in readtable at /home/idunning/pkgtest/.julia/v0.4/DataFrames/src/dataframe/io.jl:868
 in readtable at /home/idunning/pkgtest/.julia/v0.4/DataFrames/src/dataframe/io.jl:935
 in include at ./boot.jl:242
 in include_from_node1 at loading.jl:128
 in process_options at ./client.jl:293
 in _start at ./client.jl:362
 in _start_3B_3769 at /home/idunning/julia04/usr/bin/../lib/julia/sys.so
while loading /home/idunning/pkgtest/.julia/v0.4/NLreg/test/runtests.jl, in expression starting on line 4

dmbates/NLreg.jl#7

@johnmyleswhite
Copy link
Contributor

Doing convert(Uint8, char) where needed should fix this.

@milktrader
Copy link
Author

Ok, great. Thanks.

@milktrader
Copy link
Author

Here is the first block in the trace

405     if byte == '-'
 406         return -value, left < right, false
 407     elseif byte == '+'
 408         return value, left < right, false
 409     elseif '0' <= byte <= '9'
 410         value += (byte - '0') * power
 411         return value, true, false
 412     else
 413         return value, false, false
 414     end
 415 end

Incidentally, this error is raised only in testing. The methods calling readtable work fine locally (at least in Quandl).

@ivarne
Copy link

ivarne commented Nov 3, 2014

Note that convert(Uint8, char) is a checked operation that might overflow and throw InexactError. This makes it likely to be much slower than convert(Int, char).

@garborg
Copy link
Contributor

garborg commented Nov 3, 2014

I'd say value += (byte - uint8('0')) * power is easier to read without any convert call. I'm glad for the reminder about convert being checked now -- I had forgotten -- but as it's just being used on a character literal and will be compiled away, no need to jump through hoops in this case.

@ivarne
Copy link

ivarne commented Nov 3, 2014

Yes, I forgot to write that.

Uint8('0') will also work on 0.4

@garborg
Copy link
Contributor

garborg commented Nov 3, 2014

Nice! Exciting times, but a lot of new things to keep in mind for the next few months.

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

Successfully merging a pull request may close this issue.

4 participants