Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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,42 @@
// 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
"""
|> 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
"""
|> 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
Loading