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

alchemist-goto-definition-at-point crashes server when editing files with multiple import #348

Open
lstarnes1024 opened this issue May 20, 2018 · 0 comments

Comments

@lstarnes1024
Copy link

If you use alchemist-goto-definition-at-point in a module that has a multiple import statement like import Ecto.{Changeset, Query}, then it will be interpreted as Ecto., but it should be Ecto.Changeset and Ecto.Query. This will cause an error in the alchemist-server process when processing the DEFL:

02:45:30.798 [error] Task #PID<0.137.0> started from #PID<0.134.0> terminating
** (SyntaxError) nofile:1: syntax error before: ','
    (elixir) src/elixir.erl:203: :elixir.eval/3
    (elixir) lib/code.ex:192: Code.eval_string/3
    /home/lee/.emacs.d/elpa/alchemist-20180312.604/alchemist-server/lib/api/defl.exs:83: Alchemist.API.Defl.normalize/1
    /home/lee/.emacs.d/elpa/alchemist-20180312.604/alchemist-server/lib/api/defl.exs:13: Alchemist.API.Defl.request/1
    /home/lee/.emacs.d/elpa/alchemist-20180312.604/alchemist-server/lib/helpers/process_commands.exs:21: Alchemist.Helpers.ProcessCommands.process/2
    /home/lee/.emacs.d/elpa/alchemist-20180312.604/alchemist-server/lib/server/socket.exs:44: Alchemist.Server.Socket.serve/2
    (elixir) lib/task/supervised.ex:88: Task.Supervised.do_apply/2
Function: #Function<0.70471814/0 in Alchemist.Server.Socket.loop_acceptor/2>
    Args: []

I ran into this with a file (lib/pleroma/user.ex in Pleroma) that has these use/import/alias statements:

use Ecto.Schema
import Ecto.{Changeset, Query}
alias Pleroma.{Repo, User, Object, Web, Activity, Notification}
alias Comeonin.Pbkdf2
alias Pleroma.Web.{OStatus, Websub}
alias Pleroma.Web.ActivityPub.{Utils, ActivityPub}

The format call in alchemist-goto--open-definition outputs

 { "ActivityPub,make_user_from_ap_id", [ context: Elixir, imports: [Ecto.,Ecto.Schema,Pleroma.User], aliases: [{Pbkdf2, Comeonin.Pbkdf2},{Utils, Pleroma.Web.ActivityPub.Utils},{ActivityPub, Pleroma.Web.ActivityPub.ActivityPub},{OStatus, Pleroma.Web.OStatus},{Websub, Pleroma.Web.Websub},{Repo, Pleroma.Repo},{User, Pleroma.User},{Object, Pleroma.Object},{Web, Pleroma.Web},{Activity, Pleroma.Activity},{Notification, Pleroma.Notification}] ] }

But it should be

{ "ActivityPub,make_user_from_ap_id", [ context: Elixir, imports: [Ecto.Changeset,Ecto.Query,Ecto.Schema,Pleroma.User], aliases: [{Pbkdf2, Comeonin.Pbkdf2},{Utils, Pleroma.Web.ActivityPub.Utils},{ActivityPub, Pleroma.Web.ActivityPub.ActivityPub},{OStatus, Pleroma.Web.OStatus},{Websub, Pleroma.Web.Websub},{Repo, Pleroma.Repo},{User, Pleroma.User},{Object, Pleroma.Object},{Web, Pleroma.Web},{Activity, Pleroma.Activity},{Notification, Pleroma.Notification}] ] }

To fix this, alchemist-scope-modules probably needs to handle the multiple import/use statements like how alchemist-scope-aliases handles multiple alias statements.

M-x alchemist-version: Alchemist version: 1.8.2 (package: 20180312.604)

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

No branches or pull requests

1 participant