Re: replace()ing a crash
- Posted by Graeme May 27, 2021
- 848 views
suddenly started exiting without any warning or output.
Can you (or anyone else I suppose) try this:
function replace3(sequence s,object o1,object o2) for x=1 to length(s) do if equal(s[x],o1) then s[x]=o2 end if end for return s end function ?replace3({"this","that"},"that","other") -- {"this","other"} function replace4(sequence s,object o1,object o2) s[o2..o2] = o1 return s end function ?replace4({"this","that"},"that","other") -- ???
Should that be crashing (on Euphoria) without a proper message/ex.err then it should be looked into (but not by me, sorry).
Note that Phix [not that you use that] needed a minor tweak to builtins/VM/pFixup.e to report the error correctly inside replace4() (many thanks), although it did at least show the failing call to replace4().
That behaved as expected, no issues:
{ {116,104,105,115}, {111,116,104,101,114} }
C:\Euphoria\test.exw:23
slice lower index is not an atom - in slice/subscript #1 of 's (from inlined routine 'replace4' at 21)'
Yeah the Phix thing looks very interesting .... one of these days when I find a brown paper bag full of spare time I would love to check it out. TBH I don't even write much eu code any more, but I still have a heap of old eu3.1.1 bits & pieces and random personal utils that I have been using since the dawn of time. My current dabbling is mostly just getting some of this stuff to work on win10-64.
Thanks for your reply :)