-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Lexer returning wrong line number when block strings are used #2054
Comments
Took a crack at it in #2056. I wonder what we can do about that On the one hand, you could change the Node class so that Another option would be to extend the definition nodes to include references to the original tokens, for example Maybe a better approach would be, rather than exposing tokens, just to expose |
On second thought, I think you're right. If the type definition has a description, that is technically the first line where the type is defined. I don't have any preference between adding |
I think this was fixed, not sure why it was reopened. |
I was debugging an issue in which a schema that was built from a schema dump (
Schema.from_definition
) had seemingly wrong values forast_node.line
.I managed to pinpoint this to a bug in the Lexer when parsing block strings.
Repro script:
Output:
I'd expect the second token (
(TYPE "type" [3:1])
) to be(TYPE "type" [5:1])
.I dug into
lexer.rl
for a few minutes and I suspect the problem is that we aren't incrementingmeta[:line]
when emitting a:STRING
token. Typically,meta[:line]
gets incremented whenever the lexer sees aNEWLINE
, but this won't account for new lines that are within the block string.Once this is fixed, my second concern is, given the code below, what line should we be reporting:
Before, when descriptions were comments, the line returned by
ast_node.line
would be thetype
token'sline
. Since we introduced block strings, the line reported would be the one where the description starts. While this might be correct, it is somewhat of a breaking change for tools that rely on these line numbers (like linters).The text was updated successfully, but these errors were encountered: