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

end_line_number of Block can be wrong when passed to nested macro #10562

Open
matthewmcgarvey opened this issue Mar 30, 2021 · 1 comment
Open

Comments

@matthewmcgarvey
Copy link
Contributor

Bug Report

I'm trying to get the end_line_number of a Crystal::Macros::Block that is nested. It seems to return then ending line number as if it has removed all the ending newlines and comments from the block. This is not the case for non-nested blocks and it does not remove any empty or commented lines from the beginning of the block.

Example

macro line_numbers(&block)
  {{ block.body }}
  {{ block.end_line_number }}
end

end_line_number = nil
line_numbers do
  end_line_number = line_numbers do

    puts 1 + 1

  end
end

end_line_number = end_line_number.not_nil!
end_line_number == 12 || raise "Invalid end line, should be 12 but was #{end_line_number}"

Info

Crystal version: 1.0.0
OS: MacOS

@matthewmcgarvey
Copy link
Contributor Author

Came back to this to check if #11798 would fix it and it still raises the error. But... I'm also unsure if this is a real issue or not? end_line_number is 11, but if i call block.line_number I get 9 so I'm wondering if just getting what is between do...end is what is expected to take place.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants