-
Notifications
You must be signed in to change notification settings - Fork 188
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
Change the semantic of MlBytes.toString #997
Conversation
@@ -425,9 +425,14 @@ MlBytes.prototype.toString = function(){ | |||
} | |||
this.t = 8; /*BYTES | NOT_ASCII*/ | |||
case 8: /*BYTES | NOT_ASCII*/ | |||
return caml_utf16_of_utf8(this.c); | |||
return this.c; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the type of this.c?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See the top of that file. It describes the memory representation of mlBytes
If I understood correctly @hhugo's explanations in the xrefs, a side effect of that PR is that
I had naively expected that Is that expected behaviour or something that was overlooked ? |
Looking at the The inconsistency is unfortunate. One could imagine introducing more primitives to have versions of |
Summary: Changelog: [fix] The JS build for try-flow is now fixed. It's recently broken since the 0.181.0 release. We don't wrap the input arguments with `Js.to_string`, so we are likely impacted by the string representation change (See ocsigen/js_of_ocaml#997) since our js_of_ocaml 4.0 update in the last release. Fix #8899 Reviewed By: pieterv Differential Revision: D37439740 fbshipit-source-id: 8536c6d0ac36b2214cafc5dbaf3daf0e9bece55f
Summary: Changelog: [fix] The JS build for try-flow is now fixed. It's recently broken since the 0.181.0 release. We don't wrap the input arguments with `Js.to_string`, so we are likely impacted by the string representation change (See ocsigen/js_of_ocaml#997) since our js_of_ocaml 4.0 update in the last release. Fix #8899 Reviewed By: pieterv Differential Revision: D37439740 fbshipit-source-id: f26a762f358d0539301b96b88d45ff110f5e3c32
Until now,
MlBytes.toString()
would return a utf16 javascript string.This is becoming problematic now that we want to change the representation of ocaml string to use JavaScript strings.
The reason is that JavaScript VMs will transparently rely on the toString method when converting a value to a primitive type. For example, the following snippet will behave differently depending on how we represent strings.
This PR propose to change the semantic of
MlBytes.toString()
to not apply the conversion to utf16 and return the raw sequence of bytes.