Skip to content

Commit 29440cf

Browse files
authored
Merge pull request #1318 from dsyme/fix-823
Fix 823 - Compiler failing with ArgumentException when calling data constructor with equality operator
2 parents bde69ea + f3c170d commit 29440cf

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

src/fsharp/TypeChecker.fs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8263,16 +8263,16 @@ and TcItemThen cenv overallTy env tpenv (item,mItem,rest,afterOverloadResolution
82638263
else error(Error(FSComp.SR.tcUnionCaseFieldCannotBeUsedMoreThanOnce(id.idText), id.idRange))
82648264
currentIndex <- SEEN_NAMED_ARGUMENT
82658265
| None ->
8266-
// ambiguity may apprear only when if argument is boolean\generic.
8266+
// ambiguity may appear only when if argument is boolean\generic.
82678267
// if
82688268
// - we didn't find argument with specified name AND
82698269
// - we have not seen any named arguments so far AND
82708270
// - type of current argument is bool\generic
82718271
// then we'll favor old behavior and treat current argument as positional.
82728272
let isSpecialCaseForBackwardCompatibility =
8273-
if currentIndex = SEEN_NAMED_ARGUMENT then false
8274-
else
8275-
match stripTyEqns cenv.g (List.item currentIndex argtys) with
8273+
(currentIndex <> SEEN_NAMED_ARGUMENT) &&
8274+
(currentIndex < nargtys) &&
8275+
match stripTyEqns cenv.g argtys.[currentIndex] with
82768276
| TType_app(tcref, _) -> tyconRefEq cenv.g cenv.g.bool_tcr tcref || tyconRefEq cenv.g cenv.g.system_Bool_tcref tcref
82778277
| TType_var(_) -> true
82788278
| _ -> false

tests/fsharp/core/libtest/test.fsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5662,6 +5662,10 @@ module Regression_139182 =
56625662
static member Prop4 = str.ToLower() // ok
56635663
member x.Prop5 = s2.TheMethod() // ok
56645664

5665+
module LittleTestFor823 =
5666+
let x, y = 1, 2
5667+
let v = Some ((x = y), (x = x))
5668+
56655669
(*---------------------------------------------------------------------------
56665670
!* wrap up
56675671
*--------------------------------------------------------------------------- *)

0 commit comments

Comments
 (0)