Comments (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.
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.
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)
- Pass timeout parameter HOT 3
- how does it differ from elixir agent HOT 7
- stop_server not usable from within defstart HOT 4
- function undefined error at elixir v0.11.0 HOT 2
- defcall can not use in quote HOT 3
- Struct pattern matching error HOT 3
- `export:` only accept atom.
- Testing support HOT 11
- Can this be used with a via_tuple? HOT 4
- Possibility of custom process registration dispatching logic? HOT 7
- Support for Elixir 1.5 @impl HOT 4
- Generate typespecs as well HOT 1
- Broken link in README
- Unused variable warnings when variables created in map pattern match HOT 1
- Why was ExActor not a good idea? HOT 5
- Can't build docs for project what uses exactor HOT 1
- Any roadmap to supervise the started actor? HOT 5
- DSL for :local, :global name registration from supervisor's spec HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from exactor.