8000 Make hover tests stricter, add type narrowing test, fix up proc hover. by jvilk-stripe · Pull Request #902 · sorbet/sorbet · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Make hover tests stricter, add type narrowing test, fix up proc hover. #902

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

Merged
merged 1 commit into from
Jun 20, 2019

Conversation

jvilk-stripe
Copy link
Collaborator
@jvilk-stripe jvilk-stripe commented Jun 19, 2019

Make hover tests stricter, add a type narrowing test, fix up proc hover.

This change makes hover tests match against whole lines and not just a substring of the entire hover contents.

Motivation

Without this change, I can't assert that something is String and not T.nilable(String).

This change also surfaced a bug in hover on proc arguments. We had a test that was passing when it should have been failing.

Test plan

See included automated tests.

(Proc hover tests were passing before w/o the strict checks, but should have failed.)
@jvilk-stripe jvilk-stripe changed the title Make hover tests stricter, add type narrowing checks, fix up proc hover. Make hover tests stricter, add type narrowing test, fix up proc hover. Jun 19, 2019
@@ -334,7 +334,7 @@ BasicBlock *CFGBuilder::walk(CFGContext cctx, ast::Expression *what, BasicBlock
InlinedVector<core::LocalVariable, 2> idxVec{idxTmp};
InlinedVector<core::Loc, 2> locs{zeroLengthLoc};
bodyBlock->exprs.emplace_back(
argLoc, zeroLengthLoc,
argLoc, arg.loc,
Copy link
Collaborator Author
@jvilk-stripe jvilk-stripe Jun 19, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When I updated this code before, I thought that the loc query for arg.loc would get argLoc -- the local variable representing the argument. However, it does not because no cfg::Ident expression is added to the method.

As a hack, I've changed this Send binding (which is args[i]) to use arg.loc so it gets picked up instead. The hover for proc argument is now sig {returns(type-of-arg)}, which is more correct than before but not ideal.

Copy link
Collaborator Author
@jvilk-stripe jvilk-stripe Jun 19, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I can figure out that a cfg::Send has a block argument, and if I can get the types+locs of its parameter declarations, I could possibly do this the right way and match against the parameter in Environment::processBindings.

Is that possible in cfg?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jvilk-stripe I think you're looking for LoadYieldArg instruction

Copy link
Collaborator
@DarkDimius DarkDimius left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, feel free to either land it as is or follow your ideas in #902 (comment)

@jvilk-stripe
Copy link
Collaborator Author

Going to land as-is and follow up with improvements.

@jvilk-stripe jvilk-stripe merged commit 027bb5c into master Jun 20, 2019
@jvilk-stripe jvilk-stripe deleted the jvilk-better-hover-tests-and-fix-proc branch June 20, 2019 16:16
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.

2 participants
0