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

quick fix for hot code reload error #755

Closed
wants to merge 2 commits into from

Conversation

mayel
Copy link
Contributor

@mayel mayel commented Oct 9, 2024

This fixes #754 though we may want to use the column instead of ignore it?

@mayel mayel changed the title quick fix for https://github.com/surface-ui/surface/issues/754 quick fix for hot code reload error Oct 9, 2024
defp print_diagnostic(message, :warning, file, {line, _column}) do
print_diagnostic(message, :warning, file, line)
end

Copy link
Member

Choose a reason for hiding this comment

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

Hey @mayel! Thanks for the PR.

I wonder if could have something like this, instead:

if Version.match?(System.version(), ">= 1.14.0") do    
  defp print_diagnostic(message, :warning, file, {line, col}) do
    IO.warn(message, file: file, line: line, column: col)
  end
end

# TODO: Remove this clause in Surface v0.13 and set required elixir to >= v1.14
defp print_diagnostic(message, :warning, file, line) do
  rel_file = file |> Path.relative_to_cwd() |> to_charlist()
  IO.warn(message, [{nil, :__FILE__, 1, [file: rel_file, line: line]}])
end

This way most users could already benefit from the column info and have better diagnostics.

@tiagoefmoraes WDYT?

Copy link
Member

Choose a reason for hiding this comment

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

Best of both worlds!

@msaraiva
Copy link
Member

Fixed in #755.

@mayel thank you!

@msaraiva msaraiva closed this Oct 11, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Error on printing diagnostics when hot code reloading
3 participants