-
Notifications
You must be signed in to change notification settings - Fork 24
Migrate all T::Struct usages to bare Ruby classes
#841
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
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: Alexandre Terrasa <alexandre.terrasa@shopify.com>
e91064c to
90bd8f6
Compare
Signed-off-by: Alexandre Terrasa <alexandre.terrasa@shopify.com>
Signed-off-by: Alexandre Terrasa <alexandre.terrasa@shopify.com>
Signed-off-by: Alexandre Terrasa <alexandre.terrasa@shopify.com>
Signed-off-by: Alexandre Terrasa <alexandre.terrasa@shopify.com>
Signed-off-by: Alexandre Terrasa <alexandre.terrasa@shopify.com>
Signed-off-by: Alexandre Terrasa <alexandre.terrasa@shopify.com>
Signed-off-by: Alexandre Terrasa <alexandre.terrasa@shopify.com>
Signed-off-by: Alexandre Terrasa <alexandre.terrasa@shopify.com>
Signed-off-by: Alexandre Terrasa <alexandre.terrasa@shopify.com>
90bd8f6 to
80a1d36
Compare
Signed-off-by: Alexandre Terrasa <alexandre.terrasa@shopify.com>
amomchilov
left a comment
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 guess if you migrated to Data.define instead, you'd need a whole bunch of RBI files just to specify the sigs, right?
T::Struct usages to bare Ruby classes
Indeed, Sorbet doesn't have a way to associate types to data fields yet. |
paracycle
left a comment
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 have a few minor comments, but looks good to me
| #: String | ||
| attr_reader :uri | ||
|
|
||
| #: Range |
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 quite confusing. Even though it probably resolves to LSP::Range, I still find it confusing to see a bare Range reference, and I assume it would be a reference to ::Range and not something else. Should we keep the namespace here?
| const :code, Integer | ||
| const :message, String | ||
| const :information, Object | ||
| #: Range |
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.
Same comment as above
| #: Location? | ||
| attr_reader :location | ||
|
|
||
| #: Range? |
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.
Same comment here, but I think the old code was similarly confusing.
| #: (SymbolPrinter printer) -> void | ||
| def accept_printer(printer) | ||
| h = serialize.hash | ||
| h = hash |
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.
Interesting! I am noticing this code now and I am not sure if this will always work the way you intend it to. The return value of hash isn't necessarily unique, so you can't rely on it (solely) for Set inclusion.
a.eql?(b)impliesa.hash == b.hash
from https://docs.ruby-lang.org/en/3.4/Object.html#method-i-hash
but the converse isn't necessarily true, i.e. a.hash == b.hash does not necessarily imply a.eql?(b).
Also enable
Sorbet/ForbidTStructcop after that.