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

** (FunctionClauseError) no function clause matching in Earmark.Helpers.AstHelpers.augment_tag_with_ial/2 #340

Closed
wojtekmach opened this issue May 17, 2020 · 8 comments
Assignees
Labels
Milestone

Comments

@wojtekmach
Copy link
Contributor

text = "* {:error, {IncompatibleUnitError, message}}"
Earmark.as_ast(text)

results in:

** (FunctionClauseError) no function clause matching in Earmark.Helpers.AstHelpers.augment_tag_with_ial/2

    The following arguments were given to Earmark.Helpers.AstHelpers.augment_tag_with_ial/2:

        # 1
        []

        # 2
        %{}

    Attempted function clauses (showing 1 out of 1):

        def augment_tag_with_ial([{t, a, c} | tags], atts)

    (earmark 1.4.4) lib/earmark/helpers/ast_helpers.ex:12: Earmark.Helpers.AstHelpers.augment_tag_with_ial/2
    (earmark 1.4.4) lib/earmark/ast/inline.ex:214: Earmark.Ast.Inline.converter_for_inline_ial/1
    (elixir 1.10.2) lib/enum.ex:3333: Enum.find_value_list/3
    (earmark 1.4.4) lib/earmark/ast/inline.ex:24: Earmark.Ast.Inline._convert/4
    (earmark 1.4.4) lib/earmark/ast_renderer.ex:153: Earmark.AstRenderer.render_block/3
    (earmark 1.4.4) lib/earmark/ast_renderer.ex:25: Earmark.AstRenderer._render/3
    (earmark 1.4.4) lib/earmark/ast_renderer.ex:143: Earmark.AstRenderer.render_block/3
    (earmark 1.4.4) lib/earmark/ast_renderer.ex:25: Earmark.AstRenderer._render/3

See elixir-lang/ex_doc#1172 for more information.

@RobertDober RobertDober self-assigned this May 18, 2020
@RobertDober RobertDober added this to the 1.4.5 milestone May 18, 2020
@RobertDober
Copy link
Collaborator

Thank you for analysing and reporting this, I'll try to allocate some time for this.

@wojtekmach
Copy link
Contributor Author

FWIW:

- * {:error, {IncompatibleUnitError, message}}
+ * `{:error, {IncompatibleUnitError, message}}`

both fixes the bug AND is prettier in the output! But yeah, the bug might be triggered in some other ways so worth fixing.

@RobertDober
Copy link
Collaborator

well that is great news as I have no time right now, ok for you to push it into 1.5, meaning, ETA uncertain?

@wojtekmach
Copy link
Contributor Author

sounds good to me! since it's easy to fix in the user code I don't think it's a big deal.

@dinocosta
Copy link

dinocosta commented May 27, 2020

Hi 👋

I'm also encountering this same issue and I'm currently unable to generate docs for a phoenix app. I've managed to trace this to a single doc and here's sample documentation which can trigger this bug:

defmodule Sample do
  @doc """
  Creates a personal hello world message.

  ## Examples

  iex> Sample.hello("Mark", %{name: "Mark", age:
    27, info: %{email: "sample@gmail.com", phone:
      "123456789", address: "Around The Corner" } })
  {:ok, %User{...}}
  """
  def hello do
    :world
  end
end

It seems to be a very specific case because using the same documentation but moving things around slightly makes it work again, for example, the following documentation works:

defmodule Sample do
  @doc """
  Creates a personal hello world message.

  ## Examples

  iex> Sample.hello("Mark", %{name: "Mark", age:
    27, info: %{email: "sample@gmail.com", phone: "123456789", address: "Around The Corner" } })
  {:ok, %User{...}}
  """
  def hello do
    :world
  end
end

But, maintaining the same formatting as the first example and just changing the second element of the tuple in the sample response also works:

defmodule Sample do
  @doc """
  Creates a personal hello world message.

  ## Examples

  iex> Sample.hello("Mark", %{name: "Mark", age:
    27, info: %{email: "sample@gmail.com", phone:
      "123456789", address: "Around The Corner" } })
  {:ok, "Sample String"}
  """
  def hello do
    :world
  end
end

I don't know if this is of much help, the code doesn't even match the docs, but wanted to provide at least another example of how this bug can be reproduced so that if you ever decide to take a look into it you can also experiment this case :)

@RobertDober
Copy link
Collaborator

@JoaoFCosta thank you for that detailed report, will turn out helpful for sure

@wojtekmach
Copy link
Contributor Author

wojtekmach commented May 27, 2020 via email

@RobertDober
Copy link
Collaborator

Pushing into 1.4.6 as #342 is more serious and no easy workaround exists.

@RobertDober RobertDober modified the milestones: 1.4.5, 1.4.6 Jun 1, 2020
RobertDober added a commit that referenced this issue Jun 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants