Skip to content
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

[BUG] fix(parse): diagnose function expression without initializer #1310

Open
JohelEGP opened this issue Oct 11, 2024 · 0 comments
Open

[BUG] fix(parse): diagnose function expression without initializer #1310

JohelEGP opened this issue Oct 11, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@JohelEGP
Copy link
Contributor

Title: fix(parse): diagnose function expression without initializer

Description:

I tried writing a function type,
but accidentally put a : in front.

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

require_fn: type == std::function<:(copy b: bool, copy s: std::string) -> void>;
main: () = { }
Commands:
cppfront main.cpp2
clang++-18 -std=c++26 -stdlib=libc++ -lc++abi -pedantic-errors -Wall -Wextra -Wconversion -Werror=unused-result -Werror=unused-value -Werror=unused-parameter -Werror=unused-variable -I . main.cpp

Expected result: A diagnostic to drop the : or add an = initializer.

Actual result and error:

using require_fn = std::function<>;
Cpp2 lowered to Cpp1:
//=== Cpp2 type declarations ====================================================


#include "cpp2util.h"



//=== Cpp2 type definitions and function declarations ===========================

using require_fn = std::function<>;
auto main() -> int;

//=== Cpp2 function definitions =================================================


auto main() -> int{}
Output:


//=== Cpp2 type declarations ====================================================


#include "cpp2util.h"



//=== Cpp2 type definitions and function declarations ===========================

using require_fn = std::function<>;
auto main() -> int;

//=== Cpp2 function definitions =================================================


auto main() -> int{}
@JohelEGP JohelEGP added the bug Something isn't working label Oct 11, 2024
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