Skip to content

Show docs for callback with multiple clauses #8553

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

Merged
merged 5 commits into from
Jan 2, 2019

Conversation

wojtekmach
Copy link
Member

No description provided.

@@ -211,6 +215,8 @@ defmodule Kernel.DocsTest do
callback_bar,
callback_baz,
callback_foo,
callback_qux,
callback_qux,
Copy link
Member Author

Choose a reason for hiding this comment

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

this is still not right, we should get the callback only once in the chunk. I couldn't figure out how to deduplicate it so assistance would be appreciated!

Copy link
Member

Choose a reason for hiding this comment

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

According to my understand of the code this should be correct. So maybe we have something in elixir_erl.erl that is duplicating it again?

Copy link
Member Author

@wojtekmach wojtekmach Dec 30, 2018

Choose a reason for hiding this comment

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

@josevalim Good call. I noticed the issue in elixir_erl and fixed it, but I couldn't come up with a nicer solution yet. See: a0869d3. Will keep at it.

{line, doc} = get_doc_info(set, :doc, line)
store_doc(set, kind, name, arity, line, :doc, doc, %{})
# store doc only once in case callback has multiple clauses
unless :ets.member(set, {kind, name, arity}) do
Copy link
Member

Choose a reason for hiding this comment

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

Just checking: is this still necessary with the new fix?

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, still needed.

@@ -318,7 +318,23 @@ typespecs_form(Map, TranslatedTypespecs, MacroNames) ->
Forms1 = types_form(Types, Forms0),
Forms2 = callspecs_form(spec, Specs, [], MacroNames, Forms1, Map),
Forms3 = callspecs_form(callback, AllCallbacks, OptionalCallbacks, MacroCallbackNames, Forms2, Map),
{Types, AllCallbacks, Forms3}.
AllCallbacks2 = typespecs_back_to_callbacks(Forms3),
Copy link
Member

Choose a reason for hiding this comment

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

Are we doing this because of duplicates in AllCallbacks? If so, maybe it would be better to call lists:uniq or lists:usort in callbacks?

Copy link
Member Author

Choose a reason for hiding this comment

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

Good call, I'm now stripping spec information from callbacks and usorting them, check out latest commit.


{Kind, FA, Line, Rest}.
AllCallbacksWithoutSpecs = [
{Kind, NameArity, Line} || {Kind, NameArity, Line, _Spec} <- AllCallbacks
Copy link
Member

Choose a reason for hiding this comment

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

We don't seem to use the Line later on? So maybe we should return {Kind, Name, Arity} and usort on that.

Copy link
Member Author

Choose a reason for hiding this comment

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

Good call, fixed.

@michalmuskala michalmuskala merged commit ca40d15 into elixir-lang:master Jan 2, 2019
@michalmuskala
Copy link
Member

Thank you! ❤️

@wojtekmach wojtekmach deleted the wm-multiple-clauses branch January 2, 2019 13:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

3 participants