Add file and line to error message
When an error occures we currently get the message e.g. "An exception has been thrown during the rendering of a template ("Warning: Undefined array key "select"")."
The problem is, that we don't know in which file and where the error occured so it is very hard to find the "cause" of the problem. If we add the File and Line it is quite easy to find the problem:

Can you give a Twig template that exhibits the issue? This PR does not work as you can see in the tests.
In my case this happens when i call e.g. a twig function and in the twig function i access a undefined array key.
As an example: The view:
{{ "test" | trans }}
{{ app_formatter_test(123)}}
The Twig extension looks like this:
/**
* @return \Twig\TwigFunction[]
*/
public function getFunctions(): array
{
return [
new TwigFunction('app_formatter_test', [$this, 'test'], ['is_safe' => ['html']]),
];
}
public function test($number) : string
{
$x = [];
$y = $x['asdf']; //this causes the warning/error
return $number;
}

The twig function is just an example - normaly i have this issue with calls to more complex data models where it is realy hard to find the cause.
Regards, Christian
The example you gave me emits a warning, which is not cause by Twig. The error message given by PHP gives you the file and line number where it happens, so probably not a good example (at least not one I can use to understand your real-wprld issue).