F# 3.0 inheritance question


  • Something is changed with the F# 3.0 compiler, below is my code,

    type DomBase =    
            inherit DomElement
            val htmlEl: ScriptObject

            new (htmlEl:ScriptObject) = { 
                inherit DomElement(htmlEl)
                htmlEl = htmlEl

    And I get the below errors all over my project,

    Error 5 internal error: unexpected multiple fields with same name (Failure) C:\work\bitbucket\pf\pfsrc\src\Pit.Core.dbg\Dom\Elements\DomBase.fs 14 37 Pit.Core.dbg

    I'm trying to build this code with F# 5.0 Silverlight  dll. It used to compile before.



    Thursday, October 04, 2012 12:00 PM

All replies

  • interesting one - have you tried to rename your htmlEl argument?

    My guess would be that the constructor yields the additional field just like primary-constructors do.

    Seems like a bug to me and maybe you should report this.

    Thursday, October 04, 2012 1:35 PM
  • It is sad to say that it is a regression. In F# 3.0, you might have to modifiy your code untill it is fixed in the next update. I would like to change code:

    - use a different name in the derived class, or

    - use a different class style similar to

    type DomBase(htmlEl) =    
            inherit DomElement(htmlEl)
            member val htmlEl: ScriptObject = htmlEl

    I hope it has not caused a lot of trouble, though.
    • Edited by Wonseok Chae Thursday, October 11, 2012 7:17 PM
    • Proposed as answer by ildjarn Friday, October 12, 2012 7:12 PM
    Thursday, October 11, 2012 7:14 PM