From 45a441bab7915900a185331d9cca8a9d25af14f4 Mon Sep 17 00:00:00 2001 From: Ankush Desai Date: Wed, 9 Oct 2024 11:55:34 -0700 Subject: [PATCH] Added a type checking rule --- .../TypeChecker/ModuleSystemTypeChecker.cs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/Src/PCompiler/CompilerCore/TypeChecker/ModuleSystemTypeChecker.cs b/Src/PCompiler/CompilerCore/TypeChecker/ModuleSystemTypeChecker.cs index cad8a5945d..82fecc3330 100644 --- a/Src/PCompiler/CompilerCore/TypeChecker/ModuleSystemTypeChecker.cs +++ b/Src/PCompiler/CompilerCore/TypeChecker/ModuleSystemTypeChecker.cs @@ -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 { @@ -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)