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

"Or equals" operator fails with class variables #3138

Closed
jbreeden opened this Issue Mar 20, 2016 · 6 comments

Comments

Projects
None yet
3 participants
@jbreeden
Contributor

jbreeden commented Mar 20, 2016

The "or equals" operator ||= seems to fail with class variables, but not instance variables.

[jared:~/projects/mruby] mirb
mirb - Embeddable Interactive Ruby Shell

> class Test
*  @@var ||= 'testing'
* end
(mirb):4: uninitialized class variable @@var in Test (NameError)
> class Test2
*  @var ||= 'testing'
* end
 => "testing"
@matz

This comment has been minimized.

Show comment
Hide comment
@matz

matz Mar 20, 2016

Member

Ah, I forgot to support this case. Sorry.
Since it is difficult to implement this without adding instructions, let it be restriction of mruby, at least for a while.

Member

matz commented Mar 20, 2016

Ah, I forgot to support this case. Sorry.
Since it is difficult to implement this without adding instructions, let it be restriction of mruby, at least for a while.

@matz

This comment has been minimized.

Show comment
Hide comment
@matz

matz Mar 20, 2016

Member

I got an idea to support this without adding any new instruction using rescue.

Member

matz commented Mar 20, 2016

I got an idea to support this without adding any new instruction using rescue.

@matz matz closed this in a02acf2 Mar 20, 2016

@jbreeden

This comment has been minimized.

Show comment
Hide comment
@jbreeden

jbreeden Mar 20, 2016

Contributor

Thanks for taking the time! It's easy enough to work around, but I'm trying to run ruby/spec code with as few alterations as possible, so this is very much appreciated!

While the simple case works, in practice I'm seeing "NameError: uninitialized class variable NameError in SocketSpecs." Of course I can't reproduce outside of ruby/spec... but I'll get back to you if I can come up with something.

Contributor

jbreeden commented Mar 20, 2016

Thanks for taking the time! It's easy enough to work around, but I'm trying to run ruby/spec code with as few alterations as possible, so this is very much appreciated!

While the simple case works, in practice I'm seeing "NameError: uninitialized class variable NameError in SocketSpecs." Of course I can't reproduce outside of ruby/spec... but I'll get back to you if I can come up with something.

@matz

This comment has been minimized.

Show comment
Hide comment
@matz

matz Mar 21, 2016

Member

@jbreeden I fixed one error, please check if it address your issue.

Member

matz commented Mar 21, 2016

@jbreeden I fixed one error, please check if it address your issue.

@zzak

This comment has been minimized.

Show comment
Hide comment
@zzak

zzak Mar 24, 2016

Member

I think this is worth mentioning on the #3140

Member

zzak commented Mar 24, 2016

I think this is worth mentioning on the #3140

matz added a commit that referenced this issue Mar 24, 2016

@jbreeden

This comment has been minimized.

Show comment
Hide comment
@jbreeden

jbreeden Apr 3, 2016

Contributor

Finally got to verify this. The NameError issue is gone. Hurray!

Contributor

jbreeden commented Apr 3, 2016

Finally got to verify this. The NameError issue is gone. Hurray!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment