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

Fixed bug where writing to the first element of a FORM threw an error.

parent 0aef79d64c7d
......@@ -208,7 +208,7 @@ namespace Zilf.Interpreter.Values
}
set
{
if (GetRest(index) is ZilList rested && !rested.IsEmpty)
if (GetRest(index) is ZilListoidBase rested && !rested.IsEmpty)
{
rested.First = value;
}
......
......@@ -1395,5 +1395,18 @@ namespace Zilf.Tests.Interpreter
TestHelpers.EvalAndAssert(ctx, "<TYPE? ',X GVAL>", ctx.GetStdAtom(StdAtom.GVAL));
}
[TestMethod]
public void Accessing_Elements_Of_FORM_Should_Work()
{
TestHelpers.Evaluate(ctx, "<SET X '.A>");
TestHelpers.EvalAndAssert(ctx, "<1 .X>", ctx.GetStdAtom(StdAtom.LVAL));
TestHelpers.Evaluate(ctx, "<1 .X EVAL>");
TestHelpers.EvalAndAssert(ctx, "<1 .X>", ctx.GetStdAtom(StdAtom.EVAL));
TestHelpers.Evaluate(ctx, "<PUT .X 1 GVAL>");
TestHelpers.EvalAndAssert(ctx, "<1 .X>", ctx.GetStdAtom(StdAtom.GVAL));
TestHelpers.Evaluate(ctx, "<2 .X Y>");
TestHelpers.EvalAndAssert(ctx, "<2 .X>", ZilAtom.Parse("Y", ctx));
}
}
}
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