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

Custom operator parse error #225

Closed
nmote opened this issue Sep 7, 2022 · 3 comments
Closed

Custom operator parse error #225

nmote opened this issue Sep 7, 2022 · 3 comments

Comments

@nmote
Copy link
Contributor

nmote commented Sep 7, 2022


/!<5;

is now a syntax error with this parser, though it was not before. Swift parses this program successfully. Without the leading blank line, this parser accepts it:

/!<5;

The same thing occurs with the custom operator /!. Here is a complete program that is valid Swift, but is rejected by tree-sitter-swift (note the leading blank line):


/!5;

prefix operator /!;
prefix func /!(x: Int) {
    print(x)
}
@alex-pinkus
Copy link
Owner

Interesting, that would have been caused by #220. I have a suspicion that it’s because eat_comment will consume the / and foul up the rest of the state. If that’s the case, it shouldn’t be too bad to fix, we can just propagate that state forward a bit.

alex-pinkus added a commit that referenced this issue Sep 8, 2022
Fixes #225

This logic was not working properly when the whitespace handler
attempted to consume a slash already. To handle that, we give the
`eat_operator` function some more information about the surrounding
context, like a possible prior character that has been eaten.
@alex-pinkus
Copy link
Owner

Ok, merged in #227. Sorry for the breakage!

@nmote
Copy link
Contributor Author

nmote commented Sep 8, 2022

No worries at all! I doubt anybody but me noticed.

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

No branches or pull requests

2 participants