Repository navigation
Fix #168: ClearConst() does not clear m_vStringVarBuf - #169
Merged
Merged
Conversation
ClearConst() clears m_StrVarDef (the name->index map) but does not clear m_vStringVarBuf (the value buffer). After calling ClearConst() and re-registering string constants the buffer accumulates stale entries, while the map points at the tail indices of the growing buffer. The existing guard in IsStrVarTok only checks whether the buffer is non-empty, not that item->second is a valid index. The test defines two string constants, calls ClearConst(), re-registers them with different values, and checks that evaluation returns the new values — not the stale ones from the first registration. This will fail if the index arithmetic or buffer management regresses. https://claude.ai/code/session_01AdA3xUA3X15KMYv6VC7tXQ
The previous version checked evaluation results which were always correct (indices stay valid because the buffer only grows). The real symptom is that m_vStringVarBuf accumulates stale entries across ClearConst() calls: after one round of DefineStrConst + ClearConst + DefineStrConst the buffer has 4 entries instead of 2. Check the buffer size directly, mirroring how TestIssue165 inspects m_vStringBuf. The test now fails with the current code and will pass once ClearConst() is fixed to also clear m_vStringVarBuf. https://claude.ai/code/session_01AdA3xUA3X15KMYv6VC7tXQ
m_vStringVarBuf must be cleared alongside m_StrVarDef to keep the two structures in sync. Previously, repeated calls to ClearConst() followed by DefineStrConst() caused the value buffer to accumulate stale entries indefinitely. https://claude.ai/code/session_01AdA3xUA3X15KMYv6VC7tXQ
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #168.
Problem
ClearConst()clearedm_StrVarDef(the name→index map) but notm_vStringVarBuf(the string value buffer). After each round ofDefineStrConst+ClearConst+DefineStrConstthe buffer accumulated stale entries, leaving the two structures out of sync.Fix
One line added to
ClearConst()inmuParserBase.cpp:Test
TestIssue168inmuParserTest.cppverifies that afterClearConst()+ re-registration,m_vStringVarBuf.size()equals the number of newly registered constants (2), not the accumulated total (4). The test failed before this fix and passes after.