Skip to content

[BUG] public non-this data member has no effect #336

@JohelEGP

Description

@JohelEGP

public this: is disallowed. But before a this data member, a public non-this data member is not diagnosed, and has no effect.

Minimal reproducer:

x: type = { }
y: type = { }
z: type = {
  public a: x = x();
  this: y = ();
  operator=: (out this) = { }
}
w: x = z().a;

Commands:

cppfront x.cpp2
clang++17 -std=c++2b -stdlib=libc++ -I $CPPFRONT_INCLUDE_DIR x.cpp

Expected result: A well-formed program, or a diagnostic.

Actual result and error:

Generated C++1
//=== Cpp2 type declarations ====================================================


#include "cpp2util.h"

#line 1 "x.cpp2"
class x;
class y;
class z;

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

#line 1 "x.cpp2"
class x {};
class y {};
class z: private cpp2::store_as_base<"a",x>, public y {

#line 6 "x.cpp2"
  public: z();
};
extern x w;
//=== Cpp2 function definitions =================================================


#line 6 "x.cpp2"
  z::z()
                            : cpp2::store_as_base<"a",x>{ x() }
#line 6 "x.cpp2"
  {}

x w {z().a}; 
x.cpp2:8:10: error: no member named 'a' in 'z'
x w {z().a}; 
     ~~~ ^
1 error generated.

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