user_id error: Only variables should be passed by reference

There is an answer for your question right in the Codex:

The first parameter of get_comment function is:

$comment – (integer) (required)

The ID of the comment you’d like to fetch. You must pass a variable
containing an integer (e.g. $id). A literal integer (e.g. 7) will
cause a fatal error (Only variables can be passed for reference or
Cannot pass parameter 1 by reference).

Default: None

In your code, you’re passing a function result as this param, so it’s not a variable, so you get this error.

How to fix this? It’s pretty simple… Just use a variable in there:

$comment_id = get_comment_ID();
$user_id = get_comment( $comment_id )->user_id;

Or use a dummy variable (as shown in Codex):

$user_id = get_comment( $dummy = get_comment_ID() )->user_id;