-
Notifications
You must be signed in to change notification settings - Fork 796
Commit
…ure typar (#18234)
- Loading branch information
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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 | ||
|