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

Fix removeOne for internal set #4482

Open
wants to merge 1 commit into
base: dev
Choose a base branch
from
Open

Fix removeOne for internal set #4482

wants to merge 1 commit into from

Commits on Dec 7, 2023

  1. Fix removeOne for internal set

    Here, in go, if we assign a slice position to a variable, we'll have a copy.
    
    ki.Start = v + 1, on line 218, was just modifying a copy, which is not what was intended to be done here.
    
    If we get the reference as done in the change, we'll modify `ki.Start`properly. Another option would be to reasign the copy to the array position. Either way, this should be fixed.
    
    Simple test which would fail:
    
    func (suite *IIntervalSetTestSuite) TestRemoveOne() {
    	i := NewIntervalSet()
    	i.addInterval(antlr.NewInterval(5, 10))
    
    	i.removeOne(7)
    
    	suite.Len(i.intervals, 2)
    	suite.Equal(5, i.intervals[0].Start)
    	suite.Equal(7, i.intervals[0].Stop)
    	suite.Equal(8, i.intervals[1].Start)
    	suite.Equal(10, i.intervals[1].Stop)
    }
    
    
    
    Signed-off-by: Gustavo de Morais <gustavopguto@gmail.com>
    Guttz committed Dec 7, 2023
    Configuration menu
    Copy the full SHA
    8bf2a29 View commit details
    Browse the repository at this point in the history