diff --git a/src/Fable.Transforms/Python/Replacements.fs b/src/Fable.Transforms/Python/Replacements.fs index 24c930b99a..47dc01eef1 100644 --- a/src/Fable.Transforms/Python/Replacements.fs +++ b/src/Fable.Transforms/Python/Replacements.fs @@ -4004,7 +4004,16 @@ let fsharpType com methName (r: SourceLocation option) t (i: CallInfo) (args: Ex | "IsRecord" | "IsTuple" | "IsFunction" -> - Helper.LibCall(com, "Reflection", Naming.lowerFirst methName, t, args, i.SignatureArgTypes, ?loc = r) + // Drop the trailing `allowAccessToPrivateRepresentation` flag (no meaning in Python) + Helper.LibCall( + com, + "Reflection", + Naming.lowerFirst methName, + t, + List.truncate 1 args, + i.SignatureArgTypes, + ?loc = r + ) |> Some | "IsExceptionRepresentation" | "GetExceptionFields" -> None // TODO!!! diff --git a/tests/Python/TestReflection.fs b/tests/Python/TestReflection.fs index 572debd8e3..3d1f86784b 100644 --- a/tests/Python/TestReflection.fs +++ b/tests/Python/TestReflection.fs @@ -223,6 +223,7 @@ let ``test reflection functions accept allowAccessToPrivateRepresentation`` () = let recordType = typeof let record = { String = "a"; Int = 1 } + FSharpType.IsRecord(recordType, allowAccessToPrivateRepresentation = true) |> equal true FSharpType.GetRecordFields(recordType, allowAccessToPrivateRepresentation = true).Length |> equal 2 let values = FSharpValue.GetRecordFields(record, allowAccessToPrivateRepresentation = true) @@ -231,7 +232,8 @@ let ``test reflection functions accept allowAccessToPrivateRepresentation`` () = rebuilt |> equal record let unionType = typeof - let intCase = FSharpType.GetUnionCases(unionType).[1] + FSharpType.IsUnion(unionType, allowAccessToPrivateRepresentation = true) |> equal true + let intCase = FSharpType.GetUnionCases(unionType, allowAccessToPrivateRepresentation = true).[1] let u = FSharpValue.MakeUnion(intCase, [| box 5 |], allowAccessToPrivateRepresentation = true) :?> MyUnion let info, fields = FSharpValue.GetUnionFields(u, unionType, allowAccessToPrivateRepresentation = true) info.Name |> equal "IntCase"