dotnet / dotnet/fsharp

FSharpType.Format for Units Of Measure gives unexpected results

Open
#15,843 0 comments 2 reactions 0 assignees View on GitHub
Area-UoM Bug Impact-Low
Dominant language
F#
Stars
4.3k
Forks
876
Avg merge
4d 22h
Merged PRs (30d)
144

Description

Please provide a succinct description of the issue.

While working on some IDE-Tooling I stumbled upon the results of [layoutMeasure](https://github.com/dotnet/fsharp/blob/3e8abdbf165db91d052c1bc230177cc8147c70d9/src/Compiler/Checking/NicePrint.fs#L869) in `NicePrint.fs` and found them to be rather unexpected, at least from my perspective.
Because of the rewrite of `FSharp.Compiler.Syntax.SynMeasure` to `FSharp.Compiler.TypedTree.Measure` in `CheckExpressions.fs` we also loose some information.

Some examples:
```fsharp
[]
let tester = 42<_>
```
gives
```fsharp
int // no UoM at all
```
---
```fsharp
[]
let tester = 42<1>
```
gives
```fsharp
int // no UoM at all
```
---
```fsharp
[]
let tester = 42
```
gives
```fsharp
int // please notice the changed order
```
---
```fsharp
[]
let tester = 42
```
gives
```fsharp
int // The product is printed like a sequence
```
---
```fsharp
[]
let tester = 42
```
gives
```fsharp
int // The product is printed like a sequence and the order is changed
```

As this is all pretty obvious, I'm not sure if there's a background story to this that I am not aware of. It that's the case, please tell me.
Because currently, I think the tooling clients can't really use the NicePrint facilities for UoM.

Provide the steps required to reproduce the problem:

1. Clone https://github.com/dawedawe/fsharp/tree/niceprint_uom
2. Run new tests in `\tests\service\Symbols.fs`

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.