Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
13 changes: 7 additions & 6 deletions src/Compiler/Checking/CheckExpressions.fs
Original file line number Diff line number Diff line change
Expand Up @@ -1015,15 +1015,16 @@ let MakeMemberDataAndMangledNameForMemberVal(g, tcref, isExtrinsic, attrs, implS

if not isCompGen && IsLogicalInfixOpName id.idText then
let m = id.idRange
let name = ConvertValLogicalNameToDisplayNameCore id.idText
let logicalName = id.idText
let displayName = ConvertValLogicalNameToDisplayNameCore logicalName
// Check symbolic members. Expect valSynData implied arity to be [[2]].
match SynInfo.AritiesOfArgs valSynData with
| [] | [0] -> warning(Error(FSComp.SR.memberOperatorDefinitionWithNoArguments name, m))
| [] | [0] -> warning(Error(FSComp.SR.memberOperatorDefinitionWithNoArguments displayName, m))
| n :: otherArgs ->
let opTakesThreeArgs = IsLogicalTernaryOperator name
if n<>2 && not opTakesThreeArgs then warning(Error(FSComp.SR.memberOperatorDefinitionWithNonPairArgument(name, n), m))
if n<>3 && opTakesThreeArgs then warning(Error(FSComp.SR.memberOperatorDefinitionWithNonTripleArgument(name, n), m))
if not (isNil otherArgs) then warning(Error(FSComp.SR.memberOperatorDefinitionWithCurriedArguments name, m))
let opTakesThreeArgs = IsLogicalTernaryOperator logicalName
if n<>2 && not opTakesThreeArgs then warning(Error(FSComp.SR.memberOperatorDefinitionWithNonPairArgument(displayName, n), m))
if n<>3 && opTakesThreeArgs then warning(Error(FSComp.SR.memberOperatorDefinitionWithNonTripleArgument(displayName, n), m))
if not (isNil otherArgs) then warning(Error(FSComp.SR.memberOperatorDefinitionWithCurriedArguments displayName, m))

if isExtrinsic && IsLogicalOpName id.idText then
warning(Error(FSComp.SR.tcMemberOperatorDefinitionInExtrinsic(), id.idRange))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@
<Compile Include="Language\CodeQuotationTests.fs" />
<Compile Include="Language\InterpolatedStringsTests.fs" />
<Compile Include="Language\ComputationExpressionTests.fs" />
<Compile Include="Language\DynamicAssignmentOperatorTests.fs" />
<Compile Include="Language\CastingTests.fs" />
<Compile Include="Language\NameofTests.fs" />
<Compile Include="Language\ExtensionMethodTests.fs" />
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// Copyright (c) Microsoft Corporation. All Rights Reserved. See License.txt in the project root for license information.

namespace FSharp.Compiler.ComponentTests.Language

open System
open Xunit
open FSharp.Test.Compiler

module DynamicAssignmentOperatorTests =

[<Theory>]
[<InlineData("6.0")>]
[<InlineData("7.0")>]
let ``Implementing dynamic assignment operator does not produce a warning`` version =
Fsx """
type T = T with
static member inline (?<-) (f, x, y) = f x y
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could some test also include a usage of this operator, maybe?

"""
|> withLangVersion version
|> compile
|> shouldSucceed