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

Disallow to assign instance/class variable outside method dynamically #4950

Conversation

makenowjust
Copy link
Contributor

This code can be compiled currently:

class Foo
  if true
    @foo = [] of Int32
  end
end

p Foo.new

but it is crashed at run time.

$ crystal run foo.cr
Invalid memory access (signal 11) at address 0x4

This fix prevents it.

This code can be compiled currently, but it is crashed at run time.

    class Foo
      if true
        @foo = [] of Int32
      end
    end

This fix prevents it.
@makenowjust
Copy link
Contributor Author

Sorry my fix is not perfect. I close this and will open a new pull request when fixed correctly.

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.

None yet

1 participant