-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
fix for Regression that the introduction of BackwardsIndex introduced #7265
Conversation
Brilliant solution, fails for
|
that's what the tests are for, aren't they. I will see what I can do. |
Well I would like to comment on your snorky remark. I think your sarcasm is inapropriate. I try to fix a bug and I did not get it right the first time. That is what test are there for. I could also have reacted the same way when the BackwardsIndex was introduced, but I did not. But thanks for pointing out the tests that failed. Actually digging though the logs of Travis and AppVeyor is very tedious, because it is so slow. And last but not least, I would like to write a comment on the var a: array['a'..'c', string] = ["a", "b", "c"]
echo a[0] # <- this isn't allowed
echo a[^1] # So then why should this be allowedS It doesn't make a lot of sense to me. |
And on the test this is the line that failes: let lst = lc[$x | (x <- 'a'..'z'), string].asList And this is the error message I get:
I don't understand how that is related to the changes I made. |
No sarcasm involved here! I really like this solution! :-) Sorry. |
Once it works we need to decide if |
Good point, I agree. Well, apparently it used to work and |
I write an entry in the changelog, that backwards index for non-int indexed types does not compile anymore. And I remove the test. |
@Araq: No you can't really use it for generic programming either, because there is no generic way to access the first element. |
Since this breaks tmapconcept.nim, I delay this PR until further concept-related bugs are fixed. Sorry. |
As example here is a data structure that won't work with these changes. |
@NotTito: It was very confusing to me that you used head and tail with that semantic. normally head is the first element of a list and tail everything but the first element. In your case both were indices. I think |
7044343
to
f72ec4e
Compare
@NotTito I just tried moved the backwards index to the newest version of Nim and tested it with your example. There was a bug in line 53 where a normal index and a backwards index get subtracted. That operator is not defined. But when line 52 and 53 are removed, the automatically generated backwards index will work just fine. I tested it. |
well there is nothing I can do with the concepts part. It seems like the concepts are broken, because my changes should not affect concepts at all. |
Unfortunately, yes. :-( |
3693aa8
to
54290c4
Compare
This pull request has been automatically marked as stale because it has not had recent activity. If you think it is still a valid PR, please rebase it on the latest devel; otherwise it will be closed. Thank you for your contributions. |
Before the introduction of
BackwardsIndex
the following code worked.BackwardsIndex
broke it and with this PR it works again:The idea is: When I have a type that supports both
len
and`[]`
, then backwards indexing should just work out of the box. It did work, and now it works again. And while I was fixing this, it just happened to also allow for custom BackwardsIndex conversion functions:As you can see, I do not overload
len
forMyType
here. And it just works out of the box. While it is still possible to overload the[]
operator for BackwardsIndex to support it, it is not needed anymore.And last but not least. The code in
system.nim
is shorter now.