Combining of sensor and led code: was not declared in this scope

Hi everyone

I am a beginner in Arduino. I try to make a code where a neopixel ring flashes when an object is near a ultrasonic distance sensor. When there is nothing close to the sensor, the ring has this animation:

#include <Adafruit_NeoPixel.h>
 
#define PIN      6
#define N_LEDS 16
 
Adafruit_NeoPixel strip = Adafruit_NeoPixel(N_LEDS, PIN, NEO_GRB + NEO_KHZ800);
 
void setup() {
  strip.begin();
}
 
void loop() {
  chase(strip.Color(255, 0, 0)); // Red
  //chase(strip.Color(0, 255, 0)); // Green
 
}
 
static void chase(uint32_t c) {
  for(uint16_t i=0; i<strip.numPixels()+4; i++) {
      strip.setPixelColor(i  , c); // Draw new pixel
      strip.setPixelColor(i-4, 0); // Erase pixel a few steps back
      strip.show();
      delay(50);
  }
}

When I want to combine the code with the distance sensor and an If statement, I get the error: 'chase' was not declared in this scope

#include <Ultrasonic.h>
#include <Adafruit_NeoPixel.h>
#define PIN      6
#define N_LEDS 16

Adafruit_NeoPixel strip = Adafruit_NeoPixel(N_LEDS, PIN, NEO_GRB + NEO_KHZ800);

Ultrasonic ultrasonic(7, 8);
int distance;

void setup() {
  Serial.begin(9600);
  strip.begin();
  strip.show(); // Initialize all pixels to 'off'
}

void loop() {
  distance = ultrasonic.read();

  Serial.print("Distance in CM: ");
  Serial.println(distance);
  delay(1000);
 

  if (distance > 5)
  {
      chase(strip.Color(255, 0, 0)); // Red
static void chase(uint32_t c) {
  for(uint16_t i=0; i<strip.numPixels()+4; i++) {
      strip.setPixelColor(i  , c); // Draw new pixel
      strip.setPixelColor(i-4, 0); // Erase pixel a few steps back
      strip.show();
      delay(50);
  }
}
}
}
void loop() {
  distance = ultrasonic.read();

  Serial.print("Distance in CM: ");
  Serial.println(distance);
  delay(1000);
 

  if (distance > 5)
  {
      chase(strip.Color(255, 0, 0)); // Red
static void chase(uint32_t c) {

No one else has been successful at fooling the C++ compiler into accepting a function defined inside another function. Looks like you are failing, too.

Why would you bother, when it so much simpler to simply define chase() OUTSIDE of loop()?