Commit 6d8232c6 authored by Jesse McGrew's avatar Jesse McGrew

Fixed a couple bugs related to using OBLISTs as structured values. [ZILF-200]

parent ca192fe07a25
......@@ -190,13 +190,23 @@ namespace Zilf.Interpreter
if (list.IsEmpty)
throw new InterpreterError(InterpreterMessages._0_Writing_Past_End_Of_Structure, "PUTREST");
if (newRest is ZilList newRestList)
try
{
list.Rest = newRestList;
if (newRest is ZilList newRestList)
{
list.Rest = newRestList;
}
else
{
list.Rest = new ZilList(newRest);
}
}
else
catch (NotSupportedException)
{
list.Rest = new ZilList(newRest);
throw new InterpreterError(
InterpreterMessages._0_Element_1_Is_Read_Only,
"PUTREST",
"'REST'");
}
return list;
......
......@@ -163,7 +163,7 @@ namespace Zilf.Interpreter.Values.Tied
}
}
public sealed override bool IsEmpty => GetLength(1) != 0;
public sealed override bool IsEmpty => GetLength(1) == 0;
public sealed override IEnumerator<ZilObject> GetEnumerator()
{
......@@ -261,7 +261,7 @@ namespace Zilf.Interpreter.Values.Tied
public override StdAtom StdTypeAtom => StdAtom.LIST;
public override bool IsEmpty => GetLength(1) != 0;
public override bool IsEmpty => GetLength(1) == 0;
public override IEnumerator<ZilObject> GetEnumerator()
{
......
......@@ -1436,5 +1436,16 @@ namespace Zilf.Tests.Interpreter
}
}
[TestMethod]
public void OBLIST_Should_Work_With_MAPF()
{
TestHelpers.Evaluate(ctx, "SAMPLE-ATOM-1!-SAMPLE-OBLIST SAMPLE-ATOM-2!-SAMPLE-OBLIST");
TestHelpers.EvalAndAssert(
ctx,
"<MAPF ,+ ,LENGTH <MOBLIST SAMPLE-OBLIST>>",
new ZilFix(2));
}
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment