Uncaught PHP Exception Twig\Error\SyntaxError: "An exception has been thrown during the compilation of a template ("Attribute "name" does not exist for Node "Twig\Node\CheckToStringNode".") in "core/themes/bartik/templates/block--system-menu-block.html.tw

When upgrading drupal 8.6.15 the Updating twig/twig (v1.39.1 => v1.40.1) broke my site with:

The website encountered an unexpected error. Please try again later.

To see the cause of the error had to add this to web/site/default/settings.php

$config['system.logging']['error_level'] = 'verbose';
 

Then I can see the following error on the web site:

Uncaught PHP Exception Twig\Error\SyntaxError: "An exception has been thrown during the compilation of a template ("Attribute "name" does not exist for Node "Twig\Node\CheckToStringNode".") in "core/themes/bartik/templates/block--system-menu-block.html.tw

Solution was to downgrade twig

$ composer require twig/twig:1.39.1