Skip to content

Detect and error on nested/invalid subroutine definitions in named subs#3886

Merged
andypugh merged 1 commit intoLinuxCNC:masterfrom
grandixximo:issue-3880-fix
Mar 30, 2026
Merged

Detect and error on nested/invalid subroutine definitions in named subs#3886
andypugh merged 1 commit intoLinuxCNC:masterfrom
grandixximo:issue-3880-fix

Conversation

@grandixximo
Copy link
Copy Markdown

The parser silently ignored sub definitions inside called subroutines, causing wrong parameters and premature returns. Numbered subs after a named endsub polluted the global offset map and conflicted across files.

  • Add nesting checks in read and execute phases at call_level > 0
  • Block forward-seek for subs at call_level > 0 when no file exists
  • Let control_back_to errors propagate without generic overwrite
  • Update o-code docs with nesting example and new error conditions

Ref: #3880

@grandixximo grandixximo force-pushed the issue-3880-fix branch 2 times, most recently from 560c271 to daf41c9 Compare March 29, 2026 04:16
@andypugh
Copy link
Copy Markdown
Collaborator

Can I suggest adding a test to the testsuite for this?

The parser silently ignored sub definitions inside called subroutines,
causing wrong parameters and premature returns. Numbered subs after a
named endsub polluted the global offset map and conflicted across files.

- Add nesting checks in read and execute phases at call_level > 0
- Block forward-seek for subs at call_level > 0 when no file exists
- Let control_back_to errors propagate without generic overwrite
- Update o-code docs with nesting example and new error conditions

Ref: LinuxCNC#3880
@grandixximo
Copy link
Copy Markdown
Author

Can I suggest adding a test to the testsuite for this?

@andypugh tests were added

@andypugh andypugh merged commit 69b1f80 into LinuxCNC:master Mar 30, 2026
14 checks passed
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.

2 participants