Bug 310999 (MONO22646) - error in scope of local variable
Summary: error in scope of local variable
Status: RESOLVED MOVED
Alias: MONO22646
Product: Mono: Compilers
Classification: Mono
Component: C# (show other bugs)
Version: unspecified
Hardware: Other Other
: P3 - Medium : Minor
Target Milestone: ---
Assignee: Mono Bugs
QA Contact: Mono Bugs
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2002-03-28 00:02 UTC by Duco Fijma
Modified: 2007-09-15 21:24 UTC (History)
0 users

See Also:
Found By: ---
Services Priority:
Business Priority:
Blocker: ---
Marketing QA Status: ---
IT Deployment: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Thomas Wiest 2007-09-15 17:55:46 UTC


---- Reported by duco@lorentz.xs4all.nl 2002-03-27 17:02:17 MST ----

Description of Problem:
Checking the scope of a local variable hiding a class member variable
is not correctly implemented.

Steps to reproduce the problem:
using System;

class A {

        static int i = 42;

        public static void Main ()
        {
                Console.WriteLine ( i );
                int i = 37;
        }
}

Actual Results:
When compiled using "mcs", this program prints "42". This is what 
a C++ programmer might expect, but it is wrong. 

Expected Results:
The C# language reference specifies that the reference to "i" in the call
to Console.WriteLine is to the local variable i declared in "Main". At the
same time, it specifies that this reference is illegal, because it precedes
its definition ("int i = 37"). In short: the expected result is a
compilation error ("csc" reports error CS0136 on the example above).

How often does this happen? 
Always



---- Additional Comments From miguel@ximian.com 2002-04-09 13:01:57 MST ----

I will be taking care of it.



---- Additional Comments From miguel@ximian.com 2002-05-08 21:15:04 MST ----



*** This bug has been marked as a duplicate of https://bugzilla.novell.com/show_bug.cgi?id=MONO22724 ***


Unknown bug field "cf_op_sys_details" encountered while moving bug
   <cf_op_sys_details>SuSE Linux 7.1</cf_op_sys_details>
Unknown operating system unknown. Setting to default OS "Other".
This bug was marked DUPLICATE in the database it was moved from.
    Changing resolution to "MOVED"