E2025 手続きは結果を返せません (Delphi)

提供: RAD Studio
移動先: 案内検索

エラーと警告のメッセージ(Delphi) への移動

手続きを宣言しましたが,それに結果の型を指定しました。ほんとうは関数を宣言する意図だったか,あるいは結果の型を削除しなければなりません。


program Produce;

procedure DotProduct(const A,B: array of Double): Double;
var
  I: Integer;
begin
  Result := 0.0;
  for I := 0 to High(A) do
    Result := Result + A[I]*B[I];
end;

const
  C: array [1..3] of Double = (1,2,3);

begin
  Writeln( DotProduct(C,C) );
end.

{ ここでほんとうは DotProcuct を関数にする意図だったが,誤ったキーワードを使った... }


program Solve;

function DotProduct(const A,B: array of Double): Double;
var
  I: Integer;
begin
  Result := 0.0;
  for I := 0 to High(A) do
    Result := Result + A[I]*B[I];
end;

const
  C: array [1..3] of Double = (1,2,3);

begin
  Writeln( DotProduct(C,C) );
end.

{ 関数を宣言するときは必ず結果の型を宣言し,手続きを宣言するときは結果の型を宣言しない }