Skip to content

Fix issue with arrays and creation of recursive values. #5640

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

Merged
merged 2 commits into from
Sep 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@

#### :bug: Bug Fix

- Fix issue with arrays and creation of recursive values https://github.com/rescript-lang/rescript-compiler/pull/5640
- Fix issue where characters such as newlines would be escaped in a template string expression https://github.com/rescript-lang/rescript-compiler/issues/5638
- Fix issue where pipe `->` processing eats up attributes https://github.com/rescript-lang/rescript-compiler/pull/5581
- Fix issue where cancelling `rescript build` would leave the `.bsb.lock` file behind and block future builds
Expand Down
5 changes: 1 addition & 4 deletions jscomp/ml/rec_check.ml
Original file line number Diff line number Diff line change
Expand Up @@ -236,10 +236,7 @@ let rec expression : Env.env -> Typedtree.expression -> Use.t =
let arg env (_, eo) = option expression env eo in
Use.(join (inspect (expression env e)) (inspect (list arg env args)))
| Texp_tuple exprs -> Use.guard (list expression env exprs)
| Texp_array exprs ->
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This line seems to be coming from here: 0f3d69a

but it's unclear where it's coming from

(* This is counted as a use, because constructing a generic array
involves inspecting the elements (PR#6939). *)
Use.inspect (list expression env exprs)
| Texp_array exprs -> Use.guard (list expression env exprs)
| Texp_construct (_, desc, exprs) ->
let access_constructor =
match desc.cstr_tag with
Expand Down
3 changes: 2 additions & 1 deletion jscomp/test/build.ninja

Large diffs are not rendered by default.

19 changes: 19 additions & 0 deletions jscomp/test/rec_array_test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
'use strict';

var Caml_obj = require("../../lib/js/caml_obj.js");

var vicky = {};

var teacher = {};

Caml_obj.update_dummy(vicky, {
taughtBy: teacher
});

Caml_obj.update_dummy(teacher, {
students: [vicky]
});

exports.vicky = vicky;
exports.teacher = teacher;
/* No side effect */
5 changes: 5 additions & 0 deletions jscomp/test/rec_array_test.res
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
type rec student = {taughtBy: teacher}
and teacher = {students: array<student>}

let rec vicky = { taughtBy: teacher }
and teacher = {students: [vicky]}
5 changes: 1 addition & 4 deletions lib/4.06.1/unstable/js_compiler.ml
Original file line number Diff line number Diff line change
Expand Up @@ -38300,10 +38300,7 @@ let rec expression : Env.env -> Typedtree.expression -> Use.t =
let arg env (_, eo) = option expression env eo in
Use.(join (inspect (expression env e)) (inspect (list arg env args)))
| Texp_tuple exprs -> Use.guard (list expression env exprs)
| Texp_array exprs ->
(* This is counted as a use, because constructing a generic array
involves inspecting the elements (PR#6939). *)
Use.inspect (list expression env exprs)
| Texp_array exprs -> Use.guard (list expression env exprs)
| Texp_construct (_, desc, exprs) ->
let access_constructor =
match desc.cstr_tag with
Expand Down
5 changes: 1 addition & 4 deletions lib/4.06.1/unstable/js_playground_compiler.ml
Original file line number Diff line number Diff line change
Expand Up @@ -38300,10 +38300,7 @@ let rec expression : Env.env -> Typedtree.expression -> Use.t =
let arg env (_, eo) = option expression env eo in
Use.(join (inspect (expression env e)) (inspect (list arg env args)))
| Texp_tuple exprs -> Use.guard (list expression env exprs)
| Texp_array exprs ->
(* This is counted as a use, because constructing a generic array
involves inspecting the elements (PR#6939). *)
Use.inspect (list expression env exprs)
| Texp_array exprs -> Use.guard (list expression env exprs)
| Texp_construct (_, desc, exprs) ->
let access_constructor =
match desc.cstr_tag with
Expand Down
5 changes: 1 addition & 4 deletions lib/4.06.1/whole_compiler.ml
Original file line number Diff line number Diff line change
Expand Up @@ -212831,10 +212831,7 @@ let rec expression : Env.env -> Typedtree.expression -> Use.t =
let arg env (_, eo) = option expression env eo in
Use.(join (inspect (expression env e)) (inspect (list arg env args)))
| Texp_tuple exprs -> Use.guard (list expression env exprs)
| Texp_array exprs ->
(* This is counted as a use, because constructing a generic array
involves inspecting the elements (PR#6939). *)
Use.inspect (list expression env exprs)
| Texp_array exprs -> Use.guard (list expression env exprs)
| Texp_construct (_, desc, exprs) ->
let access_constructor =
match desc.cstr_tag with
Expand Down