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 variabls inside nested expressions #4951

Merged

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
... (stack trace)

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

    p Foo.new

This fix prevents it.
@straight-shoota
Copy link
Member

You could've just pushed this new commit to #4950 instead of creating a new PR ;)

@RX14 RX14 added this to the Next milestone Sep 11, 2017
@RX14 RX14 merged commit 177028e into crystal-lang:master Sep 11, 2017
@asterite
Copy link
Member

@makenowjust Awesome! Thank you! :-)

@makenowjust makenowjust deleted the fix/crystal/toplevel-nested-ivar-assign branch September 11, 2017 12:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants