Skip to content

Commit

Permalink
Added a type checking rule
Browse files Browse the repository at this point in the history
  • Loading branch information
ankushdesai committed Oct 9, 2024
1 parent ad30f29 commit 45a441b
Showing 1 changed file with 10 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
using Plang.Compiler.TypeChecker.AST;
using Plang.Compiler.TypeChecker.AST.Declarations;
using Plang.Compiler.TypeChecker.AST.ModuleExprs;
using Plang.Compiler.TypeChecker.Types;

namespace Plang.Compiler.TypeChecker
{
Expand Down Expand Up @@ -189,13 +190,21 @@ internal void CheckSafetyTest(SafetyTest test)
$"test module is not closed with respect to created interfaces; interface {@interface.First().Name} is created but not implemented inside the module");
}

//check that the test module main machine exists
// check that the test module main machine exists
var hasMainMachine = test.ModExpr.ModuleInfo.InterfaceDef.Values.Any(m => m.Name == test.Main && !m.IsSpec);
if (!hasMainMachine)
{
throw handler.NoMain(test.SourceLocation,
$"machine {test.Main} does not exist in the test module");
}

// make sure that the main machine does not take a parameter as input
globalScope.Get(test.Main, out Machine main);
if (!main.PayloadType.Equals(PrimitiveType.Null))
{
throw handler.NoMain(test.SourceLocation,
$"main machine {test.Main} cannot take an input parameter in the start state entry function.");
}
}

internal void CheckImplementationDecl(Implementation impl)
Expand Down

0 comments on commit 45a441b

Please sign in to comment.