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

Currying issue #3397

Closed
JaggerJo opened this issue Mar 31, 2023 · 1 comment · Fixed by #3399
Closed

Currying issue #3397

JaggerJo opened this issue Mar 31, 2023 · 1 comment · Fixed by #3399

Comments

@JaggerJo
Copy link

JaggerJo commented Mar 31, 2023

Description

When calling curried functions from other projects the functions get un-curried. This leads to the following exception:

TypeError: Cannot read properties of undefined (reading '0')

Repro

Create a fsharp library that includes the following code:

namespace Repro

#if FABLE_COMPILER
open Thoth.Json
#else
open Thoth.Json.Net
#endif

type Person = {
    First: string
    Last: string
}

[<AutoOpen>]
module PersonExtensions =

    [<RequireQualifiedAccess>]
    module Person =

        let decode =
            Decode.object(fun get ->
                let epoch = get.Required.Field "first" Decode.string
                let timezoneId = get.Required.Field "last" Decode.string
                { Person.First = epoch; Person.Last = timezoneId }
            )

    type Person with

        static member Decode (path: string) (value: JsonValue) =
            Person.decode path value

Add a reference to Thoth.Json (Version="5.1.0")

Call the decode function in a project referencing the library.

module Test = 

#else
    open Thoth.Json.Net
    open Expecto
#endif

    open Repro

    let test () =
        let json =
            """
            {
                "first": "John",
                "last": "Doe"
            }
            """

        let person: Person = Decode.unsafeFromString Person.decode json
        ()

Calling test fails as the decode function is un-curried by the compiler.

TypeError: Cannot read properties of undefined (reading '0')

Related information

  • Fable version: 4.0.3
  • Operating system: MacOS 13.2.1 (22D68)
@alfonsogarciacaro
Copy link
Member

Thanks for reporting! I can reproduce: https://github.com/alfonsogarciacaro/repro-3397

I will fix it for the next release 👍

alfonsogarciacaro added a commit that referenced this issue Apr 1, 2023
* Fix #3397: Curry only user imports

* Add regression test
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants