Skip to content

[BUG] Function initialized with == can't have _requires-clause_ #709

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

Closed
JohelEGP opened this issue Sep 27, 2023 · 1 comment · Fixed by #922
Closed

[BUG] Function initialized with == can't have _requires-clause_ #709

JohelEGP opened this issue Sep 27, 2023 · 1 comment · Fixed by #922
Labels
bug Something isn't working

Comments

@JohelEGP
Copy link
Contributor

Title: Function initialized with == can't have requires-clause.

Description:

This is similar to commit b1c03f2 and #675.
Although the refactor of the latter would've made the fix trivial.
Now what commit b1c03f2 did for aliases
needs to be done for functions
after the gift of commit b589f5d.

Minimal reproducer (https://cpp2.godbolt.org/z/4exaWaf53):

f: () -> int requires true == 0;
main: () = { }
Commands:
cppfront main.cpp2
clang++18 -std=c++23 -stdlib=libc++ -lc++abi -pedantic-errors -Wall -Wextra -Wconversion -Werror=unused-result -I . main.cpp

Expected result: A well-formed program.

Actual result and error:

main.cpp2...
main.cpp2(1,1): error: a function must have a body ('=' initializer), unless it is virtual (has a 'virtual this' parameter) or is defaultable (operator== or operator<=>)
@JohelEGP JohelEGP added the bug Something isn't working label Sep 27, 2023
@JohelEGP
Copy link
Contributor Author

A braced body does work (https://cpp2.godbolt.org/z/dadf8h4EM):

f: (_) -> int requires true == { return 0; }
main: () = { }

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

Successfully merging a pull request may close this issue.

1 participant