Skip to content
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
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@

#### :nail_care: Polish

- Reactivate optimization for length of array literals. https://github.com/rescript-lang/rescript/pull/7872

#### :house: Internal

- Playground: Add config options for experimental features and jsx preserve mode. https://github.com/rescript-lang/rescript/pull/7865
Expand Down
3 changes: 1 addition & 2 deletions packages/@rescript/runtime/Js_array.res
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,7 @@ Js.Array.isArray("abcd") == false
/**
Returns the number of elements in the array. See [`Array.length`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/length) on MDN.
*/
@get
external length: array<'a> => int = "length"
external length: array<'a> => int = "%array_length"

/* Mutator functions */

Expand Down
3 changes: 1 addition & 2 deletions packages/@rescript/runtime/Js_array2.res
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,7 @@ Returns the number of elements in the array. See
[`Array.length`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/length)
on MDN.
*/
@get
external length: array<'a> => int = "length"
external length: array<'a> => int = "%array_length"

/* Mutator functions */

Expand Down
2 changes: 1 addition & 1 deletion packages/@rescript/runtime/Stdlib_Array.res
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ let fromInitializer = (~length, f) =>

@val external isArray: 'a => bool = "Array.isArray"

@get external length: array<'a> => int = "length"
external length: array<'a> => int = "%array_length"

let isEmpty = arr => arr->length === 0

Expand Down
3 changes: 1 addition & 2 deletions packages/@rescript/runtime/Stdlib_Array.resi
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,7 @@ let someArray = ["hi", "hello"]
someArray->Array.length == 2
```
*/
@get
external length: array<'a> => int = "length"
external length: array<'a> => int = "%array_length"

/**
`isEmpty(array)` returns `true` if the array is empty (has length 0), `false` otherwise.
Expand Down
2 changes: 1 addition & 1 deletion tests/docstring_tests/DocTest.res.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 4 additions & 8 deletions tests/tests/src/array_subtle_test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ function f(v) {
}

function fff(x) {
return x.length >= 0;
return true;
}

function fff2(x) {
Expand All @@ -33,15 +33,11 @@ function fff2(x) {
}

function fff3(x) {
if (x.length >= 0) {
return 1;
} else {
return 2;
}
return 1;
}

function fff4(x) {
if (x.length > 0) {
if (x.length !== 0) {
return 1;
} else {
return 2;
Expand Down Expand Up @@ -87,7 +83,7 @@ Mocha.describe("Array_subtle_test", () => {
3,
3
];
while (v.length > 0) {
while (v.length !== 0) {
v.pop();
};
Test_utils.eq("File \"array_subtle_test.res\", line 60, characters 7-14", 0, v.length);
Expand Down
6 changes: 1 addition & 5 deletions tests/tests/src/js_array_test.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,7 @@ import * as Test_utils from "./test_utils.mjs";
Mocha.describe("Js_array_test", () => {
Mocha.test("isArray_array", () => Test_utils.eq("File \"js_array_test.res\", line 25, characters 7-14", true, Array.isArray([])));
Mocha.test("isArray_int", () => Test_utils.eq("File \"js_array_test.res\", line 28, characters 7-14", false, Array.isArray(34)));
Mocha.test("length", () => Test_utils.eq("File \"js_array_test.res\", line 31, characters 7-14", 3, [
1,
2,
3
].length));
Mocha.test("length", () => Test_utils.eq("File \"js_array_test.res\", line 31, characters 7-14", 3, 3));
Mocha.test("copyWithin", () => Test_utils.eq("File \"js_array_test.res\", line 35, characters 7-14", [
1,
2,
Expand Down
Loading