Created by: gdethier
This PR fixes #11889. The change has been tested against the code example provided in the issue:
Without the change, one would get this instead: