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).
-
**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 typeint<b>is supplied toRecordWithUnits. - Result: The project will not build due to a units-of-measure mismatch error.
- In
-
**Change the UOM (to fix the error) **
- Change the declaration of
RecordWithUnitsto: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.
- Change the declaration of
-
Perform a Rebuild
- Now perform a Rebuild operation.
- Result: The build succeeds as expected.
-
**Change Back to Original UOM (to cause a build error) **
- Change the declaration of
RecordWithUnitsback 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.
- Change the declaration of
-
Rebuild Again
- Perform a Rebuild.
- Result: The expected build error appears.
- 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.
Changing the unit of measure in a type definition should always result in the correct build errors or success, even with an incremental Build.
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.