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

Undetected usage of uninitialized variable in constructor #9036

Open
waj opened this issue Apr 10, 2020 · 0 comments
Open

Undetected usage of uninitialized variable in constructor #9036

waj opened this issue Apr 10, 2020 · 0 comments

Comments

@waj
Copy link
Member

waj commented Apr 10, 2020

This program crashes with a segfault. It actually should not compile, because the variable @x is used before the assignment.

class Foo
  property x : String

  def self.do
    yield
  end

  def initialize
    @x = Foo.do { x }
  end
end

puts Foo.new.x
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant