Compilers fails to compile module with same name as Record using Unit of Measure generic type declared before
See original GitHub issuePlease provide a succinct description of the issue.
Repro steps
Provide the steps required to reproduce the problem:
- Copy the following code into a
.fsx
or.fs
file:
type Animal<[<Measure>] 'Measure> =
{
Size : float
}
module Animal =
let create (s: float<'Measure>) : Animal<'Measure> =
{ Size = float s }
- Observe that the compiler throws an error for the
Animal
module.
If possible attach a zip file with the repro case. This often makes it easier for others to reproduce. The zip file should ideally represent the situation just before the call/step that is problematic.
Expected behavior
The compiler should compile.
Actual behavior
Compiler says there is a duplicate definition of the Animal
type
Known workarounds
Annotate the Animal
module with the [<CompilationRepresentation(CompilationRepresentationFlags.ModuleSuffix)>]
attribute.
Related information
Provide any related information (optional):
- Operating system
- .NET Runtime kind (.NET Core, .NET Framework, Mono)
- Editing Tools (e.g. Visual Studio Version, Visual Studio)
Issue Analytics
- State:
- Created a year ago
- Comments:9 (7 by maintainers)
Top Results From Across the Web
Generic method does not compile when passed a ...
I have included a simplified version of the issue. In the following example, the program will not compile because of the method broken...
Read more >What I wish I knew when learning F#
F# uses a lot of top level values and functions and so F# introduced modules since Namespaces can't contain them directly. These do...
Read more >1 Compiler Release Notes
1.2 Compiler 7.1.4. Fixed Bugs and Malfunctions. The 'deterministic' option was not recognized when given in a -compile() attribute in the source code....
Read more >F# coding conventions
FSharp.Collections.List module has this attribute. This is useful when functions and values in the module have names that are likely to conflict ...
Read more >Using the GNU Compiler Collection
Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.3 or any...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Matt:
In SyntaxTree, the typar (TYpeARgument) has the following shape, with attributes on it: [<NoEquality; NoComparison>] type SynTyparDecl = SynTyparDecl of attributes: SynAttributes * SynTypar
So this check should be possible.
Here is what I would do: Add new test-file by mimicing what the neighborhood tests are doing, I would place this one at : \tests*FSharp.Compiler.ComponentTests*\Conformance*UnitsOfMeasure*\
Cover the following via separate test cases (in the end almost identical)
And add a breakpoint to the set-building function above and inspect. Focus on the SynComponentInfo(typeParams=TyparDecls typars and if isNil typars then parts
This doesn’t seem to reproduce anymore in latest F#/VS.