sonar-dotnet icon indicating copy to clipboard operation
sonar-dotnet copied to clipboard

Make `ProgramState.SetOperationValueCore` set the value for a tracked symbol as well

Open Tim-Pohlmann opened this issue 1 year ago • 0 comments

If the operation passed to ProgramState.SetOperationValueCore has a tracked symbol (operation.TrackedSymbol(state) is { } symbol) the method should also set the symbolic value for the symbol.

When implemented naively, multiple UTs start failing. The reasons for this need to be investigated, and the problems evaluated to see if they can be solved.

Why? The following and similar patterns are repeated multiple times in our solution:

state = state.SetOperationValue(operation, value);
if (operation.TrackedSymbol(state) is { } symbol)
{
    state = state.SetSymbolValue(symbol, value);
}

This is unnecessary. Changing the behavior of SetOperationValueCore lets us simplify the code to

state = state.SetOperationValue(operation, value);

Tim-Pohlmann avatar Jun 14 '24 12:06 Tim-Pohlmann