Skip to content

Commit 73c80ff

Browse files
committed
merge main
2 parents 25357f8 + 6ec56c2 commit 73c80ff

File tree

4 files changed

+26
-6
lines changed

4 files changed

+26
-6
lines changed

docs/release-notes/.FSharp.Compiler.Service/11.0.0.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
* Fix: warn FS0049 on upper union case label. ([PR #19003](https://github.com/dotnet/fsharp/pull/19003))
88
* Type relations cache: handle potentially "infinite" types ([PR #19010](https://github.com/dotnet/fsharp/pull/19010))
99
* Disallow recursive structs with lifted type parameters ([Issue #18993](https://github.com/dotnet/fsharp/issues/18993), [PR #19031](https://github.com/dotnet/fsharp/pull/19031))
10+
* Fix units-of-measure changes not invalidating incremental builds. ([Issue #19049](https://github.com/dotnet/fsharp/issues/19049))
1011
* Type relations cache: handle unsolved type variables ([Issue #19037](https://github.com/dotnet/fsharp/issues/19037)) ([PR #19040](https://github.com/dotnet/fsharp/pull/19040))
1112

1213
### Added

src/Compiler/Utilities/TypeHashing.fs

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -185,13 +185,22 @@ module rec HashTypes =
185185
|> pipeToHash memberHash
186186

187187
/// Hash a unit of measure expression
188-
let private hashMeasure unt =
189-
let measuresWithExponents =
188+
let private hashMeasure g unt =
189+
let measureVarsWithExponents =
190190
ListMeasureVarOccsWithNonZeroExponents unt
191191
|> List.sortBy (fun (tp: Typar, _) -> tp.DisplayName)
192192

193-
measuresWithExponents
194-
|> hashListOrderIndependent (fun (typar, exp: Rational) -> hashTyparRef typar @@ hash exp)
193+
let measureConsWithExponents = ListMeasureConOccsWithNonZeroExponents g false unt
194+
195+
let varHash =
196+
measureVarsWithExponents
197+
|> hashListOrderIndependent (fun (typar, exp: Rational) -> hashTyparRef typar @@ hash exp)
198+
199+
let conHash =
200+
measureConsWithExponents
201+
|> hashListOrderIndependent (fun (tcref, exp: Rational) -> hashTyconRef tcref @@ hash exp)
202+
203+
varHash @@ conHash
195204

196205
/// Hash a type, taking precedence into account to insert brackets where needed
197206
let hashTType (g: TcGlobals) ty =
@@ -214,7 +223,7 @@ module rec HashTypes =
214223
let argTys, retTy = stripFunTy g ty
215224
argTys |> hashListOrderMatters (hashTType g) |> pipeToHash (hashTType g retTy)
216225
| TType_var(r, _) -> hashTyparRefWithInfo r
217-
| TType_measure unt -> hashMeasure unt
226+
| TType_measure unt -> hashMeasure g unt
218227

219228
// Hash a single argument, including its name and type
220229
let private hashArgInfo (g: TcGlobals) (ty, argInfo: ArgReprInfo) =

tests/FSharp.Compiler.ComponentTests/Signatures/ImpliedSignatureHashTests.fs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,16 @@ type BAttribute() =
288288
289289
let a ([<B>] c: int) : int = 0 """)>]
290290

291+
[<InlineDataAttribute("UnitsOfMeasureChanged",
292+
(*BEFORE*)"""module MyTest
293+
[<Measure>] type kg
294+
[<Measure>] type m
295+
type MyRecord = { Mass: int<kg> }"""
296+
(*AFTER*),"""module MyTest
297+
[<Measure>] type kg
298+
[<Measure>] type m
299+
type MyRecord = { Mass: int<m> }""")>]
300+
291301
//TODO add a lot more negative tests - in which cases should hash in fact change
292302

293303
[<Theory>]

vsintegration/src/FSharp.ProjectSystem.Base/ConfigProvider.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ private void AddOutputPath(Microsoft.Build.Construction.ProjectPropertyGroupElem
261261
string outputBasePath = this.ProjectMgr.OutputBaseRelativePath;
262262
if (outputBasePath.EndsWith(Path.DirectorySeparatorChar.ToString(), StringComparison.Ordinal))
263263
outputBasePath = Path.GetDirectoryName(outputBasePath);
264-
newConfig.AddProperty("OutputPath", Path.Combine(outputBasePath, configName) + Path.DirectorySeparatorChar.ToString());
264+
newConfig.AddProperty("OutputPath", Path.Combine(outputBasePath, configName) + Path.DirectorySeparatorChar.ToString());
265265

266266
}
267267

0 commit comments

Comments
 (0)