cppfront
cppfront copied to clipboard
[BUG] Disable UFCS on function named after variable being initialized with CTAD
trafficstars
See https://github.com/hsutter/cppfront/issues/550#issuecomment-1834594548:
There is another case that #506 doesn't yet cover (https://cpp2.godbolt.org/z/xj1P9cd66):
type_declaration: @struct type = { require: (this) = { } } require_fn: type == std::function<void(bool, std::string_view)>; array2: (inout t: type_declaration) = { require: std::optional = t.require(); _ = require; } main: () = { }main.cpp2:6:38: error: variable 'require' declared with deduced type 'std::optional' cannot appear in its own initializer 6 | std::optional require {CPP2_UFCS_0(require, t)}; | ^ main.cpp2:6:17: error: no viable constructor or deduction guide for deduction of template arguments of 'optional' 6 | std::optional require {CPP2_UFCS_0(require, t)}; | ^This is the same as https://github.com/hsutter/cppfront/issues/550#issuecomment-1698300918. Except that we can't easily identify that CTAD is required. Maybe a nested requirement such as
requires { typename std::optional; }might work to detect it.