phoenixframework/phoenix

Verified routes emit diagnostics without file and position

lukaszsamson opened this issue · 0 comments

Environment

  • Elixir version (elixir -v):
  • Phoenix version (mix deps): 1.7.12
  • Phoenix liveview version (mix deps): 0.20.14
  • Operating system:

Actual behavior

When mix compile --return-errors is run against a project with broken routes in heex, the warning that gets emitted is incomplete

%Mix.Task.Compiler.Diagnostic{
  file: nil,
  source: nil,
  severity: :warning,
  message: "no route path for My.Web.Router matches \"/foo/\#{assigns.my_id}/bar/\#{event.id}\"",
  position: 0,
  compiler_name: "Elixir",
  span: nil,
  details: nil,
  stacktrace: [
    {My.Web.Components, :my_page, 1,
     [
       file: ~c"lib/my_backend/components/pages/my_page.html.heex",
       line: 165
     ]}
  ]
}

Expected behavior

The emitted warning has file and position. Those fields are used by language servers for rendering diagnostics. Without the exact position or span it is not possible to display the warning where it is. Traversing the stacktrace is a poor and error prone workaround