-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TypeHint for setter #12
Comments
Added yield parameter and option to `TypeHint`s Added typehint to `set`s so that the syntax is consistent, but added a TODO about static analysis. This PR should finish up the syntax, closes lukescott#1, and lukescott#12 (refs lukescott#19)
I added a TODO in the spec for the semantics behind this. Let's get some feedback from other spec writers regarding if it's needed. |
"Ensure setters are void" - does that mean you have to do: class Foo {
set value() void {
}
} If that's the case, shouldn't TypeHint be disallowed as a return on a setter? That would be more compatible with existing code. Also, shouldn't a getter and setter be required to use the same TypeHint? As in: This would be correct: class Foo {
get value() string {
return this._value;
}
set value(v string) {
this._value = v;
}
} But this would be invalid: class Foo {
get value() string {
return this._value;
}
set value(v number) {
this._value = v;
}
} I know this sort of type checking territory, but I ask because both methods share the same descriptor. |
The syntax allows empty, but if it's not empty, then it ensures that the return type is |
Should void even be allowed on setter? Is the |
I added it in for symmetry. I think it would be surprising if it were forbidden. |
Probably doesn't need an explicit
TypeHint
, but semantics could state that settings are implicitlyvoid
.The text was updated successfully, but these errors were encountered: