# Possible ScriptEngine and parsing bug when converting block to a parameter

**URL:** <https://www.ruby-forum.com/t/possible-scriptengine-and-parsing-bug-when-converting-block-to-a-parameter/176598>\
**Category:** IronRuby\
**Created:** [October 2, 2009, 8:28pm UTC](https://www.ruby-forum.com/t/possible-scriptengine-and-parsing-bug-when-converting-block-to-a-parameter/176598 "2009-10-02T20:28:27Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![dotty](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/e56c9b/32.png) [@dotty](https://www.ruby-forum.com/u/dotty)\
**Post date:** [October 2, 2009, 8:28pm UTC](https://www.ruby-forum.com/t/possible-scriptengine-and-parsing-bug-when-converting-block-to-a-parameter/176598/1 "2009-10-02T20:28:27Z")

</div>

I was getting an error trying to use ScriptEngine to require  
‘win32ole’ (Actually, I need this from C#, below example given because  
its easier to show in IronRuby):

> > > IronRuby.create\_engine.execute\_file(‘Libs\win32ole.rb’)  
> > > :0: `&’ interpreted as argument prefix  
> > > (Microsoft::Scripting::SyntaxErrorException)

Looks like it fails on this line(63):

result = strongly\_typed\_enumerable.each &b  
#result = strongly\_typed\_enumerable.each(&b) #Works just fine if we  
add parens around &b

However, ir.exe reads the file with NO error if we just do a normal  
“require”.  
This is where I’m not sure if this is a bug.  
Do ScriptEngine and IR.exe (run interactively ONLY) have stricter  
parsing requirements?  
I investigated a bit further to get a simpler repro and found some  
interesting results.

Fine processing the code directly:

> ruby -e"b = lambda { |x| p x };result = [1,2].each &b"  
> 1  
> 2

> rbx -e"b = lambda { |x| p x };result = [1,2].each &b"  
> 1  
> 2

Argument error comes ONLY when running interactively (or through the  
ScriptEngine as shown above):

> irb  
> irb(main):001:0\> b = lambda { |x| p x };result = [1,2].each &b  
> 1  
> 2  
> =\> [1, 2]

> rbx  
> IronRuby 0.9.1.0 on .NET 2.0.50727.3082  
> Copyright © Microsoft Corporation. All rights reserved.

> > > b = lambda { |x| p x };result = [1,2].each &b  
> > > unknown: `&’ interpreted as argument prefix  
> > > (Microsoft::Scripting::SyntaxErrorException)

Again, fine through ir.exe interactive if I parameterize the block:  
b = lambda { |x| p x };result = [1,2].each(&b)

Thanks  
Best Regards,  
Kevin

---

<div class="post-metadata">

**Author:** ![dotty](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/e56c9b/32.png) [@dotty](https://www.ruby-forum.com/u/dotty)\
**Post date:** [October 2, 2009, 8:47pm UTC](https://www.ruby-forum.com/t/possible-scriptengine-and-parsing-bug-when-converting-block-to-a-parameter/176598/2 "2009-10-02T20:47:11Z")

</div>

Looks like a bug in win32ole.rb:

D:\M5\Merlin\Main\Languages\Ruby\>ruby -w libs\win32ole.rb  
libs/win32ole.rb:63: warning: `&’ interpreted as argument prefix

The default warning levels seem to be different when hosted. It would  
probably be better to set the default warning level on the same level as  
ir.exe/ruby does.

Will fix both.

Tomas

---

<div class="post-metadata">

**Author:** ![dotty](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/e56c9b/32.png) [@dotty](https://www.ruby-forum.com/u/dotty)\
**Post date:** [October 2, 2009, 9:17pm UTC](https://www.ruby-forum.com/t/possible-scriptengine-and-parsing-bug-when-converting-block-to-a-parameter/176598/3 "2009-10-02T21:17:37Z")

</div>

Great! Tomas, thanks also for the speedy follow-up email.  
Best Regards,  
Kevin

On Fri, Oct 2, 2009 at 12:41 PM, Tomas M.
