Wiki

Ticket #343 (closed defect: fixed)

Opened 11 years ago

Last modified 11 years ago

A field and property that differ only by case of a type with the same name triggers an internal compiler error

Reported by: nerdzero Owned by:
Priority: major Milestone:
Component: Cobra Compiler Version: 0.9.4
Keywords: ide, monodevelop Cc:

Description

MonoDevelop recently made this change:  https://github.com/mono/monodevelop/commit/f57fbcd49275c4f99ee11e12f5b17e3937a573ee#L3R711

It adds a field called "diffTracker" of type "DiffTracker?" and a property called "DiffTracker?" also of type "DiffTracker?". This triggers a duplicate key exception in Container.addDecl when reading the MonoDevelop library.

This prevents compilation of the Cobra addin for MD/XS. Sad face.

Here's part of the stack trace:

Unhandled Exception:
System.ArgumentException: An element with the same key already exists in the dictionary.
  at System.Collections.Generic.Dictionary`2[TKey,TValue].Add (System.Collections.Generic.TKey key, System.Collections.Generic.TValue value) [0x00000] in <filename unknown>:0 
  at Container`1[IBoxMember].AddDecl (IBoxMember decl) [0x00000] in <filename unknown>:0 
  at Box._scanClrProperties () [0x00000] in <filename unknown>:0 
  at Class.ScanNativeTypeClr () [0x00000] in <filename unknown>:0 
  at ClrBackEnd.ScanNativeType (Box box) [0x00000] in <filename unknown>:0 
  at Box._scanNativeType () [0x00000] in <filename unknown>:0 
  at Box._bindInh () [0x00000] in <filename unknown>:0 
  at ClassOrStruct._bindInh () [0x00000] in <filename unknown>:0 
  at Node.BindInh () [0x00000] in <filename unknown>:0 
  at Box.BindInh () [0x00000] in <filename unknown>:0 
  at Box.__prepLibraryInh () [0x00000] in <filename unknown>:0 
  at Box._prepLibraryInh () [0x00000] in <filename unknown>:0 
  at Box._prepLibraryBox () [0x00000] in <filename unknown>:0 
  at Box.PrepIfNeeded () [0x00000] in <filename unknown>:0 
  at Box.__memberForName (System.String name) [0x00000] in <filename unknown>:0 
  at Box.__memberForNameIncludingExtensions (System.String name) [0x00000] in <filename unknown>:0 
  at Box.MemberForName (System.String name) [0x00000] in <filename unknown>:0 
  at Class.MemberForName (System.String name) [0x00000] in <filename unknown>:0 
  at NameExpr.MemberForName (System.String name) [0x00000] in <filename unknown>:0 
  at CallExpr._bindImp () [0x00000] in <filename unknown>:0 
  at Node.BindImp () [0x00000] in <filename unknown>:0 
  at Stmt.BindImp () [0x00000] in <filename unknown>:0
  ...

Change History

Changed 11 years ago by Charles

I'll take a look.

Changed 11 years ago by Charles

I tried to recreate this like so:

// Lib.cs
using System;

namespace Lib {
	
	public class Foo {
	
		protected int bar;
	
		public int Bar {
			get { return bar; }
			set { bar = value; }
		}

	}

}
mcs -t:library Lib.cs
use Lib

class P

    def main
        trace Foo
        f = Foo()
        trace f.bar
        f.bar = 2
        assert f.bar == 2
        trace f.bar
        print 'done.'

And it works fine:

    trace : Foo=Lib.Foo (MonoType)
          - at use-lib.cobra:7
          - in P.main

    trace : f.bar=0
          - at use-lib.cobra:9
          - in P.main

    trace : f.bar=2
          - at use-lib.cobra:12
          - in P.main
done.

Could it be something else?

Changed 11 years ago by Charles

Nevermind. Got it. Both members have to be public.

Changed 11 years ago by Charles

Fixed. Running tests.

Changed 11 years ago by Charles

  • status changed from new to closed
  • resolution set to fixed

Fixed in changeset:3020

Note: See TracTickets for help on using tickets.