Fable: Compiler hangs on method taking a type with unit of measure derived from another unit of measure

Created on 13 Dec 2020  路  3Comments  路  Source: fable-compiler/Fable

Description

Writing a method that takes a type with a unit of measure causes the compiler to hang forever with no error, but only if the measure is derived from another measure.

Repro code

[<Measure>] type Measure1
[<Measure>] type Measure2 = Measure1

type Class() =
    member _.Method(x: float<Measure2>) = x

The bug is also present for static methods.

Related information

Fable version: 3.0.1 on https://fable.io/repl/#

Most helpful comment

Thanks a lot for reporting @theprash and for the pointer @inosik! There was a version of nonAbbreviatedType in OverloadSuffix that still could fall in the infinite loop. It only affects class members so we didn't see it before. I should put the helper in a common module somewhere to avoid these issues, but for now I just copied the code. It will be fixed in the next release 馃憤

All 3 comments

This rings a bell: #1975

@theprash Would you try to use metre instead of m, please? It's in the Microsoft.FSharp.Data.UnitSystems.SI.UnitNames namespace.

@inosik Yes, this only happens when the unit of measure is derived from another one. I'll update the title and the repro code.

Thanks a lot for reporting @theprash and for the pointer @inosik! There was a version of nonAbbreviatedType in OverloadSuffix that still could fall in the infinite loop. It only affects class members so we didn't see it before. I should put the helper in a common module somewhere to avoid these issues, but for now I just copied the code. It will be fixed in the next release 馃憤

Was this page helpful?
0 / 5 - 0 ratings

Related issues

alfonsogarciacaro picture alfonsogarciacaro  路  3Comments

SirUppyPancakes picture SirUppyPancakes  路  3Comments

stkb picture stkb  路  3Comments

alfonsogarciacaro picture alfonsogarciacaro  路  3Comments

funlambda picture funlambda  路  4Comments