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

Bug in unurlifying #117

Closed
FrigoEU opened this issue Feb 2, 2018 · 2 comments
Closed

Bug in unurlifying #117

FrigoEU opened this issue Feb 2, 2018 · 2 comments

Comments

@FrigoEU
Copy link
Contributor

FrigoEU commented Feb 2, 2018

I've stumbled across an annoying bug. It shows up when you have a record that you're sending to the server where the first field (in alphabetical order) is of an option-like type, and the second field is of an enum-like type. Here's the smallest example I could make:

datatype bugged = Nothing | Something of int
datatype myDt = One | Two
type myRecord = {Bugged: bugged
               , MyDt : myDt}

fun rpcTarget (t: myRecord) = return ()

val good = {Bugged = Something 4, MyDt = One}
val bad = {Bugged = Nothing, MyDt = One}

fun main () : transaction page = return <xml>
  <body>
    <button onclick={fn _ => rpc (rpcTarget good)}>rpc with good</button>
    <button onclick={fn _ => rpc (rpcTarget bad)}>rpc with bad</button>
  </body>
</xml>

When you click on the "rpc with bad" button, you'll get this error:

RPC failure: Fatal error: Error unurlifying datatype myDt

The error won't happen when MyDt is of a primitive type, nor will it happen when Bugged is the last field in the row. The error also won't happen if you use the Basis.option type, instead of making your own option-like datatype.

@achlipala
Copy link
Contributor

Sorry for the delay finally getting to this one! The fix turned out to be straightforward.

@FrigoEU
Copy link
Contributor Author

FrigoEU commented May 20, 2018

That's excellent, I've been running into this one a lot. Thanks!

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

No branches or pull requests

2 participants