Search
Active

2
Sign in to vote
2
Sign in to vote
Sign in
to vote
Type: Bug
ID: 507217
Opened: 11/1/2009 1:35:01 AM
Access Restriction: Public
0
Workaround(s)
1
User(s) can reproduce this bug
下記のC#コードをコンパイルすると"未割当てのローカル変数"text"が使用されました。"というエラーメッセージが表示され、コンパイルできない。フィールドtextはCreateMessageを実行する前に"Hello"で初期化することが明白なので、このエラーは不当と思われる。


using System;
namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            string text;
            // string text = null;

            Func<string> CreateMessage = () =>
            {
                return text + " World!";
            };

            text = "Hello";
        // コンソールに"Hello World."を表示する。
            Console.WriteLine(CreateMessage());
        }
    }
}
Details (expand)
製品言語
日本語
製品名
Visual Studio 2008 SP1
オペレーティング システム
Windows Vista
オペレーティング システム言語
日本語
再現手順
上記ソースコードを参照。
実際の結果
エラーメッセージ
"未割当てのローカル変数"text"が使用されました。"
が発生し、コンパイルできない。
期待した結果
ノーエラーでコンパイルできる。
TAP コード (お持ちの場合のみ)
 
File Attachments
0 attachments
Sign in to post a comment.
Posted by Microsoft on 11/1/2009 at 9:40 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 'text.'" The error seems inappropriate because it's clear the "text" field initializes itself by assigning the string "Hello" before running CreateMessage.

using System;
namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            string text;
            // string text = null;

            Func<string> CreateMessage = () =>
            {
                return text + " World!";
            };

            text = "Hello";
        // Display "Hello World." in the console.
            Console.WriteLine(CreateMessage());
        }
    }
}

[Repro Steps]
Run the above source code.

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

[Expected Results]
It should be able to be compiled with no error.
Posted by Microsoft on 11/2/2009 at 12:46 AM
Thank you for your feedback, We are currently reviewing the issue you have submitted.
Posted by Microsoft on 11/2/2009 at 1:08 AM
(こちらは、[投稿者: Microsoft、投稿日時: 2009/11/02 0:46] の和訳です。)

フィードバックをお寄せいただき、ありがとうございます。 私たちは現在、MicroVAX さんからご投稿いただきました問題を調査しております。
Posted by Microsoft on 11/5/2009 at 2:04 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/5/2009 at 4:48 PM
(こちらは、[投稿者: Microsoft、投稿日時: 2009/11/05 2:04] の和訳です。)

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

Visual Studio 製品チーム