Open AnthonyLatsis opened 11 months ago
seems like a simple update to an error message? @AnthonyLatsis can I take this one?
seems like a simple update to an error message?
Not this time. Actually, that’s almost never the case, even when a bug report is labeled as https://github.com/apple/swift/labels/good%20first%20issue and requests an improvement to a specific diagnostic message. For those sorts of issues, we expect the contributor to have practical experience with or research the associated feature, come up with an improvement to the message and back it up with a rationale.
can I take this one?
Yes, if you feel like you can manage working on two issues at once.
Not this time. Actually, that’s almost never the case, even when a bug report is labeled as good first issue and requests an improvement to a specific diagnostic message.
So this is not something simple? The improvement to the message was added by you, so do I need to have practical experience or research with this update?
So this is not something simple?
I make this as one of the harder beginner issues. Knowledge of property wrapper semantics is required, and prior experience in this area of the compiler is a bonus that would facilitate learning and reduce guesswork.
For reference, I think the property wrapper in the example is malformed and that we should diagnose it rather than uses of it.
The improvement to the message was added by you
My example is just a proposition; it can be disputed, refined, or left as is, but rationalization on either course of action is expected.
Knowledge of property wrapper semantics is required
Since I have pretty much 0 knowledge with this area of the compiler, I will take a pass on this. I was looking for a simple issue that has to do with error
messages and updates to see how it all works.
Or another diagnostic may be something like:
error: "missing argument label in call (expected 'i:')" fixit: "insert 'i:'?"
@Wrapper var w: Int = 0
since @Wrapper(i: 0) var w: Int
is valid as well
This seems to be somewhat similar to https://github.com/apple/swift/issues/68570. There are some parts in the compiler where it assumes that there's init(wrappedValue:)
in the property wrapper, but doesn't emit enough information when it goes missing.
I'd like to work on this if there aren't any other ongoing work on this :)
since
@Wrapper(i: 0) var w: Int
is valid as well
Good point, I didn’t know init(wrappedValue:)
is not a hard requirement in the absence of a default initializer. Then I think we need a tailored error message stating that this property wrapper initialization strategy only works with initializers that have a wrappedValue
parameter, and a conditional fix-it to direct users to the correct initialization strategy when a different initializer can be called with the initial value alone.
Steps to reproduce
Expected behavior
For example,
property wrapper type must provide an initializer with either no parameters or a first parameter with argument label 'wrappedValue'
.Environment