Error using Split in WebAssembly

When I use string.Split and then foreach to traverse the list I get an error in WebAssembly. Same code works in Echos.

v .2339

namespace Module
{
    [Export]
    public class Program
    {
        public void HelloWorld()
        {
            Console.WriteLine("HelloWorld");
            
            // This works :)
            List<string> words = new List<string>();
            words.Add("first");
            words.Add("second");
            words.Add("third");
            foreach (string word in words)
            {
                Console.WriteLine($"word: {word}");
            }

            // This doesn't work :(
            string myWords="first second third";
            List<string> words2 = myWords.Split(" ");
            foreach (string word in words2)
            {
                Console.WriteLine($"word: {word}");
            }

            Console.WriteLine("GoodbyeWorld");
        }
    }
}

Error:

Fatal exception in WebAssembly!
RemObjectsElements.js:277 Exception: RemObjects.Elements.System.AbstractMethodException: Abstract method
wasm-014ed466-53:27 Uncaught (in promise) RuntimeError: unreachable
    at ElementsRaiseException (wasm-function[53]:74)
    at .L__abstract (wasm-function[385]:69)
    at .L_intf__rtti_t42_gt33__RemObjects__d__Elements__d__System__d__ListEnumerator__t__1s_vmthelper0 (wasm-function[3150]:665)
    at mi_t10_Module_d_Programa_HelloWorld (wasm-function[5650]:3461)
    at imp.env.__island_invoke (http://localhost:4321/wasm/RemObjectsElements.js:443:38)
    at .Lms_t2c_RemObjects_d_Elements_d_System_d_WebAssemblyc_InvokeMethodnp_vna_o (wasm-function[4668]:623)
    at .Lmi_t2b_RemObjects_d_Elements_d_System_d_MethodInfo6_Invokenona_o (wasm-function[3823]:2863)
    at .Lmi_tnt2c_RemObjects_d_Elements_d_System_d_WebAssembly18__l__g_c____DisplayClass117__l_GetProxyFor_g_b____2nt31_RemObjects_d_Elements_d_System_d_EcmaScriptObject (wasm-function[5022]:988)
    at .Lmi_t34_RemObjects_d_Elements_d_System_d_WebAssemblyDelegate6_Invokent31_RemObjects_d_Elements_d_System_d_EcmaScriptObject (wasm-function[5008]:63)
    at __island_call_delegate (wasm-function[5051]:45)

Sounds like a bug…

Thanks, logged as bugs://81336

bugs://81336 got closed with status fixed.

Confirmed as fixed in .2341 :slight_smile:

1 Like