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

Wrong InexactError in Bool expression #8523

Closed
eschnett opened this issue Sep 29, 2014 · 7 comments
Closed

Wrong InexactError in Bool expression #8523

eschnett opened this issue Sep 29, 2014 · 7 comments

Comments

@eschnett
Copy link
Contributor

This expression from JSON.jl (line 11) yields InexactError since today:

Bool[isprint(c) && !iscntrl(c) && !(c in ['\\','"']) for c in '\x00':'\x7F']

The problem seems to be the lower bound '\x00' of the character range.

@eschnett
Copy link
Contributor Author

I see this line in "range.jl":

    UnitRange(start, stop) = new(start, ifelse(stop >= start, stop, start-1))

This unconditionally evaluates start-1, which yields InexactError for start = \x00.

@eschnett
Copy link
Contributor Author

"range.jl" is in base...

@eschnett
Copy link
Contributor Author

Yes, changing the ifelse to ?: corrects the problem.

@tkelman
Copy link
Contributor

tkelman commented Sep 29, 2014

Might also be the fault of

-(x::Char , y::Integer) = char(int(x)-int(y))
, since I can do uint(0):uint(5) but not char(0):char(5)

@eschnett
Copy link
Contributor Author

I don't think this line is at fault.

In this case, this line tries to convert a negative integer to a character, which is not defined. However, its inputs are '\x00' and 1 -- so there's nothing this functions could really do. (Presumably, it could define a wrap-around for characters, so that char(-1) is mapped to char(UIntMax), but that doesn't seem useful.)

@eschnett
Copy link
Contributor Author

See #8524

@tkelman
Copy link
Contributor

tkelman commented Sep 29, 2014

uint(0)-1 == 0xffffffffffffffff, so if char is a type of uint (though the signedness of char can be a platform-dependent thing, IIUC) then perhaps it should have the same behavior?

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