-
-
Notifications
You must be signed in to change notification settings - Fork 37
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
Obj.magic() causes code execution to fail #224
Comments
Hello, thank you for using and loving Sketch.sh. Regardings your problem, I think this is an upstream issue (with JSOO) or maybe how your Queue is implemented. I will have tho dig deeper to see what the actual issue is. In the mean time, here is a |
@Drup I'd only consider anythings that's linked with |
Yes, and Queue is part of that. The content of the stdlib is shown here. |
@Drup interesting. I wonder why sketch doesn't have Queue module |
Thanks for the alternate implementation @thangngoc89! FWIW, I've been using the reasonml docs as a stdlib reference. When I realized EDIT: |
FWIW, the current version of Queue doesn't use Obj.magic |
@Drup Thanks that's exactly what I needed! Not sure why |
I'm really loving Sketch 🎉, however, I ran into problems trying to use OCaml's
Queue
module -- the types all checked out, and code execution ran without issue, until I actually calledQueue.create()
.After some digging, I realized that
Queue
uses some unsafe type coercion viaObj.magic()
in a number of methods;Queue.create()
is one of them.Further testing revealed that
Obj.magic()
worked in cases involvingbool
,int
, andfloat
, but broke code execution when used to assignstring
orrecord
type.I have a Sketch that illustrates the problem in more detail:
https://sketch.sh/s/O5RAG6SC1rDRGzTu3d6GaU/
Right now, it seems like the only possible workaround is to roll my own
Queue
module. I'm still fairly new when it comes to reason/ocaml, but I'd love to help out if possible.The text was updated successfully, but these errors were encountered: