ex_spirit icon indicating copy to clipboard operation
ex_spirit copied to clipboard

Compilation warning

Open tmbb opened this issue 7 years ago • 6 comments

Unsafe variable found at:
  lib/ex_spirit/parser.ex:1315

warning: the variable "context" is unsafe as it has been set inside one of: case, cond, receive, if, and, or, &&, ||. Please explicitly return the variable value instead. For example:

    case integer do
      1 -> atom = :one
      2 -> atom = :two
    end

should be written as

    atom =
      case integer do
        1 -> :one
        2 -> :two
      end

Unsafe variable found at:
  lib/ex_spirit/parser.ex:1317

tmbb avatar Jul 30 '17 11:07 tmbb

Yeah that is because of some Elixir utter stupidity in that it leaks bindings out of case statements (and later Elixir realized how stupid that was so put a warning about it). The only way to fix it since I am generating massively nested case's is to generate new atom names, which balloons the atom table, and thus I do not really want to do that. I might though, it will fix this warnings. Even with the warnings it should not cause errors during run though, it is just an Elixir massive mis-design. I'll leave this open to remind me to generate unique atom names later (maybe behind an option?).

OvermindDL1 avatar Jul 31 '17 15:07 OvermindDL1

Is there any way to disable that warning? Per file or even per project?

tmbb avatar Jul 31 '17 22:07 tmbb

Is there any way to disable that warning? Per file or even per project?

Hmm, I've not actually checked, I've always left the warning to remind me to do something about it later (it would not even be an issue if elixir did not leak bindings outside their scope to begin with...)...

From some quick googling I'm not finding any way to disable that warning explicitly and it seems they don't want to add such a way to disable it considering the pattern (which does not actually exist here, just macro's acting oddly in certain recursive patterns) is a bad pattern that should have never existed to begin with.

Keep poking me on occasion, I'm in a crunch period this and next week but I should be able to get time after that (maybe before at home sometimes?) to fix it in ExSpirit. It would help a LOT if you could give me a minimal reproducable example that causes that warning so I don't have to trace through every line individually, with such a minimal example I could fix it a lot sooner. ^.^

OvermindDL1 avatar Jul 31 '17 22:07 OvermindDL1

It would help a LOT if you could give me a minimal reproducable example that causes that warning so I don't have to trace through every line individually, with such a minimal example I could fix it a lot sooner. ^.^

Sure, I'll try!

tmbb avatar Jul 31 '17 22:07 tmbb

Just a warning that this will turn into an error in Elixir 1.7

tmbb avatar Mar 01 '18 09:03 tmbb

Well it's not actually 'used', so I don't even know why elixir says it is leaking out, that functionality needs to be entirely removed and I can't wait until it is (bindings should not leak out of scopes!). ^.^

OvermindDL1 avatar Mar 01 '18 16:03 OvermindDL1