Throws SyntaxException in Twig 3.* if autoescape is used in a spaceless block

/var/www/html/vendor/twig/twig/lib/Twig/Parser.php:496

I recently updated from Twig 2.* to Twig 3.* and received a SyntaxException when attempting to render templates with the structure:

{% autoescape %}
  ...
  {% spaceless %}
    ...
  {% endspaceless %}
  ...
{% endautoescape %}

Why is this structure no longer supported by Twig? How should it be rewritten or supported?

This structure is no longer supported by Twig 3. Use the autoescape tag with the spaceless filter instead:

{% autoescape %}
  ...
  {{ ...|spaceless }}
  ...
{% endautoescape %}