Nested REPEAT overwrites the outer $REPEAT_INDEX

Open
#26 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
3/5
Estimated time
Half a day
Newbie friendliness
70/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
cpp
Domain
tooling

Research direction

Start in src/script_executor.cpp, where $REPEAT_INDEX is written at L186 and L389, and trace how REPEAT and ENDREPEAT handle the loop counter. The index currently lives in a single global, so the fix needs to keep it per loop frame and restore the enclosing value when an inner loop ends. Done when the reproduction REPEAT 2 / REPEAT 3 / ... / LOG "outer=$REPEAT_INDEX" / ENDREPEAT logs outer=0 then outer=1.

Written by the indexing model from the issue text.

Description

bug
Summary

$REPEAT_INDEX is a single global variable; an inner REPEAT overwrites it and it is not restored when the inner loop ends.

Location
  • File(s): src/script_executor.cpp
  • Line(s) / function(s): L186, L389
Category

functional

Severity

low

Reproduction / Evidence

Reproducible at runtime: REPEAT 2 / REPEAT 3 / SET $X 1 / ENDREPEAT / LOG "outer=$REPEAT_INDEX" / ENDREPEAT logs outer=2 twice; expected outer=0 then outer=1.

Expected Behavior

The index of the enclosing loop is restored after an inner loop.

Actual Behavior

Outer index lost.

Root Cause

Index stored in a global variable rather than per loop frame.

Dominant language
C++
Stars
1
Forks
2
Avg merge
1h 34m
Merged PRs (30d)
7

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from 5250ng/5250script

All issues in 5250ng/5250script

Similar issues

More C++ issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.