From 0b7fcd39ebe91bee81579c4f96b51000defaec4f Mon Sep 17 00:00:00 2001 From: Alfonso Garcia-Caro Date: Thu, 21 Feb 2019 22:06:01 +0100 Subject: [PATCH] Fix prototype of anonymous records --- src/fable-library/Types.js | 2 +- src/quicktest/QuickTest.fs | 8 -------- tests/Main/RecordTypeTests.fs | 5 +++++ 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/src/fable-library/Types.js b/src/fable-library/Types.js index 037e7e36a6..9ebc3b32a6 100644 --- a/src/fable-library/Types.js +++ b/src/fable-library/Types.js @@ -216,7 +216,7 @@ Record.prototype.CompareTo = function(other) { }; export function anonRecord(o) { - return Object.assign(Object.create(Record), o); + return Object.assign(Object.create(Record.prototype), o); } export const FSharpRef = declare(function FSharpRef(contents) { diff --git a/src/quicktest/QuickTest.fs b/src/quicktest/QuickTest.fs index 1310e940f6..5b023ba369 100644 --- a/src/quicktest/QuickTest.fs +++ b/src/quicktest/QuickTest.fs @@ -49,11 +49,3 @@ let testCaseAsync msg f = // to Fable.Tests project. For example: // testCase "Addition works" <| fun () -> // 2 + 2 |> equal 4 - -let makeAnonRec() = - {| X = 5; Y = "Foo"; F = fun x y -> x + y |} - -testCase "Anonymous records work" <| fun () -> - let r = makeAnonRec() - sprintf "Tell me %s %i times" r.Y (r.F r.X 3) - |> equal "Tell me Foo 8 times" \ No newline at end of file diff --git a/tests/Main/RecordTypeTests.fs b/tests/Main/RecordTypeTests.fs index f3873014b8..eff53d9196 100644 --- a/tests/Main/RecordTypeTests.fs +++ b/tests/Main/RecordTypeTests.fs @@ -43,6 +43,11 @@ let tests = let r = makeAnonRec() sprintf "Tell me %s %i times" r.Y (r.F r.X 3) |> equal "Tell me Foo 8 times" + let x = {| Foo = "baz"; Bar = 23 |} + let y = {| Foo = "baz" |} + x = {| y with Bar = 23 |} |> equal true + // x = {| y with Baz = 23 |} |> equal true // Doesn't compile + x = {| y with Bar = 14 |} |> equal false #endif testCase "Recursive record does not cause issues" <| fun () ->