FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

[BUG] Bad generated cpp1 for is constraints on wildcarded parameters · Issue #1229 · hsutter/cppfront · GitHub

[BUG] Bad generated cpp1 for is constraints on wildcarded parameters #1229

Description

67c665c introduces the possibility of constraining the wildcarded type with concepts. It works correctly for concepts taking one argument but fail for concepts taking two (or more) arguments.

E.g. for the following code:

fun: (x: _ is std::convertible_to<bool>) = {
    if x {
        std::cout << "true" << std::endl;
    } else {
        std::cout << "false" << std::endl;
    }
}

main: () = {
    fun(true);
}

cppfront generates the following code (clean-cpp1 version):

#include "cpp2util.h"


auto fun(auto const& x) -> void
CPP2_REQUIRES (std::convertible_to<bool><CPP2_TYPEOF(x)>) ;

auto main() -> int;
auto fun(auto const& x) -> void
requires (std::convertible_to<bool><CPP2_TYPEOF(x)>) {
    if (x) {
        std::cout << "true" << std::endl;
    }else {
        std::cout << "false" << std::endl;
    }
}

auto main() -> int{
    fun(true);
}

The bug is in the generated require clause, which is generated in the following way:

requires (std::convertible_to<bool><CPP2_TYPEOF(x)>) {

And it should be generated in the following way:

requires (std::convertible_to<CPP2_TYPEOF(x), bool>) {

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions


      Back | FazBrowse Home | New Git URL