SOLVED: {wp_user_id} in Code Widget crashes it

It seems to be caused by using dynamic tags without quotes.
$pid = {post_id}; => crashes
$pid = "{post_id}"; => works

Execution of the PHP code seems to take place (and cause fatal error) before the dynamic tags are replaced.