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

FSI generates internal error: Index not found with Struct DU #2363

Closed
cartermp opened this issue Feb 3, 2017 · 9 comments
Closed

FSI generates internal error: Index not found with Struct DU #2363

cartermp opened this issue Feb 3, 2017 · 9 comments
Labels
Area-FSI Bug Impact-Medium (Internal MS Team use only) Describes an issue with moderate impact on existing code.

Comments

@cartermp
Copy link
Contributor

cartermp commented Feb 3, 2017

  1. Open FSI via command line or F# Interactive
  2. Enter the following:
[<Struct>]
type Shape =
    | Circle of radius: float
    | Square of side: float
    | Triangle of height: float * width: float

Expected: FSI executes and the type is registered.
Actual: error FS0193: internal error: Index not found. (Exception from HResult: 0x80131124

internal-error-struct-du
internal-error-struct-du-fsi

@kbattocchi
Copy link
Contributor

Are multi-case struct DUs supposed to work? I thought only single-case DUs could be represented as structs. (That is, I thought the expected behavior would be a compile-time error, not runtime success)

@cartermp
Copy link
Contributor Author

cartermp commented Feb 3, 2017

@kbattocchi Multicase DUs are now supported in F# 4.1, although there is currently a bug with them: #1678

@kbattocchi
Copy link
Contributor

kbattocchi commented Feb 3, 2017

I see; it looks like the RFC states

For multi-case struct unions, each case must have a unique name.

but presumably this was supposed to say unique type instead? In which case this would again be expected to fail at compile-time.

(As an aside, I had trouble finding the RFC because several of the links to it are dead since it was moved from /RFCs to /FSharp-4.1)

@cartermp
Copy link
Contributor Author

cartermp commented Feb 3, 2017

@dsyme could comment further, but the intention to my understanding is that they simply require unique names. They shouldn't also require unique types.

@KevinRansom
Copy link
Member

KevinRansom commented Feb 3, 2017

@kbattocchi
Well .. it works fine if it's not a struct so it seems like it should work for struct DUs too

Works in FSI

type StructShape =
    | Circle of radius: float
    | Square of side: float
    | Triangle of height: float * width: float

Fails in FSI

[<Struct>]
type StructShape =
    | Circle of radius: float
    | Square of side: float
    | Triangle of height: float * width: float

@KevinRansom
Copy link
Member

@cartermp

The compiler doesn't like it either:

// Learn more about F# at http://fsharp.org
// See the 'F# Tutorial' project for more help.

[<Struct>]
type StructShape =
    | Circle of radius: float
    | Square of side: float
    | Triangle of height: float * width: float

[<EntryPoint>]
let main argv = 
    printfn "%A" argv
    0 // return an integer exit code

Fails with:

1>FSC: error FS2014: A problem occurred writing the binary 'C:\Users\kevinr\Documents\Visual Studio 2017\Projects\ConsoleApplication31\ConsoleApplication31\obj\Debug\ConsoleApplication31.exe': Error in pass2 for type Program, error: Error in pass2 for type StructShape, error: duplicate entry '.ctor' in method table
1>Done building project "ConsoleApplication31.fsproj" -- FAILED.

@KevinRansom KevinRansom added the Impact-Medium (Internal MS Team use only) Describes an issue with moderate impact on existing code. label Feb 3, 2017
@cartermp
Copy link
Contributor Author

cartermp commented Feb 3, 2017

Same underlying issue as #1678 then. Bah.

@dsyme
Copy link
Contributor

dsyme commented Feb 4, 2017

Yes, my apologies for #1678. We will address it in F# 4.2 (or next update of F# 4.1) For now we have to list it as a known limitation.

@dsyme
Copy link
Contributor

dsyme commented Feb 4, 2017

I'll close this as a duplicate of #1678

@dsyme dsyme closed this as completed Feb 4, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-FSI Bug Impact-Medium (Internal MS Team use only) Describes an issue with moderate impact on existing code.
Projects
None yet
Development

No branches or pull requests

4 participants