Skip to content

Commit

Permalink
Merge pull request #1318 from dsyme/fix-823
Browse files Browse the repository at this point in the history
Fix 823 - Compiler failing with ArgumentException when calling data constructor with equality operator
  • Loading branch information
dsyme authored Jul 21, 2016
2 parents bde69ea + f3c170d commit 29440cf
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/fsharp/TypeChecker.fs
Original file line number Diff line number Diff line change
Expand Up @@ -8263,16 +8263,16 @@ and TcItemThen cenv overallTy env tpenv (item,mItem,rest,afterOverloadResolution
else error(Error(FSComp.SR.tcUnionCaseFieldCannotBeUsedMoreThanOnce(id.idText), id.idRange))
currentIndex <- SEEN_NAMED_ARGUMENT
| None ->
// ambiguity may apprear only when if argument is boolean\generic.
// ambiguity may appear only when if argument is boolean\generic.
// if
// - we didn't find argument with specified name AND
// - we have not seen any named arguments so far AND
// - type of current argument is bool\generic
// then we'll favor old behavior and treat current argument as positional.
let isSpecialCaseForBackwardCompatibility =
if currentIndex = SEEN_NAMED_ARGUMENT then false
else
match stripTyEqns cenv.g (List.item currentIndex argtys) with
(currentIndex <> SEEN_NAMED_ARGUMENT) &&
(currentIndex < nargtys) &&
match stripTyEqns cenv.g argtys.[currentIndex] with
| TType_app(tcref, _) -> tyconRefEq cenv.g cenv.g.bool_tcr tcref || tyconRefEq cenv.g cenv.g.system_Bool_tcref tcref
| TType_var(_) -> true
| _ -> false
Expand Down
4 changes: 4 additions & 0 deletions tests/fsharp/core/libtest/test.fsx
Original file line number Diff line number Diff line change
Expand Up @@ -5662,6 +5662,10 @@ module Regression_139182 =
static member Prop4 = str.ToLower() // ok
member x.Prop5 = s2.TheMethod() // ok

module LittleTestFor823 =
let x, y = 1, 2
let v = Some ((x = y), (x = x))

(*---------------------------------------------------------------------------
!* wrap up
*--------------------------------------------------------------------------- *)
Expand Down

0 comments on commit 29440cf

Please sign in to comment.