hoshiumiarata · GitHub

It seems that using a numbered parameter as a singleton is generating an incorrect AST, so code like this is not working:

o = Object.new
o.tap { def _1.a(b) = "a#{b}" }
=> undefined method '_1' (NoMethodError)

It generates the following AST:

00002               NODE_SDEF:
00002                 NODE_FCALL:
00002                   method='_1' (31195136)
00002                 :a
00002                   mandatory args:
00002                     NODE_ARG b

I tried to fix it, so it generates the following AST now:

00002               NODE_SDEF:
00002                 NODE_NVAR 1
00002                 :a
00002                   mandatory args:
00002                     NODE_ARG b

I'm not sure if this is the best way to fix it, so it's okay to fix it in another way if it's better.

Read the original on github.com ↗