-
Notifications
You must be signed in to change notification settings - Fork 27
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
ForbidTStruct handles nilable properties #180
Conversation
Signed-off-by: Alexandre Terrasa <alexandre.terrasa@shopify.com>
sig { returns(Integer) } | ||
attr_accessor :baz | ||
|
||
sig { params(baz: Integer, foo: T.nilable(Integer), bar: T.nilable(String)).void } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not clear why we need to change the argument order here if only dealing with keyword arguments?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Order is kept for keyword arguments foo
and bar
. Only baz
is moved earlier.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a rule within Sorbet, required keyword parameters must be before the optional ones: https://sorbet.run/#%23%20typed%3A%20true%0Aextend%20T%3A%3ASig%0A%0Asig%20%7Bparams%28x%3A%20Integer%2C%20y%3A%20Integer%29.void%7D%0Adef%20foo%28x%3A%2042%2C%20y%3A%29%0A%20%20puts%28x%20%2B%201%29%0Aend
sig { returns(Integer) } | ||
attr_accessor :baz | ||
|
||
sig { params(baz: Integer, foo: T.nilable(Integer), bar: T.nilable(String)).void } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Order is kept for keyword arguments foo
and bar
. Only baz
is moved earlier.
I fixed the typo in the PR title in case anyone is searching for this. |
Closes #179.