-
Notifications
You must be signed in to change notification settings - Fork 368
Closed
Labels
Description
Consider the following scriptlet
using System;
class Reprocase {
public static int SplitIt(string s)
{
return s.Split(new [] {' ', '\t'}, StringSplitOptions.RemoveEmptyEntries).Length;
}
}
Console.WriteLine("Hello world");`
When running it with the Mono scripting engine, it fails with the following exception:
ERROR: [ScriptCs.Command.ExecuteScriptCommand] Script execution failed. [System.ArgumentOutOfRangeException] Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
at System.ThrowHelper.ThrowArgumentOutOfRangeException () <0x19505e0 + 0x0004f> in <filename unknown>:0
at System.Collections.Generic.List`1[T].get_Item (Int32 index) <0x17b6770 + 0x00022> in <filename unknown>:0
at Mono.CSharp.Location.get_Name () <0x3b25400 + 0x0003f> in <filename unknown>:0
at Mono.CSharp.Location.ToString () <0x3b253c8 + 0x00013> in <filename unknown>:0
at Mono.CSharp.ReportPrinter.Print (Mono.CSharp.AbstractMessage msg, System.IO.TextWriter output, Boolean showFullPath) <0x3b25188 + 0x000ab> in <filename unknown>:0
at Mono.CSharp.StreamReportPrinter.Print (Mono.CSharp.AbstractMessage msg, Boolean showFullPath) <0x3b25128 + 0x00027> in <filename unknown>:0
at Mono.CSharp.Report.Error (Int32 code, Location loc, System.String error) <0x3b24ef0 + 0x0008b> in <filename unknown>:0
at Mono.CSharp.CSharpParser.parse () <0x3aad1f8 + 0x0027f> in <filename unknown>:0
at Mono.CSharp.Evaluator.ParseString (ParseMode mode, System.String input, System.Boolean& partial_input) <0x3aa4c68 + 0x0030b> in <filename unknown>:0
at Mono.CSharp.Evaluator.Compile (System.String input, Mono.CSharp.CompiledMethod& compiled) <0x36dded8 + 0x0018f> in <filename unknown>:0
at Mono.CSharp.Evaluator.Evaluate (System.String input, System.Object& result, System.Boolean& result_set) <0x3b1bb38 + 0x0005f> in <filename unknown>:0
at ScriptCs.Engine.Mono.MonoScriptEngine.Execute (System.String code, Mono.CSharp.Evaluator session) <0x3ac0238 + 0x000eb> in <filename unknown>:0
Running only the class definition works, and running only the WriteLine statement works. Also, removing the array initializer (i.e. replacing it with a different syntax) also works.
I tried to debug down into the ScriptCs.Engine.Mono and the difference that I can see is that when it works, the RegionParser successfully splits the code into two regions, one with the class definition and one with the Console.WriteLine statement. When it fails, all of the code is in one chunk.
Reactions are currently unavailable