Only on 404 page, get notice: trying to get property of non-object on nonce

The $post global is not set on 404 pages, which leads to the error you are getting.

You can either check if

  • $post is set or

  • bail if the current page is a 404 page or

  • do all of the above

EXAMPLE

/**
 * enqueue scripts used in frontend
 *
 */
function sama_enqueue_scripts() {
     global $post, $sama_author_review;

    if ( !isset( $post ) )
        return;

     $ajax_vars = array(
         'url' => admin_url( 'admin-ajax.php' ),
         'nonce' => wp_create_nonce('ajax-user-rate-nonce-'. $post->ID)
     );
     // see author-review.php
     wp_localize_script( 'review', 'ajax_user_rate', $ajax_vars );
}

or

/**
 * enqueue scripts used in frontend
 *
 */
function sama_enqueue_scripts() {
     global $post, $sama_author_review;

    if ( is_404() )
        return;

     $ajax_vars = array(
         'url' => admin_url( 'admin-ajax.php' ),
         'nonce' => wp_create_nonce('ajax-user-rate-nonce-'. $post->ID)
     );
     // see author-review.php
     wp_localize_script( 'review', 'ajax_user_rate', $ajax_vars );
}