This instance will be upgraded to Heptapod 0.17.0 on 2020-11-26 at 14:00 UTC+1 (a few minutes of down time)

Commit d9eebc94 authored by Jesse McGrew's avatar Jesse McGrew

ZILF-219: Fix infinite loop in NewParserVocabFormat.BuildLateSyntaxTables

when WORD-FLAGS-LIST contains duplicate entries.
parent 0cbd488d9e75
......@@ -788,16 +788,16 @@ namespace Zilf.ZModel.Vocab.NewParser
if (!wordFlagsList.StartsWith(out ZilObject vword, out ZilObject flags))
throw new CompilerError(CompilerMessages.WORDFLAGSLIST_Must_Have_An_Even_Number_Of_Elements);
if (!seen.Add(vword))
continue;
var nw = NewParserWord.FromVword(ctx, (ZilHash)vword);
var atom = nw.Atom;
var word = ctx.ZEnvironment.Vocabulary[atom];
var zword = helpers.Vocabulary[word];
if (seen.Add(vword))
{
var nw = NewParserWord.FromVword(ctx, (ZilHash)vword);
var atom = nw.Atom;
var word = ctx.ZEnvironment.Vocabulary[atom];
var zword = helpers.Vocabulary[word];
filtered.Add(zword);
filtered.Add(helpers.CompileConstant(flags));
filtered.Add(zword);
filtered.Add(helpers.CompileConstant(flags));
}
wordFlagsList = wordFlagsList.GetRest(2);
Debug.Assert(wordFlagsList != null);
......
......@@ -323,6 +323,19 @@ namespace Zilf.Tests.Integration
"<=? <GET ,WORD-FLAG-TABLE 2> 12345>");
}
[TestMethod, Timeout(5000)]
public void WORD_FLAGS_LIST_With_Duplicates_Should_Compile()
{
AssertGlobals(
SNewParserBootstrap,
"<COMPILATION-FLAG WORD-FLAGS-IN-TABLE T>",
"<NEW-ADD-WORD FOO TBUZZ 123 456>",
"<NEW-ADD-WORD BAR TBUZZ 234 567>",
"<NEW-ADD-WORD FOO TADJ 345 678>")
.InV6()
.Compiles();
}
[TestMethod, TestCategory("NEW-PARSER?")]
public void NEW_PARSER_P_Synonyms_Should_Use_Pointers()
{
......
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