Skip to content

[BUG] anonymous functions and things inside decltype should never be forward declared #485

Closed
@farmerpiki

Description

@farmerpiki

Describe the bug
I think anonymous functions should never be forward declared, and IMHO decltype should not be implied for them when using inside a type alias (and possibly other scenarios as well)

currently there's no usable equivalent to the cpp1 syntax for this that works
using pq_conn_ptr = std::unique_ptr<PGconn, decltype([](PGconn *ptr) { PQfinish(ptr); })>;

To Reproduce
Steps to reproduce the behavior:

  1. Sample code - distilled down to minimal essentials please
    I tried this instead
    pq_conn_ptr : type == std::unique_ptr<PGconn, decltype(: (ptr : *PGconn) = { PQfinish(ptr); })>;
    and using it just as
    p: pq_conn_ptr = ();
  2. Command lines including which C++ compiler you are using
    cppfront and g++-13 but I guess the issue would be with any compiler cause it's caused by the generated code
  3. Expected result - what you expected to happen
    I expected it to generate the above using declaration
  4. Actual result/error
    using pq_conn_ptr = std::unique_ptr<PGconn,decltype([](PGconn* ptr) -> void;)>;
    the error is that the body of the lambda is missing

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