Search
Active

1
Sign in to vote
0
Sign in to vote
Sign in
to vote
Type: Bug
ID: 507832
Opened: 11/3/2009 4:20:31 AM
Access Restriction: Public
0
Workaround(s)
0
User(s) can reproduce this bug
 下記のC#コードをコンパイルすると"未割当てのローカル変数"fact"が使用されました。"というエラーメッセージが表示され、コンパイルできない。fact実行時にはfactは確定していることは明白なので、このエラーは不当と思われる。そもそも匿名メソッド内で使われている匿名メソッド外部のローカル変数が未割り当てかどうかを、コンパイラがチェックするという方針が適切ではない。
     Func<int, int> fact = n => {
        if (n == 0) return 1;
        return fact(n - 1) * n;
     };
Details (expand)
製品言語
日本語
製品名
Visual Studio 2008 SP1
オペレーティング システム
Windows XP Professional
オペレーティング システム言語
日本語
再現手順
上記ソースコードを参照。
実際の結果
エラーメッセージ
"未割当てのローカル変数"fact"が使用されました。"
が発生し、コンパイルできない。
期待した結果
ノーエラーでコンパイルできる。
TAP コード (お持ちの場合のみ)
 
File Attachments
0 attachments
Sign in to post a comment.
Posted by Microsoft on 11/3/2009 at 8:47 PM
この度は、フィードバックをお送りいただき、誠にありがとうございます。 現在、お送りいただきました報告内容に基づき問題を調査中ですので、しばらくお待ちください。 よろしくお願いいたします。

[Problem Description]
When you try to compile the below C# source code, it cannot be compiled and the following error message occurs: "Use of unassigned local variable 'fact.'" The error seems inappropriate because it's clear that "fact" is fixed when executed. In the first place, I think it's inappropriate that the compiler checks if an external local variable used in an anonymous method is unassigned or not.

     Func<int, int> fact = n => {
        if (n == 0) return 1;
        return fact(n - 1) * n;
     };

[Repro Steps]
Run the above source code.

[Actual Results]
It cannot be compiled and the following error occurs: "Use of unassigned local variable 'fact'"

[Expected Results]
It should be able to be compiled with no error.
Posted by Microsoft on 11/11/2009 at 4:14 AM
Thanks for your feedback. We are routing this bug to the product unit who works on that specific feature area. The team will review this issue and make a decision on whether they will fix it or not for the next release.

Thank you,
Visual Studio Product Team
Posted by Microsoft on 11/11/2009 at 6:12 PM
(こちらは、[投稿者: Microsoft、投稿日時: 2009/11/11 4:14] の和訳です。)

フィードバックをお寄せいただき、ありがとうございます。 こちらのバグに関しましては、該当する機能を専門で担当している製品チームに報告させていただきます。 今後は、同チームが問題を再調査し、次期リリース版での修正について判断する予定です。 よろしくお願いいたします。

Visual Studio 製品チーム