This causes a major issue with recursive functions that rely on killing an entity to terminate the chain. It seems that the armor stand is killed 1 tick later, causing conditional commands that check for that entity to still execute until the function ends. This contrasts from the teleport command, in which the player can use the execute command to update the position at which teleport commands will be relative to. These are the commands, used in a function:
/kill @s
/execute if @s run say hi
What I expected: the executing entity is killed and the second command never runs.
What actually happened: in chat: [executing entity]:hi, then the entity gets killed.
I got tired of constantly searching the bug tracker for this issue and turning up mainly results that in no way relate to it, even with using more specific search criteria. I might have seen one that has to do with if statements not working correctly, but I haven't been able to find it again.
Related issues
Comments


Dead players, not dead mobs or killed armor stands, which is what the commands use. Players still exist after death, mobs and other entities do not.
Sure they do – they exist so they can continue doing their death animation for example 🙂
In fact you can even save, exit, and relog and a dying mob will still be dying. As for other entities, they are marked dead but not cleared until the end of the tick.
@e
just can't target dead or dying entities

The fact that they are marked as dead but are not immediately removed is an implementation detail and therefore we should not rely on that too much. And even the way it currently is might cause problems. Should it be reopened at least for that case but then include this general problem that selectors can contain marked as dead entities?

If the suggestion doesn't already exist, I will try to make one on the minecraft reddit page that would suggest the addition of a dead/alive parameter to entity selectors. In which case maybe this issue should be postponed for now until more information on the subject is given. I don't see a need to change behavior that only causes issues in a single isolated situation (the use of @s in functions), but there is a need to allow the player to change the default behavior that is causing the issues. That is why I considered this a bug, because the default feature (which could reasonably be specified otherwise by the player) is left in a state that cannot be changed, thus resulting in undesirable, set in stone behavior. Should I switch my attention to the suggestions page, or is this issue actually considered a bug? There are workarounds to the issue, such as using tags or scores, but no direct solution exists.
@s and @a can target the dead, this is intentional design.