Skip to content

fix: function and arg size book-keeping for TestSub recursion#874

Open
jodavies wants to merge 1 commit into
form-dev:masterfrom
jodavies:issue-741-gpt
Open

fix: function and arg size book-keeping for TestSub recursion#874
jodavies wants to merge 1 commit into
form-dev:masterfrom
jodavies:issue-741-gpt

Conversation

@jodavies

Copy link
Copy Markdown
Collaborator

When TestSub is called recursively, correctly update the nested sizes. Rely on the recursion to fix the sizes at each level, except when an argument term disappears completely; then we fix up the whole nesting stack and continue processing further argument terms.

This fix was prepared with the help of an LLM report: https://gist.github.com/tueda/9d71a87e04dcc1f51fbbb432ae1af903

Its findings are in line with previous debugging efforts by me, but I did not figure out a proper fix at the time.

In addition:

  • completely remove the "subsubveto" mechanism, which appears to be a previous workaround, required due to the incorrect size updates
  • add a check that we do not exceed the FunctionLevels setup parameter, and give an error message for the user if so.
  • check RecFlag has the same value on entry and when returning from TestSub

This fixes #367 and #741

@jodavies

Copy link
Copy Markdown
Collaborator Author

Tentatively, this is also a 1% performance improvement in forcer, forcer-exp and maybe hyperform.

@coveralls

coveralls commented Jul 13, 2026

Copy link
Copy Markdown

Coverage Status

coverage: 63.19% (+0.004%) from 63.186% — jodavies:issue-741-gpt into form-dev:master

When TestSub is called recursively, correctly update the nested sizes.
Rely on the recursion to fix the sizes at each level, except when an
argument term disappears completely; then we fix up the whole nesting
stack and continue processing further argument terms.

This fix was prepared with the help of an LLM report:
https://gist.github.com/tueda/9d71a87e04dcc1f51fbbb432ae1af903

Its findings are in line with previous debugging efforts by me, but
I did not figure out a proper fix at the time.

In addition:
- add a check that we do not exceed the FunctionLevels setup parameter,
  and give an error message for the user if so.
- check RecFlag has the same value on entry and when returning from TestSub
@jodavies

jodavies commented Jul 14, 2026

Copy link
Copy Markdown
Collaborator Author

I put back subsubveto, since @tueda is not sure about it. I think it would help if we could find a FORM script which would hit the following code, in the case that AN.subsubveto == 1:

form/sources/proces.c

Lines 741 to 748 in b143fc2

if ( t[3] == 0 ) {
t1 = r + r[1];
t2 = term + *term;
*term -= r[1]+t[1];
r = t;
while ( t1 < t2 ) *r++ = *t1++;
goto ReStart;
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

replace_ fails to handle 0-replacement

2 participants