Coder Social home page Coder Social logo

Comments (3)

sasa1977 avatar sasa1977 commented on September 27, 2024 3

Thanks for the report. There was indeed a problem with compound matches, and it's now fixed and pushed to GitHub (but not yet to hex).

However, the fix will not solve all warnings. The remaining problems are the cases where a submatch of an argument is used only in the interface function:

defstart start_link(state = %Location{module: _, uuid: uuid}), 
    gen_server_opts: [name: {:global, {:location, uuid}}] 
do
  ...
end

The problem is that defstart generates two functions: start_link which uses uuid var, and init which doesn't use it. Thus, a warning is emitted.

I'm not sure I can do anything to reliably treat such situations. I could try to walk the AST of the body, to deduce which variables are in fact used in the callback function (init), and then mask the references in the match to init. But this would be quite convoluted, hard to reason about, and might possibly introduce some subtle bugs. So at the moment, I'm not inclined to attempt this.

A workaround for this could be to introduce a helper function:

defstart start_link(location),
    gen_server_opts: [name: process_name(location)]
do
...
end

defp process_name(%Location{module: _, uuid: uuid}), do: {:global, {:location, uuid}}

This is one example which demonstrates the weakness of ExActor. The problem is that macros such as defstart, defcall, and others generate two functions. That works fine when arguments are just plain vars. However, if you want to use more complex pattern matches, then there might be problems because it's hard (if not impossible) to guess whether the match should be applied in the interface function and/or in the callback function.

In any case, could you please give this a try (you need to change your dependency to point to GitHub), and let me know if it works.

from exactor.

sasa1977 avatar sasa1977 commented on September 27, 2024

I just tried with Elixir 1.2.5 and didn't get any warning. Could you provide a code which produces such warning?

Also, which version of ExActor are you using? There was indeed such bug in previous versions, but it's fixed in the latest one (2.2.0).

from exactor.

Qqwy avatar Qqwy commented on September 27, 2024

Thank you for your reply! 👍

I am using version 2.2.0 of ExActor, and I am running version 1.2.5 of Elixir (and I am getting exactly the same warnings under version 1.2.3 and 1.2.4).

The project I am currently using ExActor for can be found on GitHub over here.

When (re-)compiling lib/alchemud/world/gen_location.ex, I get the following warnings:

lib/alchemud/world/gen_location.ex:13: warning: variable state is unused
lib/alchemud/world/gen_location.ex:13: warning: variable uuid is unused
lib/alchemud/world/gen_location.ex:32: warning: variable exit_name is unused
lib/alchemud/world/gen_location.ex:32: warning: variable exit_name is unused
lib/alchemud/world/gen_location.ex:32: warning: variable way is unused
lib/alchemud/world/gen_location.ex:32: warning: variable ways is unused
lib/alchemud/world/gen_location.ex:46: warning: variable entity is unused
lib/alchemud/world/gen_location.ex:84: warning: variable state is unused
lib/alchemud/world/gen_location.ex:10: warning: unused alias Entity
Compiled lib/alchemud/world/gen_location.ex

Similar warnings are made for lib/alchemud/world/gen_way.ex and lib/alchemud/world/gen_entity.ex.

Am I doing something wrong?

from exactor.

Related Issues (19)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.