Skip to content

Surrounding pair problem in error python code #712

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

Closed
AndreasArvidsson opened this issue May 31, 2022 · 3 comments · Fixed by #1558
Closed

Surrounding pair problem in error python code #712

AndreasArvidsson opened this issue May 31, 2022 · 3 comments · Fixed by #1558
Assignees
Labels
bug Something isn't working

Comments

@AndreasArvidsson
Copy link
Member

def funk(words:list<str>):
take pair in <str> doesn't work

@auscompgeek
Copy link
Member

Isn't that invalid Python? list[str] would be a valid type hint.

@pokey
Copy link
Member

pokey commented Jun 2, 2022

Yes, but the idea behind surrounding pairs is that they should work no matter what

@pokey
Copy link
Member

pokey commented Jun 2, 2022

The problem here is that tree-sitter is seeing this < as a less-than operator. We have code that tries to discard < as a paired delimiter if it is being used as the less-than operator, so that you don't get trapped by things like if (foo < bar).

We do avoid doing this if the < token is an error node, but in this case tree-sitter actually doesn't treat this < as an error node; it doesn't decide there's an error until it sees the >

The example described in this issue is obviously fairly odd-ball code, but @AndreasArvidsson maybe it would make sense to just take a swing at implementing #673 using a new experimental modifier type. Then it's well-contained and feature flagged, so you can see if you can get something robust working. I do think you'll need to think about the less-than case, but who knows, maybe there's a stack of heuristics that will end up being more predictable than what we have today. As long as it's in its own modifier stage and protected by a feature flag, I'm happy for you to go wild. One of the benefits of the new, more modular approach

You might want to wait for the newer scope type setup, though, so you don't have to worry about ranges. I'm hoping we can get that working in #629

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
3 participants