Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix spurious execution of other conditional branches after a true ELSEIF #9

Merged
merged 2 commits into from
Mar 17, 2024

Conversation

suppertails66
Copy link
Contributor

state->true_already_found is only being set for IF statements, not ELSEIF, causing various issues with subsequent branches being executed when they're not supposed to. This fix changes the behavior of ELSEIF to match IF in this regard, which I believe should solve the problem (though I haven't tested this for more complex nested constructions).

Example 1

  if 0
    inform 0,"took IF branch"
  elseif 1
    inform 0,"took ELSEIF branch 1"
  elseif 1
    inform 0,"took ELSEIF branch 2"
  else
    inform 0,"took ELSE branch"
  endif

Output on mainline:

INFORM: 'took ELSEIF branch 1'
INFORM: 'took ELSEIF branch 2'

Output with this fix:

INFORM: 'took ELSEIF branch 1'

Example 2

  if 0
    inform 0,"took IF branch"
  elseif 1
    inform 0,"took ELSEIF branch 1"
  elseif 0
    inform 0,"took ELSEIF branch 2"
  else
    inform 0,"took ELSE branch"
  endif

Output on mainline:

INFORM: 'took ELSEIF branch 1'
INFORM: 'took ELSE branch'

Output with this fix:

INFORM: 'took ELSEIF branch 1'

suppertails66 and others added 2 commits March 16, 2024 18:31
true_already_found was only being set for IF statements, not IFELSE. This
could result in spurious execution of any following IFELSE or ELSE.
@Clownacy Clownacy merged commit 67fb736 into Clownacy:master Mar 17, 2024
@Clownacy
Copy link
Owner

Thanks for fixing this.

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