Skip to content

[BUG] Line number and formatting issues on generated that functions. #282

Closed
@gregmarr

Description

@gregmarr

Describe the bug
Generated .cpp file has incorrect #line numbers, misplaced braces, should be a newline between closing brace and next function. See inline comments for issue descriptions.

To Reproduce
regression-tests/pure2-types-that-parameters.cpp2

 1
 2 myclass : type = {
 3 
 4     operator=: (out this) = { }
 5 
 6     operator=: (out this, that) = {
 7         name = that.name;
 8         addr = that.addr;
 9     }
10
11    operator=: (out this, move that) = {
12        name = that.name;
13        addr = that.addr;
14    }

regression-tests/test-results/pure2-types-that-parameters.cpp

#line 1 "pure2-types-that-parameters.cpp2"

class myclass   {

    public: myclass()         
                              : name{ "Henry" }
                              , addr{ "123 Ford Dr." }
#line 5 "pure2-types-that-parameters.cpp2" // The following braces are from line 4, not 5
{} // Braces are at column 0 instead of normal indentation from function or at source column
    public: explicit myclass(myclass const& that)
        : name{ that.name }
        , addr{ that.addr }
#line 7 "pure2-types-that-parameters.cpp2" // The following brace is from line 6, not 7
{  // Brace is at column 0 instead of normal indentation from function or at source column

    }public: auto operator=(myclass const& that) -> void{name = that.name;addr = that.addr;}  // assignment operator follows immediately after closing brace with no whitespace, generated by line 6, but will be reported as line 9.  Assignments in body are from lines 7 and 8 but will be reported as line 9.  No whitespace inside function body.

    public: explicit myclass(myclass&& that)
        : name{ std::move(that).name }
        , addr{ std::move(that).addr }
#line 12 "pure2-types-that-parameters.cpp2" // The following brace is from line 11, not 12
{

    }public: auto operator=(myclass&& that) -> void{name = std::move(that).name;addr = std::move(that).addr;}  // assignment operator follows immediately after closing brace with no whitespace, generated by line 11, but will be reported as line 14.  Assignments in body are from lines 12 and 13 but will be reported as line 14

Expected something like this

#line 1 "pure2-types-that-parameters.cpp2"

class myclass   {

    public: myclass()         
                              : name{ "Henry" }
                              , addr{ "123 Ford Dr." }
#line 4 "pure2-types-that-parameters.cpp2"
        {}

    public: explicit myclass(myclass const& that)
        : name{ that.name }
        , addr{ that.addr }
#line 6 "pure2-types-that-parameters.cpp2"
                                  {

    }

#line 6 "pure2-types-that-parameters.cpp2"
    public: auto operator=(myclass const& that) -> void {
        name = that.name;
        addr = that.addr;
    }

    public: explicit myclass(myclass&& that)
        : name{ std::move(that).name }
        , addr{ std::move(that).addr }
#line 11 "pure2-types-that-parameters.cpp2"
                                      {

    }

#line 11 "pure2-types-that-parameters.cpp2"
    public: auto operator=(myclass&& that) -> void {
        name = std::move(that).name;
        addr = std::move(that).addr;
    }

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions