Skip to content

Units of Measure applied to literal bindings are ignored #6929

@reinux

Description

@reinux

Instances of literal bindings assigned units of measure compile, but don't carry the measure.

Code to reproduce

type [<Measure>] rad
[<Literal>]
let pi = 3.14
let a = pi<rad>
let f (a:float<rad>) = a
f a

Expected behavior

Either an error on the assignment of a, or for f to accept pi

Actual behavior

Error	FS0001	This expression was expected to have type
    'float<rad>'    
but here has type
    'float'	F#

Known workarounds

let a = pi*1.<rad>

Related information

  • Windows 10
  • FSI 10.4.0 for F# 4.6
  • Visual Studio 2019

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area-Compiler-CheckingType checking, attributes and all aspects of logic checkingBugImpact-Medium(Internal MS Team use only) Describes an issue with moderate impact on existing code.

    Type

    Projects

    Status

    New

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions