Skip to content

Conversation

@letFunny
Copy link
Collaborator

@letFunny letFunny commented Oct 14, 2025

This commit reverts the change in
aca3b32 that changed the for loop to
use the new range semantics which was not equivalent because we were
mutating the contents of the array in the loop itself.

A test has been added to detect it.

  • Have you signed the CLA?

For context, the commit was part of PR #215 which introduced cosmetic changes to the code. The lesson here is that we should not change the code for the sake of cosmetics unless it is strictly necessary, subtle changes in semantics can introduce hard to find bugs.

This commit reverts the change in
aca3b32 that changed the for loop to
use the new range semantics which was not equivalent because we were
mutating the contents of the array in the loop itself.

A test has been added to detect it.
@letFunny letFunny requested a review from niemeyer October 14, 2025 15:33
@letFunny letFunny added Simple Nice for a quick look on a minute or two Priority Look at me first Bug An undesired feature ;-) labels Oct 14, 2025
@github-actions
Copy link

Command Mean [s] Min [s] Max [s] Relative
BASE 8.545 ± 0.023 8.509 8.587 1.00
HEAD 8.553 ± 0.018 8.531 8.577 1.00 ± 0.00

Copy link
Contributor

@zhijie-yang zhijie-yang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the quick fix @letFunny . The new test looks good to me.

Copy link
Contributor

@niemeyer niemeyer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense, thanks for the fix.

@niemeyer niemeyer merged commit 3e6e615 into canonical:main Oct 20, 2025
18 checks passed
@lczyk
Copy link
Contributor

lczyk commented Nov 20, 2025

just spend about 1/2 a day thinking i found a bug in chisel, and i did. i found this one 😅 (i was on 1.2.0) glad it's fixed and just wanted to +1 this PR from the future. @zhijie-yang you've beat me to it by a month ;)

@lczyk
Copy link
Contributor

lczyk commented Nov 20, 2025

also @letFunny

The lesson here is that we should not change the code for the sake of cosmetics

the lesson is also that we should not mutate an array while iterating over it 😉 i know this code is using a slice kindof like a queue, but then i'd make it an actual datastructure (which, yes, would likely be backed by a slice)

@letFunny letFunny deleted the bugfix-transitive-essential branch November 21, 2025 09:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bug An undesired feature ;-) Priority Look at me first Simple Nice for a quick look on a minute or two

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants