Skip to content

Commit

Permalink
Fix internal error when missing measure attribute in an unsolved meas…
Browse files Browse the repository at this point in the history
…ure typar (#18234)
  • Loading branch information
edgarfgp authored Jan 20, 2025
1 parent 72ab794 commit 5bfbc6d
Show file tree
Hide file tree
Showing 18 changed files with 123 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/release-notes/.FSharp.Compiler.Service/9.0.300.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
### Fixed

* Fix Realsig+ generates nested closures with incorrect Generic ([Issue #17797](https://github.com/dotnet/fsharp/issues/17797), [PR #17877](https://github.com/dotnet/fsharp/pull/17877))
* Fix internal error when missing measure attribute in an unsolved measure typar. ([Issue #7491](https://github.com/dotnet/fsharp/issues/7491), [PR #18234](https://github.com/dotnet/fsharp/pull/18234)==
* Set `Cancellable.token` from async computation ([Issue #18235](https://github.com/dotnet/fsharp/issues/18235), [PR #18238](https://github.com/dotnet/fsharp/pull/18238))

### Added
Expand Down
1 change: 1 addition & 0 deletions src/Compiler/FSComp.txt
Original file line number Diff line number Diff line change
Expand Up @@ -1789,5 +1789,6 @@ featureUseTypeSubsumptionCache,"Use type conversion cache during compilation"
3872,tcPartialActivePattern,"Multi-case partial active patterns are not supported. Consider using a single-case partial active pattern or a full active pattern."
featureDontWarnOnUppercaseIdentifiersInBindingPatterns,"Don't warn on uppercase identifiers in binding patterns"
3873,chkDeprecatePlacesWhereSeqCanBeOmitted,"This construct is deprecated. Sequence expressions should be of the form 'seq {{ ... }}'"
3874,tcExpectedTypeParamMarkedWithUnitOfMeasureAttribute,"Expected unit-of-measure type parameter must be marked with the [<Measure>] attribute."
featureDeprecatePlacesWhereSeqCanBeOmitted,"Deprecate places where 'seq' can be omitted"
featureSupportValueOptionsAsOptionalParameters,"Support ValueOption as valid type for optional member parameters"
3 changes: 3 additions & 0 deletions src/Compiler/TypedTree/TypedTreeOps.fs
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,9 @@ and remapMeasureAux tyenv unt =
| Some tpTy ->
match tpTy with
| TType_measure unt -> unt
| TType_var(typar= typar) when tp.Kind = TyparKind.Measure ->
// This is a measure typar that is not yet solved, so we can't remap it
error(Error(FSComp.SR.tcExpectedTypeParamMarkedWithUnitOfMeasureAttribute(), typar.Range))
| _ -> failwith "remapMeasureAux: incorrect kinds"
| None -> unt
| Some (TType_measure unt) -> remapMeasureAux tyenv unt
Expand Down
5 changes: 5 additions & 0 deletions src/Compiler/xlf/FSComp.txt.cs.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions src/Compiler/xlf/FSComp.txt.de.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions src/Compiler/xlf/FSComp.txt.es.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions src/Compiler/xlf/FSComp.txt.fr.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions src/Compiler/xlf/FSComp.txt.it.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions src/Compiler/xlf/FSComp.txt.ja.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions src/Compiler/xlf/FSComp.txt.ko.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions src/Compiler/xlf/FSComp.txt.pl.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions src/Compiler/xlf/FSComp.txt.pt-BR.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions src/Compiler/xlf/FSComp.txt.ru.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions src/Compiler/xlf/FSComp.txt.tr.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions src/Compiler/xlf/FSComp.txt.zh-Hans.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions src/Compiler/xlf/FSComp.txt.zh-Hant.xlf

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information.

module ErrorMessages.UnitOfMeasureTests

open Xunit
open FSharp.Test.Compiler

[<Fact>]
let ``Error - Expected unit-of-measure type parameter must be marked with the [<Measure>] attribute.`` () =
Fsx """
type A<[<Measure>]'u>(x : int<'u>) =
member this.X = x

type B<'u>(x: 'u) =
member this.X = x

module M =
type A<'u> with // Note the missing Measure attribute
member this.Y = this.X

type B<'u> with
member this.Y = this.X

open System.Runtime.CompilerServices
type FooExt =
[<Extension>]
static member Bar(this: A<'u>, value: A<'u>) = this
"""
|> typecheck
|> shouldFail
|> withDiagnostics [
(Error 3874, Line 9, Col 12, Line 9, Col 14, "Expected unit-of-measure type parameter must be marked with the [<Measure>] attribute.")
]

[<Fact>]
let ``Expected unit-of-measure type parameter must be marked with the [<Measure>] attribute.`` () =
Fsx """
type A<[<Measure>]'u>(x : int<'u>) =
member this.X = x

module M =
type A<[<Measure>] 'u> with // Note the Measure attribute
member this.Y = this.X

open System.Runtime.CompilerServices
type FooExt =
[<Extension>]
static member Bar(this: A<'u>, value: A<'u>) = this
"""
|> typecheck
|> shouldSucceed

Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,7 @@
<Compile Include="ErrorMessages\InterfaceImplInAugmentationsTests.fs" />
<Compile Include="ErrorMessages\ExtendedDiagnosticDataTests.fs" />
<Compile Include="ErrorMessages\ActivePatternArgCountMismatchTest.fs" />
<Compile Include="ErrorMessages\UnitOfMeasureTests.fs" />
<Compile Include="Language\IndexerSetterParamArray.fs" />
<Compile Include="Language\MultiDimensionalArrayTests.fs" />
<Compile Include="Language\RegressionTests.fs" />
Expand Down

0 comments on commit 5bfbc6d

Please sign in to comment.