Skip to content

Units-of-measure changes between F# projects aren't always noticed by Build, requiring Rebuild to fix errors #19049

@vsfeedback

Description

@vsfeedback

This issue has been moved from a ticket on Developer Community.


Repro case is in https://github.com/marklam/UnitsMismatch - the README is copied below:

This repository demonstrates a bug in the F# build system related to type providers and units of measure across different projects.
The issue is that changing the unit of measure in a record type is not always noticed by the build system, causing errors to not appear, or not go away
(depending on whether your edit is causing or fixing a units-of-measure mismatch).

Steps to Reproduce

  1. **Initial State (build error) **

    • In ClassLibrary1/TypeWIthUnits.fs, the record is defined as:
      type RecordWithUnits =
          {
              Value: int<a>
          }
    • In UnitsMismatch/Usage.fs), a value of type int<b> is supplied to RecordWithUnits.
    • Result: The project will not build due to a units-of-measure mismatch error.
  2. Change the UOM (to fix the error)

    • Change the declaration of RecordWithUnits to:
      type RecordWithUnits =
          {
              Value: int<b>
          }
    • Action: Perform a Build (not Rebuild).
    • Result: The build fails with the same error as before, even though the code should now be correct.
  3. Perform a Rebuild

    • Now perform a Rebuild operation.
    • Result: The build succeeds as expected.
  4. Change Back to Original UOM (to cause a build error)

    • Change the declaration of RecordWithUnits back to:
      type RecordWithUnits =
          {
              Value: int<a>
          }
    • Action: Perform a Build.
    • Result: The build succeeds, even though it should fail due to the units-of-measure mismatch.
  5. Rebuild Again

    • Perform a Rebuild.
    • Result: The expected build error appears.

Summary

  • Build does not always pick up changes to units of measure in record types, leading to stale or incorrect build results.
  • Rebuild is required to get the correct build status after such changes.

Expected Behavior

Changing the unit of measure in a type definition should always result in the correct build errors or success, even with an incremental Build.

Actual Behavior

Build does not always detect changes to units of measure, leading to confusing or incorrect build results. Only a full Rebuild produces the correct outcome.


Original Comments

Feedback Bot on 9/17/2025, 05:08 AM:

We have directed your feedback to the appropriate engineering team for further evaluation. The team will review the feedback and notify you about the next steps.

Metadata

Metadata

Assignees

Type

No type

Projects

Status

New

Relationships

None yet

Development

No branches or pull requests

Issue actions