hsutter / cppfront

A personal experimental C++ Syntax 2 -> Syntax 1 compiler
Other
5.24k stars 223 forks source link

[BUG] An `in` parameter in a statement scope does not work with CTAD #1003

Open bluetarpmedia opened 4 months ago

bluetarpmedia commented 4 months ago

Describe the bug CTAD does not appear to work with cpp2::in when using a parameter in a statement scope.

To Reproduce Run cppfront on this code (which is similar to #1002):

main: () -> int = {

    m : std::mutex = ();

    (_: std::unique_lock = (m))
    {

    }

    _ = m.native_handle();  // Workaround for bug #968

    return 0;
}

After compiling with clang it results in an error:

main.cpp2:5:32: error: use of class template 'std::unique_lock' requires template arguments
    5 | [[maybe_unused]] cpp2::in<std::unique_lock> unnamed_param_1{m};
      |                                ^

Repro on Godbolt