-
Notifications
You must be signed in to change notification settings - Fork 25
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
Fixed forRange
in Julia for positive step
values
#3994
base: main
Are you sure you want to change the base?
Conversation
Julia's ranges include the end value, and other languages don't. I updated the Julia renderer to subtract `1` from the end value to match the other languages. Note that while this fixes it for positive `step` values, it does not for negative `step` values. More work needs to be done here.
forRange
in Julia for positive step
values
I'm not sure what's going on with HLint. The error in the log is |
@@ -2,11 +2,11 @@ module VectorTest | |||
|
|||
global v1 = [1.0, 1.5] | |||
global v2 = [0.0, -1.0] | |||
for i in 0:1:length(v1) - 1 | |||
for i in 0:1:length(v1) - 1 - 1 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems odd -- length - 2 ? This looks like it is over-compensating!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch. I should have noticed that. It looks like I accounted for the range difference in the thunkAssign
function, which uses the forRange
function. Because this change is upstream of it (most likely the 'correct' place), it was affected. My new commit should remedy that.
Turns out that `thunkAssign` already subtracted `1`, so the new generated code was subtracting it twice. This code should resolve that issue.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm approving now, but won't merge in quite yet, as the linter did not run - looks like an upstream problem though, i.e. not your fault.
#3998 should fix that, but I'm waiting for a review. |
Julia's ranges include the end value, and other languages don't. I updated the Julia renderer to subtract
1
from the end value to match the other languages.Note that while this fixes it for positive
step
values, it does not for negativestep
values. More work needs to be done here.Contributes to #3992