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

disallow line-terminating colons #4701

Closed
andrewcooke opened this issue Oct 31, 2013 · 5 comments
Closed

disallow line-terminating colons #4701

andrewcooke opened this issue Oct 31, 2013 · 5 comments

Comments

@andrewcooke
Copy link
Contributor

About 1 time in 5, when I run

julia runtests.jl

in the src directory of https://github.com/andrewcooke/Stupid.jl/tree/range-bug I see

: julia runtests.jl 
Prefix
   0 010204 1/02 2/04 1/02
ERROR: Range: length must be non-negative
 in Range1 at range.jl:27
at /home/andrew/.julia/Stupid/src/runtests.jl:4

I have reduced the project as much as (quickly) possible, deleting routines and modules that are not used. But it's still a non-trivial amount of code (it's the analysis of a stream cipher).

I also updated to the latest version of Julia (from git), and still see the problem - I am using Version 0.2.0-rc2+105; Commit 5167476 2013-10-31 18:03:04 UTC; x86_64-suse-linux

Feel free to ask questions; I have no idea how to debug something like this - the stack trace shown seems to be completely wrong (it's missing tests() and test_distance() - you can see some output generated by test_distance() before the ERROR).

(I think it's a bug in Julia because although I was using random numbers elsewhere, that test, which is all that is left in the branch, where the code still fails, is deterministic. Yet the error is intermittent and the stack trace seems incorrect).

Cheers, Andrew

@JeffBezanson
Copy link
Sponsor Member

This is because of the pythonic colon at the end of Prefix.jl:21, which is getting parsed across the line break as h1:consume(t). This certainly makes me think allowing colons to parse across lines is a bad thing.

The second argument to colon is a large integer hash value, which is sometimes outside the range of the Int type, leading to the error. We only give the error in one direction, but there should probably be a different error for too-large ranges.

@andrewcooke
Copy link
Contributor Author

Oh, I feel like an idiot. I really appreciate all the help here and on the list. Sorry for posting this and wasting your time. Thanks!

@JeffBezanson
Copy link
Sponsor Member

I think this issue raises a very valid point: programmers are likely to try : at the end of a line, and instead of getting an error you just get highly unexpected behavior. I think this should be fixed.

@StefanKarpinski
Copy link
Sponsor Member

Not at all. I think the actionable result of this issue is that we shouldn't allow colon syntax to be split across lines. There's no reasonable reason to do that and it's very likely that many Pythonistas will make the same mistake in the future.

@pao
Copy link
Member

pao commented Oct 31, 2013

Reopened with updated title.

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

4 participants