Skip to content
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

Report more "unexpected bare value" errors #7887

Merged
merged 3 commits into from
May 15, 2024
Merged

Report more "unexpected bare value" errors #7887

merged 3 commits into from
May 15, 2024

Conversation

jez
Copy link
Collaborator

@jez jez commented May 14, 2024

Motivation

While helping a user attempt to write some code today, I noticed that they had
this in their code and it did the right thing statically but only worked at
runtime because generics are erased (T::Array[x]). Had they attempted to do
something similar with T.class_of or T.any or something else, it would not
have done the thing they hoped it would have.

Ideally an even better error message would include something like an autocorrect
like "Did you meant to explicitly annotate this value's type here?" and offer to
replace x in the test with T.type_parameter(:U), or whatever the type of x
is. That isn't always going to be the right suggestion, but it will at least get
the user closer to understanding what the problem is.

Test plan

See included automated tests.

@jez jez requested a review from a team as a code owner May 14, 2024 20:11
@jez jez requested review from froydnj and removed request for a team May 14, 2024 20:11
@jez
Copy link
Collaborator Author

jez commented May 14, 2024

We have a policy of testing changes to Sorbet against Stripe's codebase before
merging them. I've kicked off a test run for the current PR. When the build
finishes, I'll share with you whether or how it failed. Thanks!

Stripe employees can see the build results here:

https://go/builds/bui_Q6f3GZMJfpyBAv
https://go/builds/bui_Q6f3FuQSzgatfj
https://go/builds/bui_Q6f3iBy7i1Dkg2

@jez jez merged commit 2d68c38 into master May 15, 2024
16 checks passed
@jez jez deleted the jez-unwrap-type branch May 15, 2024 22:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants