-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Parser: fix wrong/missing locations of various AST nodes #11798
Conversation
`else_location` should be `nil` if `else` block is not present.
For example: a, b = 1, 2 if 3
For example: abstract def foo(x)
For example: ::foo
For example: foo.[0] = 1
For example: x : Foo(A, *B, C)
For example: Int[8]?
For example: [1, 2,]
For example: foo( &.block )
For example: foo.bar(x) do; end
For example: %w(one two)
For example: {% if foo bar end %}
For example: foo bar, out baz
For example: Foo?
For example: foo : Foo.class foo : Foo? foo : Foo* foo : Foo** foo : Foo[42]
For example: foo ->bar(Baz)
For example: Foo { 1 }
For example: foo.!
For example: f.x = foo
For example: x : Foo -> Bar
spec/compiler/parser/parser_spec.cr
Outdated
end_loc = node.end_location.not_nil! | ||
end_loc.line_number.should eq(line_number) | ||
end_loc.column_number.should eq(column_number) | ||
source_between(string, loc, end_loc).should eq(source) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the purpose of this expectation? I don't see how the source string comparison adds any relevant information to just the end location.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It’s useful for checking if the start location is set correctly (so maybe I should move this to a separate test). However, I think the string comparison is easier to understand at a glance than line/column numbers (when the test fails), so perhaps we can delete the number comparisons altogether?
Where does the internal compiler error come from? |
Could this make it into 1.7.0, pretty please? :) |
CI is 💚 , 2nd review anyone? |
I've included examples in tests and commit description, but if you want I can split this PR into multiple PRs.