Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix 823 - Compiler failing with ArgumentException when calling data constructor with equality operator #1318

Merged
merged 4 commits into from
Jul 21, 2016
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
8 changes: 4 additions & 4 deletions src/fsharp/TypeChecker.fs
Original file line number Diff line number Diff line change
Expand Up @@ -8249,16 +8249,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