jamesjuett / lobster

Interactive Program Visualization Tools
8 stars 3 forks source link

Check matching return type on separate function definitions using a qualified name #322

Open jamesjuett opened 2 years ago

jamesjuett commented 2 years ago

It appears that separate function definitions that use a qualified name (including but not limited to out-of-line member function definitions) do not properly check that the return type of the defined function matches the return type present on the declaration of the same signature.

Interestingly, a definition using an unqualified name does appear to check correctly, so I'm inclined to think the problem has to do with the name being qualified in the definition rather than the specific case of an out-of-line member function definition.

#include <iostream>
#include <string>

using namespace std;

void foo();
void bar();

int foo() {
  return 3;
}

int ::bar() {
  return 3;
}

class Test {
public:
  void blah();
  string bleh();
};

int Test::blah() {
  return 3;
}

const char * Test::bleh() {
  return "test";
}

int main() {
  cout << "Hello World!" << endl;
}

image