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] UFCS macro broken given object v<a, b> #493

Closed
JohelEGP opened this issue Jun 5, 2023 · 2 comments · Fixed by #506
Closed

[BUG] UFCS macro broken given object v<a, b> #493

JohelEGP opened this issue Jun 5, 2023 · 2 comments · Fixed by #506
Labels
bug Something isn't working

Comments

@JohelEGP
Copy link
Contributor

JohelEGP commented Jun 5, 2023

Title: UFCS macro broken given object v<a, b>.

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

main: () -> int = std::variant<i8, i8>().index();
Commands:
cppfront -clean-cpp1 main.cpp2
clang++17 -std=c++23 -stdlib=libc++ -lc++abi -pedantic-errors -Wall -Wextra -Wconversion -I . main.cpp

Expected result:

Program returned: 0

Actual result and error:

[[nodiscard]] auto main() -> int { return CPP2_UFCS_0(index, std::variant<cpp2::i8,cpp2::i8>());  }
Cpp2 lowered to Cpp1.
#include "cpp2util.h"


[[nodiscard]] auto main() -> int;

[[nodiscard]] auto main() -> int { return CPP2_UFCS_0(index, std::variant<cpp2::i8,cpp2::i8>());  }

Output.

build/_cppfront/main.cpp:8:84: error: too many arguments provided to function-like macro invocation
    8 | [[nodiscard]] auto main() -> int { return CPP2_UFCS_0(index, std::variant<cpp2::i8,cpp2::i8>());  }
      |                                                                                    ^
raw.githubusercontent.com/hsutter/cppfront/main/include/cpp2util.h:705:9: note: macro 'CPP2_UFCS_0' defined here
  705 | #define CPP2_UFCS_0(FUNCNAME,PARAM1) \
      |         ^
@JohelEGP JohelEGP added the bug Something isn't working label Jun 5, 2023
@tsoj
Copy link

tsoj commented Oct 21, 2023

Also happens with [] braces, e.g:

Position: type = {
    operator[]: (this, p: int, c: int) -> int = 0;
}

main: () -> int = Position()[0, 0].abs();

(Relevant for C++23)

@JohelEGP
Copy link
Contributor Author

Yeah:

main.cpp2:5:74: error: too many arguments provided to function-like macro invocation
    5 | [[nodiscard]] auto main() -> int { return CPP2_UFCS_0(abs, Position()[0, 0]);  }
      |                                                                          ^

That's fixed by #506.

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.

2 participants