You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Spec of instance variable initializers (§15.11.3) does not seem to exclude extern constructors, i.e., it sounds like extern constructors should perform variable initializers as well.
I think the spec should exclude extern constructors from the wording - the compiler cannot perform the initializers when an extern constructor is used since it doesn't control its code. (Indeed, the roslyn implementation doesn't perform the initializers.)
Note also that if you have a single constructor which is extern, then all variable initializers are not emitted anywhere, so they are useless. But there is no warning about that - should one be added to the language? For example:
classC{intX=5;// the initializer has no effect on the produced assemblyexternC();}
Related issue for static extern constructors: #158
The text was updated successfully, but these errors were encountered:
After discussion... we can't require the extern constructor to do anything in particular; we could potentially warn if there is a field initializer in a type which only has extern constructors. (There are reasons why you might want to have field initializers and extern constructors, if you also have normal constructors.)
We think we don't need to specify such a warning though, as warnings are generally non-normative.
But we agree that 15.11.3 should exclude requirements for extern constructors. I'll see how minimally we can make this change, and try to cover #158 at the same time.
Spec of instance variable initializers (§15.11.3) does not seem to exclude
extern
constructors, i.e., it sounds likeextern
constructors should perform variable initializers as well.I think the spec should exclude
extern
constructors from the wording - the compiler cannot perform the initializers when anextern
constructor is used since it doesn't control its code. (Indeed, the roslyn implementation doesn't perform the initializers.)Note also that if you have a single constructor which is
extern
, then all variable initializers are not emitted anywhere, so they are useless. But there is no warning about that - should one be added to the language? For example:Related issue for static extern constructors: #158
The text was updated successfully, but these errors were encountered: