Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

internal error when implementing interface with auto property in record type (Unexpected definition (AutoProperty...) #13690

Closed
smoothdeveloper opened this issue Aug 15, 2022 · 8 comments
Assignees
Labels
Area-Compiler-Checking Type checking, attributes and all aspects of logic checking Bug Impact-Medium (Internal MS Team use only) Describes an issue with moderate impact on existing code.
Milestone

Comments

@smoothdeveloper
Copy link
Contributor

Under .net framework FSI, I'm getting internal error:

Repro steps

type Foo =
  abstract member X : string with get, set

type FooImpl = 
  { name: string }
  interface Foo with
    member val X = "" with get, set

Actual behavior

error FS0073: internal error: Unexpected definition (AutoProperty
   ([], false, X, None, PropertyGetSet, <fun:_fsyacc_reductions@2322-424>,
    PreXmlDoc ((7,4), FSharp.Compiler.Xml.XmlDocCollector), None,
    \test.fsx (7,17--7,18),
    Const
      (String
         ("", Regular,
          \test.fsx (7,19--7,21)),
       \test.fsx (7,19--7,21)),
    Some
      \test.fsx (7,22--7,26),
    Some
      \test.fsx (7,22--7,35),
    \test.fsx (7,4--7,21)),
 ContainerInfo
  (Parent FSI_0002,
   Some
     (MemberOrValContainerInfo
        (FooImpl,
         Some
           (Foo,
            SlotImplSet
              ([RequiredSlot (FSMeth (<TcGlobals>, Foo, X, None), false);
                RequiredSlot (FSMeth (<TcGlobals>, Foo, X, None), false)],
               map
                 [("get_X",
                   [RequiredSlot (FSMeth (<TcGlobals>, Foo, X, None), false)]);
                  ("set_X",
                   [RequiredSlot (FSMeth (<TcGlobals>, Foo, X, None), false)])],
               [], [FSProp (<TcGlobals>, Foo, Some X, Some X)])), None,
         NoSafeInitInfo, []))))

Expected behavior

Compiles.

Known workarounds

To not use a record.

Related information

  • Windows 11
  • .NET Framework 4.8 FSI
  • VS 2022 17.2.6
@vzarytovskii
Copy link
Member

vzarytovskii commented Aug 15, 2022

@nojaf should this also be fixed by #13664 or was it only for exception?

Update: probably not, since the change is specific to Exception, and this one is autoprop

@vzarytovskii
Copy link
Member

vzarytovskii commented Aug 15, 2022

type Foo =
    abstract member X : string with get, set

type FooImpl = 
    interface Foo with
      member val X = "" with get, set

Also fails but for a different reason:

        member val X = "" with get, set;;
  ---------------------^^

stdin(6,22): error FS0971: Undefined value 'X@'

But this code is weird regardless, since FooImpl doesn't have constructor and won't be able to set the underlying X@ to the default value.

@vzarytovskii
Copy link
Member

This works, though:

type Foo =
    abstract member X : string with get, set

type FooImpl() = 
    interface Foo with
      member val X = "" with get, set

@vzarytovskii
Copy link
Member

Interesting, it also fails on sharplab, which uses 10 months old FCS. It seems bug is there for some time and unrelated to Florian's changes.

@vzarytovskii
Copy link
Member

vzarytovskii commented Aug 15, 2022

So, we've checked it, and it's broken since at least 3.1.412, not something we introduced recently.
We should probably emit different error if we try to have autoproperties on constructor-less types, since we don't generate implicit constructors and I guess it makes no sense having auto-properties on such types.
And we should fix the case for the records, I guess?

cc @dsyme @0101

@vzarytovskii vzarytovskii added Area-Compiler-Checking Type checking, attributes and all aspects of logic checking Area-Compiler-CodeGen IlxGen, ilwrite and things at the backend labels Aug 16, 2022
@vzarytovskii vzarytovskii moved this to Not Planned in F# Compiler and Tooling Aug 16, 2022
@vzarytovskii vzarytovskii added this to the Backlog milestone Aug 16, 2022
@dsyme dsyme removed the Area-Compiler-CodeGen IlxGen, ilwrite and things at the backend label Sep 21, 2022
@dsyme dsyme self-assigned this Sep 21, 2022
@edgarfgp
Copy link
Contributor

edgarfgp commented Jan 14, 2023

@vzarytovskii Any decision here ? . Happy to help with error reporting

@edgarfgp
Copy link
Contributor

The internal error reported in this issue has been fixed at some point in F# 8 likely by #15343. We have now an error an error message This declaration element is not permitted in an augmentation.

Screenshot 2023-11-26 at 18 37 25

We could close this issue and raise separate issues for :

  • Raise a new error if we try to have auto properties on constructor-less types,
  • Fix the case for the records supporting auto properties

@edgarfgp
Copy link
Contributor

edgarfgp commented Dec 13, 2023

@vzarytovskii This can be closed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Compiler-Checking Type checking, attributes and all aspects of logic checking Bug Impact-Medium (Internal MS Team use only) Describes an issue with moderate impact on existing code.
Projects
Archived in project
Development

No branches or pull requests

4 participants