hubFS: THE place for F#

. . . are you on The Hub?
Welcome to hubFS: THE place for F# Sign in | Join | Help
in Search

Possible Bug: Declaring Events in an Interface

Last post 09-08-2008, 6:26 by RayV. 3 replies.
Sort Posts: Previous Next
  •  09-08-2008, 5:55 6971

    Possible Bug: Declaring Events in an Interface

    Is it something that I'm doing wrong or is this a bug? I am attempting to declare an interface that exposes an Event property.

    I have tried:

    #light

    type IEventSource =
        abstract Event : IEvent<string>

    type EventSource() =
        let event = new Event<string>()
       
        interface IEventSource with
            member this.Event = event.Publish
       
    // error FS0192: internal error: forceM: envGetMethB: failed: x = get_Event(...)
    // Please build a small example that reproduces this problem and report it to fsbugs@microsoft.com.


    It works fine when I don't declare and implement an interface:

    type EventSource() =
        let event = new Event<string>()
       
        member this.Event = event.Publish

  •  09-08-2008, 6:18 6973 in reply to 6971

    Re: Possible Bug: Declaring Events in an Interface

    I should have clarified that I get the above when loading the code as a script in fsi.

    If I try to compile that same code I get:
    -----------------------------------------------
    The local method 'Temp.EventSource'::'get_Event' was referenced but not declared
    generic arity: 0
    Error in mref_as_MethodDef_idx for mref = "get_Event", error: Microsoft.FSharp.Compiler.AbstractIL.BinaryWriter+Mdef_not_foundException: Exception of type 'Microsoft.FSharp.Compiler.AbstractIL.BinaryWriter+Mdef_not_foundException' was thrown.
       at Microsoft.FSharp.Compiler.AbstractIL.BinaryWriter.mdkey_as_MethodDef_idx(cenv cenv, mdkey mdkey)
       at Microsoft.FSharp.Compiler.AbstractIL.BinaryWriter.mref_as_MethodDef_idx(cenv cenv, MethodRef mref)
    typ_as_MemberRef_parent: mspec should have been encoded as mdtMethodDef?
    The local method 'Temp.EventSource'::'get_Event' was referenced but not declared
    generic arity: 0
    Error in mref_as_MethodDef_idx for mref = "get_Event", error: Microsoft.FSharp.Compiler.AbstractIL.BinaryWriter+Mdef_not_foundException: Exception of type 'Microsoft.FSharp.Compiler.AbstractIL.BinaryWriter+Mdef_not_foundException' was thrown.
       at Microsoft.FSharp.Compiler.AbstractIL.BinaryWriter.mdkey_as_MethodDef_idx(cenv cenv, mdkey mdkey)
       at Microsoft.FSharp.Compiler.AbstractIL.BinaryWriter.mref_as_MethodDef_idx(cenv cenv, MethodRef mref)
    typ_as_MemberRef_parent: mspec should have been encoded as mdtMethodDef?

  •  09-08-2008, 6:19 6974 in reply to 6973

    Re: Possible Bug: Declaring Events in an Interface

    I'm using CTP 1.9.6.0 and it compiles, but I get the same output as you.
  •  09-08-2008, 6:26 6975 in reply to 6974

    Re: Possible Bug: Declaring Events in an Interface

    Thanks for trying that out, yashez. I'm filing a bug report right now. My initial attempt to file one failed which is why I posted here but after a second check I see that I mis-typed the address...sigh...
View as RSS news feed in XML
Powered by Community Server, by Telligent Systems