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

Issue 50: []= not working? #99

Closed
consiliens opened this Issue Aug 26, 2011 · 5 comments

Comments

Projects
None yet
2 participants
@consiliens
Contributor

consiliens commented Aug 26, 2011

"Reported by michal.h...@gmail.com, Apr 6, 2011
michal@domov:~/Plocha$ jruby -S mirah hash.mirah
hash.mirah:5: undefined method error?' for #<Mirah::AST::InlineCode:0x2219b4> def []= (k:Object, v:Object) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ puts "K: #{k}, V: #{v}" ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ end ^^^^^ /usr/lib/jruby/lib/ruby/gems/1.8/gems/mirah-0.0.7-java/lib/mirah/ast/method.rb:284:inresolve_if': undefined method error?' for #<Mirah::AST::InlineCode:0x2219b4> (Mirah::InternalCompilerError) from /usr/lib/jruby/lib/ruby/gems/1.8/gems/mirah-0.0.7-java/lib/mirah/ast.rb:227:inresolve_if'
from /usr/lib/jruby/lib/ruby/gems/1.8/gems/mirah-0.0.7-java/lib/mirah/ast/method.rb:277:in resolve_if' from /usr/lib/jruby/lib/ruby/gems/1.8/gems/mirah-0.0.7-java/lib/mirah/ast/method.rb:229:ininfer'
from /usr/lib/jruby/lib/ruby/gems/1.8/gems/mirah-0.0.7-java/lib/mirah/typer.rb:295:in infer' from /usr/lib/jruby/lib/ruby/gems/1.8/gems/mirah-0.0.7-java/lib/mirah/ast/structure.rb:35:ininfer'
from org/jruby/RubyArray.java:1671:in each' from org/jruby/RubyEnumerable.java:903:ineach_with_index'
from /usr/lib/jruby/lib/ruby/gems/1.8/gems/mirah-0.0.7-java/lib/mirah/ast/structure.rb:33:in infer' from /usr/lib/jruby/lib/ruby/gems/1.8/gems/mirah-0.0.7-java/lib/mirah/typer.rb:295:ininfer'
from /usr/lib/jruby/lib/ruby/gems/1.8/gems/mirah-0.0.7-java/lib/mirah/ast/class.rb:110:in infer' from /usr/lib/jruby/lib/ruby/gems/1.8/gems/mirah-0.0.7-java/lib/mirah/typer.rb:114:indefine_type'
from /usr/lib/jruby/lib/ruby/gems/1.8/gems/mirah-0.0.7-java/lib/mirah/ast/class.rb:108:in infer' from /usr/lib/jruby/lib/ruby/gems/1.8/gems/mirah-0.0.7-java/lib/mirah/ast.rb:227:inresolve_if'
from /usr/lib/jruby/lib/ruby/gems/1.8/gems/mirah-0.0.7-java/lib/mirah/ast/class.rb:104:in infer' from /usr/lib/jruby/lib/ruby/gems/1.8/gems/mirah-0.0.7-java/lib/mirah/typer.rb:295:ininfer'
from /usr/lib/jruby/lib/ruby/gems/1.8/gems/mirah-0.0.7-java/lib/mirah/ast/structure.rb:35:in infer' from org/jruby/RubyArray.java:1671:ineach'
from org/jruby/RubyEnumerable.java:903:in each_with_index' from /usr/lib/jruby/lib/ruby/gems/1.8/gems/mirah-0.0.7-java/lib/mirah/ast/structure.rb:33:ininfer'
from /usr/lib/jruby/lib/ruby/gems/1.8/gems/mirah-0.0.7-java/lib/mirah/typer.rb:295:in infer' from /usr/lib/jruby/lib/ruby/gems/1.8/gems/mirah-0.0.7-java/lib/mirah/ast/structure.rb:266:ininfer'
from /usr/lib/jruby/lib/ruby/gems/1.8/gems/mirah-0.0.7-java/lib/mirah/ast.rb:227:in resolve_if' from /usr/lib/jruby/lib/ruby/gems/1.8/gems/mirah-0.0.7-java/lib/mirah/ast/structure.rb:261:ininfer'
from /usr/lib/jruby/lib/ruby/gems/1.8/gems/mirah-0.0.7-java/lib/mirah/typer.rb:295:in infer' from /usr/lib/jruby/lib/ruby/gems/1.8/gems/mirah-0.0.7-java/lib/mirah/impl.rb:146:ininfer_asts'
from org/jruby/RubyArray.java:1671:in each' from /usr/lib/jruby/lib/ruby/gems/1.8/gems/mirah-0.0.7-java/lib/mirah/impl.rb:146:ininfer_asts'
from /usr/lib/jruby/lib/ruby/gems/1.8/gems/mirah-0.0.7-java/lib/mirah/impl.rb:92:in generate' from /usr/lib/jruby/lib/ruby/gems/1.8/gems/mirah-0.0.7-java/lib/mirah/impl.rb:20:inrun'
from /usr/lib/jruby/lib/ruby/gems/1.8/gems/mirah-0.0.7-java/lib/mirah.rb:41:in run' from /usr/lib/jruby/lib/ruby/gems/1.8/gems/mirah-0.0.7-java/bin/mirah:25:in(root)'
from org/jruby/RubyKernel.java:1066:in `load'"
http://code.google.com/p/mirah/issues/detail?id=50

@consiliens

This comment has been minimized.

Show comment
Hide comment
@consiliens

consiliens Aug 26, 2011

Contributor

"Comment 1 by rib...@gmail.com, Apr 8, 2011
what's in hash.mirah?"
http://code.google.com/p/mirah/issues/detail?id=50

Contributor

consiliens commented Aug 26, 2011

"Comment 1 by rib...@gmail.com, Apr 8, 2011
what's in hash.mirah?"
http://code.google.com/p/mirah/issues/detail?id=50

@consiliens

This comment has been minimized.

Show comment
Hide comment
@consiliens

consiliens Aug 26, 2011

Contributor

"Comment 2 by michal.h...@gmail.com, Apr 8, 2011
this:

class Hash
  def []= (k:Object, v:Object)
    puts "K: #{k}, V: #{v}"
  end
end

"
http://code.google.com/p/mirah/issues/detail?id=50

Contributor

consiliens commented Aug 26, 2011

"Comment 2 by michal.h...@gmail.com, Apr 8, 2011
this:

class Hash
  def []= (k:Object, v:Object)
    puts "K: #{k}, V: #{v}"
  end
end

"
http://code.google.com/p/mirah/issues/detail?id=50

@consiliens

This comment has been minimized.

Show comment
Hide comment
@consiliens

consiliens Aug 26, 2011

Contributor

"Comment 4 by rogerpack2005, May 28, 2011
I get a different error these days, which I assume means that it's still broken.

$cat yoyo.mir

class Hashy
def []= (k:Object, v:Object)
puts "K: #{k}, V: #{v}"
end
end

a = Hashy.new
a[Integer(3)]=Integer(4)

$ mirah yoyo.mir
Inference Error:
Cannot find instance method []=(java.lang.Integer, java.lang.Integer) on Hashy
yoyo.mir:10: Cannot find instance method []=(java.lang.Integer, java.lang.Integer) on Hashy
a[Integer(3)]=Integer(4)
^^^^^^^^^^^^^
"
http://code.google.com/p/mirah/issues/detail?id=50

Contributor

consiliens commented Aug 26, 2011

"Comment 4 by rogerpack2005, May 28, 2011
I get a different error these days, which I assume means that it's still broken.

$cat yoyo.mir

class Hashy
def []= (k:Object, v:Object)
puts "K: #{k}, V: #{v}"
end
end

a = Hashy.new
a[Integer(3)]=Integer(4)

$ mirah yoyo.mir
Inference Error:
Cannot find instance method []=(java.lang.Integer, java.lang.Integer) on Hashy
yoyo.mir:10: Cannot find instance method []=(java.lang.Integer, java.lang.Integer) on Hashy
a[Integer(3)]=Integer(4)
^^^^^^^^^^^^^
"
http://code.google.com/p/mirah/issues/detail?id=50

@baroquebobcat

This comment has been minimized.

Show comment
Hide comment
@baroquebobcat

baroquebobcat Aug 26, 2011

Member

I'm not sure if you can define []= as a method. I think you need to use a macro for that. It would be nice to not need a macro to make it work though.

Member

baroquebobcat commented Aug 26, 2011

I'm not sure if you can define []= as a method. I think you need to use a macro for that. It would be nice to not need a macro to make it work though.

@baroquebobcat

This comment has been minimized.

Show comment
Hide comment
@baroquebobcat

baroquebobcat Sep 11, 2011

Member
class Hashy
def set (k:Object, v:Object)
puts "K: #{k}, V: #{v}"
end
macro def []= k,v
  quote {set `k`,`v`}
end
end

a = Hashy.new
a["aoeu"]="asdf"

works for me.

Closing this issue--it's not a bug per se. We could put in an enhancement to macro-ify methods like we talked about in #111. Also, resolving #111, could help w/ this as well.

Member

baroquebobcat commented Sep 11, 2011

class Hashy
def set (k:Object, v:Object)
puts "K: #{k}, V: #{v}"
end
macro def []= k,v
  quote {set `k`,`v`}
end
end

a = Hashy.new
a["aoeu"]="asdf"

works for me.

Closing this issue--it's not a bug per se. We could put in an enhancement to macro-ify methods like we talked about in #111. Also, resolving #111, could help w/ this as well.

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