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

[BUG] `@print` shortcomings · Issue #840 · hsutter/cppfront · GitHub

[BUG] @print shortcomings #840

Description

Title: Single-expression functions print with extra semicolon.

Description:

This makes the printed code invalid Cpp2:

example.cpp2(4,51): error: a single-expression function should end with a single semicolon (at ';')

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

#include <functional>
t: @struct @print type = {
  x: std::function<void()> = :() = _ = 0;
  y: std::function<void()> = :() 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: Printed Cpp2 code to be valid.

Actual result and error: public x: std::function<void()> = :() = _ = 0;;.

Cpp2 lowered to Cpp1:
//=== Cpp2 type declarations ====================================================


#include "cpp2util.h"


class t;
  

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

#include <functional>
class t {
  public: std::function<void()> x {[]() -> void { static_cast<void>(0);  }}; 
  public: std::function<void()> y {[]() -> auto { return 0;  }}; 
};
auto main() -> int;

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


auto main() -> int{}
Output:
main.cpp2...

t: type = 
{
    public x: std::function<void()> = :() = _ = 0;;

    public y: std::function<void()> = :() -> move _ = 0;;
}
 ok (mixed Cpp1/Cpp2, Cpp2 code passes safety checks)

See also:

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