Skip to content

[BUG] <...> lowers to unnamed pack #708

Closed

Description

@JohelEGP

Title: <...> lowers to unnamed pack.

Description:

Since commit 025d7af, ... is an identifier.
So ... in a template-parameter-declaration-list lowers to typename ...,
just like T would lower to typename T.

Feature or bug?
I call bug.
#603 makes it so that template template parameters are emitted.
Because it chooses to lower them unnamed, it lowers T: <...> to template<typename> class T.
The existing branch in main to print a pack's ellipsis,
if (n.declaration->is_variadic) { (https://github.com/hsutter/cppfront/pull/603/files#diff-e683e1259bbc0d6de7f1fbf797fb772f31a0a1ef2254ec317d15c298102fa3f3R3931)
isn't exercised because it the declaration isn't variadic (it's name just happens to be ...).

Minimal reproducer (https://cpp2.godbolt.org/z/YbzMc3dh3):

f: <...> () = { }
main: () = { }
Commands:
cppfront main.cpp2
clang++18 -std=c++23 -stdlib=libc++ -lc++abi -pedantic-errors -Wall -Wextra -Wconversion -Werror=unused-result -I . main.cpp

Expected result: A diagnostic due to naming a declaration ....

Actual result and error:

Program returned: 0
template<typename ...> auto f() -> void{}
Cpp2 lowered to Cpp1:
//=== Cpp2 type declarations ====================================================


#include "cpp2util.h"



//=== Cpp2 type definitions and function declarations ===========================

template<typename ...> auto f() -> void;
auto main() -> int;


//=== Cpp2 function definitions =================================================

template<typename ...> auto f() -> void{}
auto main() -> int{}

Activity

  1. JohelEGP commented on Sep 26, 2023

    @JohelEGP
    ContributorAuthor

    A simpler reproducer (https://cpp2.godbolt.org/z/Kf8fdWz95):

    main: () = {
      ...: int = 0;
    }
    
    auto main() -> int{
      int ... {0}; 
    }
  2. hsutter commented on Sep 28, 2023

    @hsutter
    Owner

    Thanks! Yes, that's a bug... fixing now...

  3. added a commit that references this issue on Dec 5, 2023
    385e205
  4. added a commit that references this issue on Feb 4, 2024
    673e232
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions