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

Fix identical link generation prevention for the "Defined in" section (docs) #6489

Merged
merged 2 commits into from
Aug 6, 2018

Conversation

wooster0
Copy link
Contributor

@wooster0 wooster0 commented Aug 5, 2018

Follow-up of #6280.

Preventing duplicates in types.cr doesn't seems to work. See: Float32.
But it works now by preventing them in generator.cr.

@straight-shoota
Copy link
Member

Is there an exaplanation why the existing solution doesn't work as expected?

@straight-shoota
Copy link
Member

I guess, in the end it doesn't really matter though. The implementation is equivalent as it applies the correct result to Crystal::Doc::Type#location. So, as long as it works, it's fine by me.

Copy link
Member

@bcardiff bcardiff left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@r00ster91 same question @straight-shoota asked. Did you debug why the previous code was not preventing duplicates?

@wooster0
Copy link
Contributor Author

wooster0 commented Aug 6, 2018

Hmm I guess it's because at the time in the add_location method, the filename and line_number instance variables of the Location aren't yet correctly modified. But they are modified in the relative_location before the any?. For example here's how filename gets modified before the any? iteration:

filename = filename[1..-1] if filename.starts_with? File::SEPARATOR
filename = filename[4..-1] if filename.starts_with? SRC_SEP

And all these modifications of filename and line_number don't happen before the any? iteration in add_location. That's why it didn't work in add_location I think.

Copy link
Member

@sdogruyol sdogruyol left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @r00ster91 👍

@sdogruyol sdogruyol merged commit dbe03f2 into crystal-lang:master Aug 6, 2018
@sdogruyol sdogruyol added this to the 0.26.0 milestone Aug 6, 2018
@bcardiff bcardiff added kind:bug A bug in the code. Does not apply to documentation, specs, etc. and removed kind:refactor labels Aug 6, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind:bug A bug in the code. Does not apply to documentation, specs, etc. kind:docs topic:compiler
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants