Understanding scope: error: 'void setup()' cannot be overloaded

I have this minimal C++ class which was working in Arduino IDE 1.8.2 but now in 1.8.7 it gives an error.

I can't have two function in the same scope which is called 'setup' but the other one in this example is inside a class and thus should be out of scope, or what?

In my project I just did a renamed s/setup/Setup/ and it was working again but I really want to know were the problem is.

class {
  public:
    void setup(void) {
      // stuff here
    }
} foo;

void setup() {
  foo.setup();
}

void loop() {
}

Works fine IDE 1.8.5
Same, your error, 1.8.6
Compiles and runs fine gcc 7.3
Compiles fine avr-gcc 8.1

Thanks,

DKWatson:
Same, your error, 1.8.6

So the conclusion is: A bug in the IDE?

A bug indeed. The prototype generator scattered the prototypes for setup() and loop() inside the class:

build_directory/sketch/boo.ino.cpp

#include <Arduino.h>
#line 1 "/private/tmp/rjl/boo/boo.ino"
#line 1 "/private/tmp/rjl/boo/boo.ino"
class {
  public:
#line 8 "/private/tmp/rjl/boo/boo.ino"      //   <<   OOPS!
void setup();                               //   <<
#line 12 "/private/tmp/rjl/boo/boo.ino"     //   <<
void loop();                                //   <<
#line 3 "/private/tmp/rjl/boo/boo.ino"
    void setup(void) {
      // stuff here
    }
} foo;

void setup() {
  foo.setup();
}

void loop() {
}

Does somebody report this?

Reported: Non-class function prototypes are sometimes inserted inside class definition. · Issue #292 · arduino/arduino-builder · GitHub

Works fine in IDE 1.9.0-beta-Windows
Thanks!