Skip to content

[BUG] Disable UFCS on function named after variable being initialized with CTAD #864

Open
@JohelEGP

Description

@JohelEGP

See #550 (comment):

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 #550 (comment).
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.

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