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

Naming or shadowing issue with `arguments` field in record sent through port #611

Closed
schpaa opened this Issue May 18, 2016 · 5 comments

Comments

Projects
None yet
3 participants
@schpaa

schpaa commented May 18, 2016

I want to send MyRecord through a port. But it fails with the console message:

TypeError: undefined is not an object (evaluating 'xs.ctor')

This is what I'm doing, javascript first:

app.ports.apiv1.subscribe(function(commandRecord) {
    console.log("app.ports.api... ",commandRecord)
})

in some port module I have defined the port:

port apiv1 : MyRecord -> Cmd a

where MyRecord is defined as:

type alias MyRecord =
    { command : String
    , arguments : List String
    }

somewhere in the view-function, this happens:

...
in
    flexDiv
        <| [ button [ onClick SendApiV1Message ] [ text "Send api message" ]

supported by my update-function:

...
case msg of
    SendApiV1Message ->
        let
            x : MyRecord
            x = { command = "Hello", arguments = [ "one", "tow", "three" ] }
        in
            model ! [ apiv1 x ]
...

To fix/bypass

If I change MyRecord and substitute the List String with a String, like this:

type alias MyRecord =
    { command : String
    , arguments : String
    }

there are no messages in the console, and the program works.

@schpaa

This comment has been minimized.

Show comment
Hide comment
@schpaa

schpaa May 18, 2016

Investigating further, this peculiar thing revealed itself to me:

Gives back arguments as undefined in the browser-console, all the other works.

type alias MyRecord =
    { command : String
    , arguments : String
    , extra : Int
    }

This one works, any shadowing happening with arguments here?

type alias MyRecord =
    { command : String
    , argumentodos : String
    , extra : Int
    }

schpaa commented May 18, 2016

Investigating further, this peculiar thing revealed itself to me:

Gives back arguments as undefined in the browser-console, all the other works.

type alias MyRecord =
    { command : String
    , arguments : String
    , extra : Int
    }

This one works, any shadowing happening with arguments here?

type alias MyRecord =
    { command : String
    , argumentodos : String
    , extra : Int
    }

@schpaa schpaa changed the title from Sending a Record with a List String through a Port fails to Sending a Record with a List String through a Port fails (became Shadowing issue with `arguments`) May 18, 2016

@jvoigtlaender

This comment has been minimized.

Show comment
Hide comment
@jvoigtlaender

jvoigtlaender May 18, 2016

Contributor

Related to elm/compiler#994?

Contributor

jvoigtlaender commented May 18, 2016

Related to elm/compiler#994?

@schpaa

This comment has been minimized.

Show comment
Hide comment
@schpaa

schpaa May 18, 2016

Yes, it seems so. What should I do?

schpaa commented May 18, 2016

Yes, it seems so. What should I do?

@jvoigtlaender

This comment has been minimized.

Show comment
Hide comment
@jvoigtlaender

jvoigtlaender May 18, 2016

Contributor

I think: Open a new issue at the https://github.com/elm-lang/elm-compiler repository. Put an http://sscce.org/ into the first comment on that new issue.

If possible, try to capture the "old" case from elm/compiler#994 as well. (It seems that your problem is about outgoing ports, whereas the one originally reported there was about incoming ports. But the base problem, reserved JS names in stuff going through ports, seems to be the same. So it would be great if you could cover both, since the underlying bug for both might be the same. That probably means you would have to come up with two SSCCEs.)

Contributor

jvoigtlaender commented May 18, 2016

I think: Open a new issue at the https://github.com/elm-lang/elm-compiler repository. Put an http://sscce.org/ into the first comment on that new issue.

If possible, try to capture the "old" case from elm/compiler#994 as well. (It seems that your problem is about outgoing ports, whereas the one originally reported there was about incoming ports. But the base problem, reserved JS names in stuff going through ports, seems to be the same. So it would be great if you could cover both, since the underlying bug for both might be the same. That probably means you would have to come up with two SSCCEs.)

@jvoigtlaender jvoigtlaender changed the title from Sending a Record with a List String through a Port fails (became Shadowing issue with `arguments`) to Naming or shadowing issue with `arguments` field in record sent through port Jun 3, 2016

@evancz

This comment has been minimized.

Show comment
Hide comment
@evancz

evancz Mar 7, 2018

Member

Tracking in elm/compiler#1685 now. This will make it easier to fix them all in one batch. Thank you for the report!

Member

evancz commented Mar 7, 2018

Tracking in elm/compiler#1685 now. This will make it easier to fix them all in one batch. Thank you for the report!

@evancz evancz closed this Mar 7, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment