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

Issue #1351 : bug fix #1396

Merged
merged 10 commits into from Mar 19, 2017
Merged

Issue #1351 : bug fix #1396

merged 10 commits into from Mar 19, 2017

Conversation

ghost
Copy link

@ghost ghost commented Mar 18, 2017

No description provided.

Copy link
Member

@bobzhang bobzhang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it is cool you dig into codegen!
no need patch to stdlib, you only need intercept Parrayrefs and Parraysets https://github.com/bloomberg/bucklescript/blob/master/jscomp/core/lam.ml#L115
the last letter s means safe.
Also the introduced bound checking runtime support is already there, so you don't need add a new one https://github.com/bloomberg/bucklescript/blob/0fc3cd0701079531ca0c04aff361c70318f13994/jscomp/runtime/caml_array.ml#L75

@@ -14,7 +14,7 @@
(* Array operations *)

external length : 'a array -> int = "%array_length"
external get: 'a array -> int -> 'a = "%array_safe_get"
external get: 'a array -> int -> 'a = "caml_array_safe_get"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you don't need change here, see my comments later

@ghost
Copy link
Author

ghost commented Mar 19, 2017

@bobzhang Hi finally I fixed all wrong unit tests. I think this is ready. Could you review please? Thanks!

@bobzhang
Copy link
Member

Would you do a rebase against origin/master?

@ghost
Copy link
Author

ghost commented Mar 19, 2017

@bobzhang done.

Copy link
Member

@bobzhang bobzhang left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dorafmon looks good to me, I will squash the commit and merge.
it would be nice that you can send a following PR to improve some runtime libs (see the comments)

var hh;

try {
hh = Caml_string.get("ghsogh", -3);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

hmm, this looks like a regression, will have a look why

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh, you changed the test code, nvm

@@ -61,6 +62,31 @@ function caml_array_concat(l) {
return result;
}

function caml_array_set(xs, index, newval) {
if (index < 0 || index >= xs.length) {
throw [
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dorafmon would you create a following PR to lift such allocation into the toplevel. such as

let outbound_exn = Invalid_argument "out of bounds"
let caml_array_set xs index new val = 
   ...

function caml_array_get(xs, index) {
if (index < 0 || index >= xs.length) {
throw [
Caml_builtin_exceptions.invalid_argument,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the exception allocation could be shared

@bobzhang bobzhang merged commit fca887d into rescript-lang:master Mar 19, 2017
@ghost
Copy link
Author

ghost commented Mar 19, 2017

@bobzhang sure I will send a following PR soon. Let me finish the template string thing first. That is going under a major refactoring at this moment.

@bobzhang
Copy link
Member

hi @dorafmon when you have time, would you mind also check String.get, Bytes.get and Bytes.set, thanks! look forward to your es6 string PR, I will cut a new release on March 27

@ghost
Copy link
Author

ghost commented Mar 19, 2017

@bobzhang sure, I think this PR already covers string.get/set, not sure about bytes. I will check later.

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 this pull request may close these issues.

2 participants