Skip to content

[BUG] Disable UFCS on template function with non-template local (g:=0; x.g<>();) #889

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 13, 2023 · 0 comments
Labels
bug Something isn't working

Comments

@JohelEGP
Copy link
Contributor

See #807 (comment):

The one case we can handle is when source local name lookup results in a variable.
If it isn't templated, func<targs>(obj) can't be valid, so the only option is the member call.
See https://cpp2.godbolt.org/z/T6sdezYKh:

t: @struct type = {
  f: <T> (this) = { }
  g: <T> (this) = { }
}
main: () = {
  t().f<int>(); // OK.

  g := 0;
  // error: 'g' does not name a template but is followed by template arguments
  t().g<int>();
  _ = g;
}
auto main() -> int{
  CPP2_UFCS_TEMPLATE(f<int>)(t());// OK.
  auto g {0}; 
  CPP2_UFCS_TEMPLATE(g<int>)(t());// S
  static_cast<void>(std::move(g));
}
main.cpp2:10:22: error: 'g' does not name a template but is followed by template arguments
   10 |   CPP2_UFCS_TEMPLATE(g<int>)(t());
      |                      ^~~~~~
raw.githubusercontent.com/hsutter/cppfront/main/include/cpp2util.h:855:84: note: expanded from macro 'CPP2_UFCS_TEMPLATE'
  855 | #define CPP2_UFCS_TEMPLATE(...)                           CPP2_UFCS_(&,(),template,__VA_ARGS__)
      |                                                                                    ^~~~~~~~~~~
raw.githubusercontent.com/hsutter/cppfront/main/include/cpp2util.h:845:51: note: expanded from macro 'CPP2_UFCS_'
  845 |   noexcept(CPP2_UFCS_IS_NOTHROW_ARG(QUALID,TEMPKW,__VA_ARGS__)) CPP2_FORCE_INLINE_LAMBDA -> decltype(auto) \
      |                                                   ^~~~~~~~~~~
raw.githubusercontent.com/hsutter/cppfront/main/include/cpp2util.h:803:90: note: expanded from macro 'CPP2_UFCS_IS_NOTHROW_ARG'
  803 | #define CPP2_UFCS_IS_NOTHROW_ARG(QUALID,TEMPKW,...)   CPP2_UFCS_IS_NOTHROW(QUALID,TEMPKW,__VA_ARGS__)
      |                                                                                          ^~~~~~~~~~~
raw.githubusercontent.com/hsutter/cppfront/main/include/cpp2util.h:801:60: note: expanded from macro 'CPP2_UFCS_IS_NOTHROW'
  801 |               requires noexcept(CPP2_UFCS_REMPARENS QUALID __VA_ARGS__(std::declval<Obj>(), std::declval<Params>()...)); }
      |                                                            ^~~~~~~~~~~
main.cpp2:8:8: note: non-template declaration found by name lookup
    8 |   auto g {0}; 
      |        ^
@JohelEGP JohelEGP added the bug Something isn't working label Dec 13, 2023
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