[Ironruby-core] Can't run script after engine exception

Tomas Matousek Tomas.Matousek at microsoft.com
Tue Feb 19 02:51:33 EST 2008


Thanks, will investigate.

Tomas

-----Original Message-----
From: ironruby-core-bounces at rubyforge.org [mailto:ironruby-core-bounces at rubyforge.org] On Behalf Of Aaron Clauson
Sent: Monday, February 18, 2008 10:09 PM
To: ironruby-core at rubyforge.org
Subject: Re: [Ironruby-core] Can't run script after engine exception

Tomas Matousek wrote:
> Could you sent a full repro containing the source code of both scripts
> and the order of execution?
>
> Tomas

I thought I'd made a mistake for a while as I was having real difficulty
reapeating the problem. However I've found that it's a particular type
of syntax error that causes the problem rather than any syntax error.
The end statement missing on an if block is the culprit. Below is the
code that illustrates the problem:

IScriptEnvironment scriptEnvironment = IronRuby.CreateRuntime();
IScriptEngine rubyengine = IronRuby.GetEngine(scriptEnvironment);

string goodScript =
@"
if true
 puts 'Ruby is cool'
end";

string badScript =
@"
if true
 puts 'Ruby is cool'
";

Console.WriteLine("Attempting run1 (good script).");
rubyengine.Runtime.ExecuteSourceUnit(rubyengine.CreateScriptSourceFromString(goodScript));

try
{
  Console.WriteLine("Attempting run2 (bad script).");
  rubyengine.Runtime.ExecuteSourceUnit(rubyengine.CreateScriptSourceFromString(badScript));
}
catch (Exception excp)
{
  Console.WriteLine(excp.GetType());
}

try
{
  Console.WriteLine("Attempting run3 (good script).");
  rubyengine.Runtime.ExecuteSourceUnit(rubyengine.CreateScriptSourceFromString(goodScript));
}
catch (Exception excp2)
{
  Console.WriteLine(excp2.GetType());
}

Output:

Attempting run1 (good script).
Ruby is cool
Attempting run2 (bad script).
Microsoft.Scripting.SyntaxErrorException
Attempting run3 (good script).
Microsoft.Scripting.SyntaxErrorException

Regards,

Aaron

--
Posted via http://www.ruby-forum.com/.
_______________________________________________
Ironruby-core mailing list
Ironruby-core at rubyforge.org
http://rubyforge.org/mailman/listinfo/ironruby-core


More information about the Ironruby-core mailing list