Skip to content

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

@github-actions
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
@T-Gro
Copy link
Member

T-Gro commented Jan 6, 2025

Thanks Edgar for following up on the feedback!
I will re-review this soon 👍

@vzarytovskii vzarytovskii enabled auto-merge (squash) January 9, 2025 11:38
Copy link
Contributor

@psfinaki psfinaki left a comment

Choose a reason for hiding this comment

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

Good stuff, good testing - thanks Edgar!

@vzarytovskii vzarytovskii merged commit 9ac324d into dotnet:main Jan 9, 2025
33 checks passed
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

4 participants