Skip to content

Commit

Permalink
Fixed a bug in the inference of machine creates for recursive functio…
Browse files Browse the repository at this point in the history
…ns (part 2)
  • Loading branch information
ankushdesai committed Feb 19, 2021
1 parent 923e4f5 commit 4e9bedc
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions Src/PCompiler/CompilerCore/TypeChecker/InferMachineCreates.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ namespace Plang.Compiler.TypeChecker
public static class InferMachineCreates
{
// hash table used to store the functions inferred, to handle recursive, cyclic functions
private static HashSet<string> visitedFunctions;
private static HashSet<Function> visitedFunctions;
public static void Populate(Machine machine, ITranslationErrorHandler handler)
{
InterfaceSet interfaces = new InterfaceSet();
foreach (Function function in machine.Methods)
{
visitedFunctions = new HashSet<string>();
visitedFunctions = new HashSet<Function>();
interfaces.AddInterfaces(InferCreates(function, handler));
}

Expand All @@ -35,10 +35,10 @@ private static IEnumerable<Interface> InferCreates(IPAST tree, ITranslationError
{
return function.CreatesInterfaces;
}
if(visitedFunctions.Contains(function.Name))
if(visitedFunctions.Contains(function))
return Enumerable.Empty<Interface>();
else
visitedFunctions.Add(function.Name);
visitedFunctions.Add(function);

return InferCreates(function.Body, handler);

Expand Down

0 comments on commit 4e9bedc

Please sign in to comment.