Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nested lambdas yield broken tokens #3

Closed
Alcaro opened this issue May 16, 2018 · 2 comments
Closed

Nested lambdas yield broken tokens #3

Alcaro opened this issue May 16, 2018 · 2 comments
Labels
bug Something isn't working

Comments

@Alcaro
Copy link

Alcaro commented May 16, 2018

Found this on LLVM Weekly. Neat project.

Unfortunately, lambda handling seems quite buggy. For example:

void x()
{
  auto a = [](){
    [](){};
  };
}
void x()
{

   class __lambda_3
   {
     public: inline /*constexpr */ void operator()() const
     {
       __lambda_4;
     }
     
   };
   
   
   class __lambda_4
   {
     public: inline /*constexpr */ void operator()() const
     {
     }
     
   };
   
     __lambda_3 a = __lambda_4{}da_3{};
}

I'm not sure what __lambda_3; in operator() is supposed to do, and __lambda_4{}da_3{} is nonsense.

I suspect you're replacing the substring at [4,7) with something longer, then doing another replacement on the same line, without adjusting the offsets to account for the previous replacement. This yields lots of strange output (another example: removing auto a = makes it emit lambdas in the output), but I think most or all of it is all the same root cause.

(Additionally, two lambdas on the same line expand to two classes with the same name. Append column number to subsequent ones, maybe?)

@andreasfertig
Copy link
Owner

Thanks for reporting. It looks like the matcher matches twice. Column number is a excellent idea. I like to keep the name stable, hence the line number. Adding the column number to it should make it more robust. I will look into that.

@andreasfertig andreasfertig added the bug Something isn't working label May 19, 2018
@Alcaro
Copy link
Author

Alcaro commented Jun 10, 2018

Yep, looks good to me, I can no longer produce any non-compiling output.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants