Bug 319198 (MONO76333) - Referencing method member as prop/field in foreach dies
Summary: Referencing method member as prop/field in foreach dies
Status: RESOLVED MOVED
Alias: MONO76333
Product: Mono: Compilers
Classification: Mono
Component: C# (show other bugs)
Version: 1.1
Hardware: Other Other
: P3 - Medium : Normal
Target Milestone: ---
Assignee: Raja R Harinath
QA Contact: Mono Bugs
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2005-10-05 03:35 UTC by Peter Johanson
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 19:33:33 UTC


---- Reported by latexer@gentoo.org 2005-10-04 20:35:16 MST ----

Description of Problem: Accidentially referencing a member method as if it
were a field or property inside a foreach declaration makes mcs freak.

The following test case makes mcs freak out with a nasty error message on
mono-1.1.9.1 here:

<snip>
using System;
using System.Text.RegularExpressions;

public class MainClass
{
        public static void Main (string[] args)
        {
                Regex reg = new Regex (@"\w");

                foreach (Match match in reg.Matches)
                {
                        Console.WriteLine("Match: |{0}|", match);
                }
        }
}
</snip>

Inside the foreach, "Matches" is attempted to be referenced as a
field/property, when it really should be 'reg.Matches("some string")'. The
same mistake outside of the foreach conditional does *not* cause this
error. Here is the full error message:
<snip>
peter@stu ~/csharp/playground $ mcs foreach-fubar.cs 
Exception caught by the compiler while compiling:
   Block that caused the problem begin at: foreach-fubar.cs(7,21):
                     Block being compiled: [Internal(1,1):,Internal(1,1):]
System.NullReferenceException: Object reference not set to an instance of
an object

Unhandled Exception: System.NullReferenceException: Object reference not
set to an instance of an object
in <0x000ec> Mono.CSharp.Foreach:Resolve (Mono.CSharp.EmitContext ec)
in <0x001b6> Mono.CSharp.Block:Resolve (Mono.CSharp.EmitContext ec)
in <0x001b6> Mono.CSharp.Block:Resolve (Mono.CSharp.EmitContext ec)
in <0x00122> Mono.CSharp.EmitContext:ResolveTopBlock
(Mono.CSharp.EmitContext anonymous_method_host, Mono.CSharp.ToplevelBlock
block, Mono.CSharp.InternalParameters ip, IMethodData md, System.Boolean
unreachable)
</snip.

Let me know if any further information is required.



---- Additional Comments From marek.safar@seznam.cz 2005-10-05 04:54:43 MST ----



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


Unknown bug field "cf_op_sys_details" encountered while moving bug
   <cf_op_sys_details>Gentoo</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"