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

Silence compiler warnings, safer variable re-binding #10

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

tompave
Copy link

@tompave tompave commented Nov 1, 2016

At the moment using this library in a phoenix project will raise this warning on (re)compilation:

warning: the variable "children" is unsafe as it has been set inside a case/cond/receive/if/&&/||. Please explicitly return the variable value instead. For example:

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

should be written as

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

Unsafe variable found at:
  lib/my_app_name/react_io.ex:2

where lib/my_app_name/react_io.ex has these contents:

defmodule MyAppName.ReactIo do  
  use StdJsonIo, otp_app: :my_app_name, script: "node_modules/react-stdio/bin/react-stdio"
end 

This is because of Elixir's new stricter checks on variable re-binding inside conditionals.

This PR extracts the logic to add the reloader spec in a separate function, to improve the organization of the init/1 function and to silence the "unsafe variable assignment" warnings.

…o improve the organization of the init/1 function and to silence the "unsafe variable assignment" warnings.
@gogocurtis
Copy link

+1

@tompave
Copy link
Author

tompave commented Jan 19, 2017

bump

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

Successfully merging this pull request may close these issues.

2 participants