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

Show obsolete warnings/errors when used with unit of measure #18182

Open
wants to merge 20 commits into
base: main
Choose a base branch
from

Conversation

edgarfgp
Copy link
Contributor

@edgarfgp edgarfgp commented Dec 29, 2024

Description

Fixes #18181

Before

  • No warnings/errors shown when using UOM marked as Obsolete
open System

[<Measure; Obsolete("Use kg2", true)>]
type kg

// Distance, meters.
[<Measure; Obsolete("Use m2")>] type m

// Time, seconds.
[<Measure; Obsolete("Use s2")>] type s

let genericSumUnits ( x : float<'u>) (y: float<'u>) = x + y

let genericSumUnits2 ( x : float<m>) (y: float<s>) = ()

let v1 = 3.1<m/s>

let v2 = 2.7<m/s>

let x1 = 1.2<m>

let t1 = 1.0<s>

[<Measure>] type m

[<Measure; Obsolete("Use s2", true)>]
type s

// Force, Newtons.
[<Measure>] type N = kg m / s^2

After

  • Warnings/Errors shown when using UOM marked as Obsolete
open System

[<Measure; Obsolete("Use kg2", true)>]
type kg

// Distance, meters.
[<Measure; Obsolete("Use m2")>] type m

// Time, seconds.
[<Measure; Obsolete("Use s2")>] type s

let genericSumUnits ( x : float<'u>) (y: float<'u>) = x + y

let genericSumUnits2 ( x : float<m>) (y: float<s>) = () // raises obsolete warnings

let v1 = 3.1<m/s> // raises obsolete warnings

let v2 = 2.7<m/s> // raises obsolete warnings

let x1 = 1.2<m> // raises obsolete warnings

let t1 = 1.0<s> // raises obsolete warnings

// Force, Newtons.
[<Measure>] type N = kg m / s^2 // raises obsolete warnings

Checklist

  • Test cases added
  • Release notes entry updated

Copy link
Contributor

github-actions bot commented Dec 29, 2024

❗ Release notes required


✅ Found changes and release notes in following paths:

Change path Release notes path Description
src/Compiler docs/release-notes/.FSharp.Compiler.Service/9.0.200.md

@edgarfgp edgarfgp closed this Dec 29, 2024
@edgarfgp edgarfgp reopened this Dec 29, 2024
@edgarfgp edgarfgp marked this pull request as ready for review December 30, 2024 14:28
@edgarfgp edgarfgp requested a review from a team as a code owner December 30, 2024 14:28

/// A product of two units of measure
| Prod of measure1: Measure * measure2: Measure
| Prod of measure1: Measure * measure2: Measure * range: range
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The newly added code in TypedTreeOps is assigning range0 to the range anyway, is there a codepath assigning a meaningful value to it (and different from measure1/2.Range) ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Obsolete attribute warning/error is not taken into account when used with a unit of measure
2 participants