public void TrySet(ParseInfo parseInfo, IExpression value, DocRange expressionRange) { var type = CodeType.GetCodeType(parseInfo.TranslateInfo); // Check if the hook was already set. if (WasSet) { parseInfo.Script.Diagnostics.Error("Hooks cannot be set twice.", expressionRange); } // Check if the given value implements the expected value. else if (SemanticsHelper.ExpectValueType(parseInfo, value, type, expressionRange)) { // Set the hook. HookValue = value; SetHook?.Invoke(value); } WasSet = true; }