-
Notifications
You must be signed in to change notification settings - Fork 1.5k
Open
Labels
examples-2026An issue that is relevant for examples we are trying to port to Carbon in 2026.An issue that is relevant for examples we are trying to port to Carbon in 2026.leads questionA question for the leads teamA question for the leads team
Description
The testcase where I encountered this involves an explicit default constructor:
import Cpp inline '''
struct A {
explicit A();
A(const A&) = delete;
};
''';
var a: Cpp.A = ();Currently we reject this, with a confusing error:
<source>:7:1: error: attempt to use a deleted function
7 | var a: Cpp.A = ();
| ^
<source>:4:5: note: 'A' has been explicitly marked deleted here
4 | A(const A&) = delete;
| ^
<source>:7:1: error: cannot implicitly convert expression of type `()` to `Cpp.A`
var a: Cpp.A = ();
^~~~~~~~~~~~
<source>:7:1: note: type `()` does not implement interface `Core.ImplicitAs(Cpp.A)`
var a: Cpp.A = ();
^~~~~~~~~~~~The reason we reject is because C++ copy-initialization from {} is invalid because it would use an explicit constructor.
However, this leaves us with no easy way to provide initialization with the same semantics as C++'s
A a;... which does permit calling an explicit default constructor. Should we have an ergonomic way to do that? Should the conversion from () do that?
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
examples-2026An issue that is relevant for examples we are trying to port to Carbon in 2026.An issue that is relevant for examples we are trying to port to Carbon in 2026.leads questionA question for the leads teamA question for the leads team