Skip to content

CFE does not report an error when new is used in a non-constructor position with constructor tearoffs enabled #47075

Closed
@leafpetersen

Description

@leafpetersen

With constructor tearoffs enabled, the CFE correctly emits an error on the definition of the field in C in the code below, but issues no errors on the access of new on an instance of C and on foo in main. I believe that all of those should be an error. This causes a failure in co19/Language/Expressions/Instance_Creation/New/type_t05 (source here) when constructor tearoffs are enabled. See logs here . CL turning on the flag is here.

cc @eernstg @lrhn @johnniwinther @devoncarew

class C {
  int new = 42;
}

main() {
  new C().new is int;
  dynamic foo;
  foo.new;
  foo.new();
}

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions