Skip to content

marklam/UnitsMismatch

Repository files navigation

Units of Measure Build Bug Reproduction

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.

About

Demo of Visual Studio not noticing units of measure changin

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages