Open dutkalex opened 1 month ago
I'm definitely in favour of clear, friendly error messages. But instead of requiring all data members to have default initializers, I'd prefer the error to be something like: A value type must be default constructible
. Then the user can choose to either add a default constructor or to add data member initializers.
Hi folks! I ran into a very confusing bug while experimenting with cppfront. Consider the following type:
Cppfront refuses to compile this code snippet and produces the following error message:
However, there is nothing wrong with the
operator=
here. The problem is actually that a value type must be default constructible, which is not the case in this example. This error message got me very confused at first, and I had to look into the sources to understand what was going on. Maybe the missing piece to get a better diagnostic is to require all data members of@value
types to be declared with a default initializer. What do you think of this? I'd be happy to submit a PR to fix this in the definition of the@value
metaclass, but I'd rather make sure that my analysis is correct first.Best regards, Alex