Commit b27ac677 authored by Jesse McGrew's avatar Jesse McGrew
Browse files

Fixed bug where <REST .X 0> returned .X without chtyping to its primtype.

parent b31b89e55212
......@@ -59,7 +59,7 @@ namespace Zilf.Interpreter
var result = (ZilObject)st.GetRest(skip);
if (result == null)
throw new InterpreterError(InterpreterMessages._0_Not_Enough_Elements, "REST");
return result;
return result.GetPrimitive(ctx);
}
/// <exception cref="InterpreterError">The type of <paramref name="st"/> does not support this operation, or <paramref name="st"/> has not been RESTed at least <paramref name="skip"/> elements.</exception>
......
......@@ -79,8 +79,10 @@ namespace Zilf.Interpreter.Values
}
}
protected ZilListBase(ZilObject first, ZilListoidBase rest)
protected ZilListBase([CanBeNull] ZilObject first, [CanBeNull] ZilListoidBase rest)
{
Debug.Assert((first == null) == (rest == null));
this.first = first;
this.rest = rest;
}
......@@ -106,6 +108,7 @@ namespace Zilf.Interpreter.Values
[NotNull]
protected virtual string CloseBracket => ")";
[NotNull]
public override string ToString()
{
if (Recursion.TryLock(this))
......
......@@ -1408,5 +1408,10 @@ namespace Zilf.Tests.Interpreter
TestHelpers.EvalAndAssert(ctx, "<2 .X>", ZilAtom.Parse("Y", ctx));
}
[TestMethod]
public void REST_0_Should_Return_Primitive_Type()
{
TestHelpers.EvalAndAssert(ctx, "<REST '<1> 0>", new ZilList(new ZilFix(1), new ZilList(null, null)));
}
}
}
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