IRremote library doesn't work normally

Hi,
I am trying to build an intelligent alarm that detects when the person is still asleep (and if the person is, it stays on and keeps playing music). It uses a 16 02 LCD screen and a DS3231 clock module. The IRremote library works fine on its own, but when I inserted the LCD library and added the code for the LCD screen, this line >>> IRrecv irrecv(receiver); will get underlined as wrong:

Arduino: 1.8.4 (Windows 10), Board: "Arduino/Genuino Mega or Mega 2560, ATmega2560 (Mega 2560)"

...
 
exit status 1
'receiver' was not declared in this scope

On its own, the same line and the same code worked and still works.
Here’s the code on its own:

#include <IRremote.h>

int receiver = 2;

IRrecv irrecv(receiver);      
decode_results results;       

void setup()  {
  Serial.begin(9600);
  Serial.println("Inizio rilevazione");
  irrecv.enableIRIn();
 
}


void loop() {
  if (irrecv.decode(&results)) {
    Serial.println(results.value);
    delay(1000);
    irrecv.resume();
  }
}

little sidenote: the code was written by me, I did not copy anything.

Code with LCD screen:

#include <LiquidCrystal.h>
#include <IRremote.h>

LiquidCrystal lcd(7, 6, 5, 4, 3, 2);
IRrecv irrecv(receiver);
decode_results results;

int data;
int data2;
int data3;
int data4;
int pos;

void setup() {
  pinMode(8, OUTPUT);
  pinMode(9, OUTPUT);
  pinMode(10, OUTPUT);
  pinMode(11, OUTPUT);
  pinMode(12, OUTPUT);
  pinMode(13, OUTPUT);
  lcd.begin(16, 2);
  lcd.clear();
}

void loop() {
  if (irrecv.decode(&results)) {
    if (pos == 0) {
      if (results.value == 16753245) {
        data = 10;
        Serial.println(data);
      }
      if (results.value == 16738455) {
        data = 0;
        Serial.println(data);
      }
      if (results.value == 16724175) {
        data = 1;
        Serial.println(data);
      }
      if (results.value == 16718055) {
        data = 2;
        Serial.println(data);
      }
      if (results.value == 16743045) {
        data = 3;
        Serial.println(data);
      }
      if (results.value == 16716015) {
        data = 4;
        Serial.println(data);
      }
      if (results.value == 16726215) {
        data = 5;
        Serial.println(data);
      }
      if (results.value == 16734885) {
        data = 6;
        Serial.println(data);
      }
      if (results.value == 16728765) {
        data = 7;
        Serial.println(data);
      }
      if (results.value == 16730805) {
        data = 8;
        Serial.println(data);
      }
      if (results.value == 16732845) {
        data = 9;
        Serial.println(data);
      }
      pos = 1;
      delay(1000);
      irrecv.resume(); // receive the next value
    }
    else if (pos == 1) {
      if (results.value == 16753245) {
        data = 10;
        Serial.println(data2);
      }
      if (results.value == 16738455) {
        data = 0;
        Serial.println(data2);
      }
      if (results.value == 16724175) {
        data = 1;
        Serial.println(data2);
      }
      if (results.value == 16718055) {
        data = 2;
        Serial.println(data2);
      }
      if (results.value == 16743045) {
        data = 3;
        Serial.println(data2);
      }
      if (results.value == 16716015) {
        data = 4;
        Serial.println(data2);
      }
      if (results.value == 16726215) {
        data = 5;
        Serial.println(data2);
      }
      if (results.value == 16734885) {
        data = 6;
        Serial.println(data2);
      }
      if (results.value == 16728765) {
        data = 7;
        Serial.println(data2);
      }
      if (results.value == 16730805) {
        data = 8;
        Serial.println(data2);
      }
      if (results.value == 16732845) {
        data = 9;
        Serial.println(data2);
      }
      pos = 2;
      delay(1000);
      irrecv.resume(); // receive the next value
    }
    else if (pos == 2) {
      if (results.value == 16753245) {
        data = 10;
        Serial.println(data3);
      }
      if (results.value == 16738455) {
        data = 0;
        Serial.println(data3);
      }
      if (results.value == 16724175) {
        data = 1;
        Serial.println(data3);
      }
      if (results.value == 16718055) {
        data = 2;
        Serial.println(data3);
      }
      if (results.value == 16743045) {
        data = 3;
        Serial.println(data3);
      }
      if (results.value == 16716015) {
        data = 4;
        Serial.println(data3);
      }
      if (results.value == 16726215) {
        data = 5;
        Serial.println(data3);
      }
      if (results.value == 16734885) {
        data = 6;
        Serial.println(data3);
      }
      if (results.value == 16728765) {
        data = 7;
        Serial.println(data3);
      }
      if (results.value == 16730805) {
        data = 8;
        Serial.println(data3);
      }
      if (results.value == 16732845) {
        data = 9;
        Serial.println(data3);
      }
      pos = 4;
      delay(1000);
      irrecv.resume(); // receive the next value
    }
    if (pos == 3) {
      if (results.value == 16753245) {
        data = 10;
        Serial.println(data4);
      }
      if (results.value == 16738455) {
        data = 0;
        Serial.println(data4);
      }
      if (results.value == 16724175) {
        data = 1;
        Serial.println(data4);
      }
      if (results.value == 16718055) {
        data = 2;
        Serial.println(data4);
      }
      if (results.value == 16743045) {
        data = 3;
        Serial.println(data4);
      }
      if (results.value == 16716015) {
        data = 4;
        Serial.println(data4);
      }
      if (results.value == 16726215) {
        data = 5;
        Serial.println(data4);
      }
      if (results.value == 16734885) {
        data = 6;
        Serial.println(data4);
      }
      if (results.value == 16728765) {
        data = 7;
        Serial.println(data4);
      }
      if (results.value == 16730805) {
        data = 8;
        Serial.println(data4);
      }
      if (results.value == 16732845) {
        data = 9;
        Serial.println(data4);
      }
      pos = 0;
      delay(1000);
      irrecv.resume(); // receive the next value
    }
  }
  esegui();
}
void esegui() {
  //empty for now
}

What could be causing the problem? Is the library broken? It surely has lots of problems…
Thank you

Have you tried to assign it to its number.

int receiver = 2;
IRrecv irrecv(receiver);

The error is correct. In the first sketch, you declare a variable named receiver:

int receiver = 2;

In the second sketch, you don't.

Did you declare the variable before or inside your main function?