Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
JohelEGP opened this issue Dec 3, 2023 · 0 comments
Labels
bug Something isn't working

Comments

@JohelEGP
Copy link
Contributor

JohelEGP commented Dec 3, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant