fix(translate): validate control flow stack before popping#40
fix(translate): validate control flow stack before popping#40tetsuo-cpp merged 2 commits intocanonfrom
Conversation
tetsuo-cpp
left a comment
There was a problem hiding this comment.
Code Review
Looks good. Clean, well-scoped defensive fix with solid test coverage. All 6 cfStack.pop_back_val() sites are now guarded, the tag checks are correct against each push site, and the error messages are clear.
Minor suggestions
-
Missing test for REPEAT tag mismatch: All REPEAT tests trigger the empty-stack path. There's no test exercising the
destTag != CFTag::DestororigTag != CFTag::Origbranches inside REPEAT (e.g.IF REPEATwould hit the first). Not a blocker — the logic is identical to the other sites which are tested for mismatch — but would give full branch coverage. -
Future follow-up: No end-of-body check for unclosed control flow (e.g.
IFwithoutTHENleaves the stack non-empty at end of parsing). Out of scope here but could be a follow-up issue.
0bb07fd to
f2ec8d6
Compare
Summary
cfStack.pop_back_val()in the Forth translatorTHENwithoutIF,REPEATwithoutWHILE) now produce clear error messages instead of crashingTest plan
Closes #21