private void ResolveBodyTypesInField(FieldDeclarationSyntax fieldDeclaration) { if (fieldDeclaration.Initializer == null) return; var resolver = new ExpressionTypeResolver(fieldDeclaration.File, diagnostics); resolver.CheckExpressionType(fieldDeclaration.Initializer, fieldDeclaration.Type.Fulfilled()); }
private void ResolveBodyTypesInFunction(FunctionDeclarationSyntax function) { if (function.Body == null) return; var diagnosticCount = diagnostics.Count; // TODO the return types of constructors and init functions should probably be void for purposes of expressions var resolver = new ExpressionTypeResolver(function.File, diagnostics, (Metatype)function.DeclaringType?.Type.Fulfilled(), function.ReturnType.Fulfilled()); // The body of a function shouldn't itself evaluate to anything. // There should be no `=> value` for the block, so the type is `void`. resolver.CheckExpressionType(function.Body, DataType.Void); if (diagnosticCount != diagnostics.Count) function.Poison(); }