Skip to content

Commit 635ea1c

Browse files
authored
Merge branch 'master' into in-operator
2 parents 6f4d58b + e4d98a7 commit 635ea1c

File tree

11 files changed

+81
-19
lines changed

11 files changed

+81
-19
lines changed

CHANGELOG.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
- Add popover attributes to JsxDOM.domProps. https://github.com/rescript-lang/rescript/pull/7317
1919
- Add `inert` attribute to `JsxDOM.domProps`. https://github.com/rescript-lang/rescript/pull/7326
2020
- Make reanalyze exception tracking work with the new stdlib. https://github.com/rescript-lang/rescript/pull/7328
21+
- Fix Pervasive.max using boolean comparison for floats. https://github.com/rescript-lang/rescript/pull/7333
2122
- Add built-in support for the JavaScript in operator. https://github.com/rescript-lang/rescript/pull/7342
2223

2324
#### :boom: Breaking Change
@@ -33,10 +34,12 @@
3334

3435
- Deprecate JSON.Classify.classify. https://github.com/rescript-lang/rescript/pull/7315
3536
- Hide stdlib modules in output. https://github.com/rescript-lang/rescript/pull/7305
37+
- Deprecate unsafe host-specific bindings from stdlib. https://github.com/rescript-lang/rescript/pull/7334
3638

3739
#### :bug: Bug fix
3840

3941
- Fix recursive untagged variant type checking by delaying well-formedness checks until environment construction completes. [#7320](https://github.com/rescript-lang/rescript/pull/7320)
42+
- Fix incorrect expansion of polymorphic return types in uncurried function applications. https://github.com/rescript-lang/rescript/pull/7338
4043

4144
# 12.0.0-alpha.9
4245

compiler/ml/translcore.ml

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,7 @@ let comparisons_table =
164164
objcomp = Pobjmax;
165165
intcomp = Pintmax;
166166
boolcomp = Pboolmax;
167-
floatcomp = Pboolmax;
167+
floatcomp = Pfloatmax;
168168
stringcomp = Pstringmax;
169169
bigintcomp = Pbigintmax;
170170
simplify_constant_constructor = false;
@@ -211,16 +211,6 @@ let comparisons_table =
211211
} );
212212
(* FIXME: Core compatibility *)
213213
( "%bs_min",
214-
{
215-
objcomp = Pobjmax;
216-
intcomp = Pintmax;
217-
boolcomp = Pboolmax;
218-
floatcomp = Pboolmax;
219-
stringcomp = Pstringmax;
220-
bigintcomp = Pbigintmax;
221-
simplify_constant_constructor = false;
222-
} );
223-
( "%bs_max",
224214
{
225215
objcomp = Pobjmin;
226216
intcomp = Pintmin;
@@ -230,6 +220,16 @@ let comparisons_table =
230220
bigintcomp = Pbigintmin;
231221
simplify_constant_constructor = false;
232222
} );
223+
( "%bs_max",
224+
{
225+
objcomp = Pobjmax;
226+
intcomp = Pintmax;
227+
boolcomp = Pboolmax;
228+
floatcomp = Pfloatmax;
229+
stringcomp = Pstringmax;
230+
bigintcomp = Pbigintmax;
231+
simplify_constant_constructor = false;
232+
} );
233233
|]
234234

235235
let primitives_table =

compiler/ml/typecore.ml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3554,7 +3554,9 @@ and type_application ?type_clash_context total_app env funct (sargs : sargs) :
35543554
let ty_fun = expand_head env ty_fun in
35553555
let arity_ok = List.length args < max_arity in
35563556
match ty_fun.desc with
3557-
| Tvar _ ->
3557+
| Tvar _ when force_tvar ->
3558+
(* This is a total application when the toplevel type is a polymorphic variable,
3559+
so the function type including arity can be inferred. *)
35583560
let t1 = newvar () and t2 = newvar () in
35593561
if ty_fun.level >= t1.level && not_identity funct.exp_desc then
35603562
Location.prerr_warning sarg1.pexp_loc Warnings.Unused_argument;

lib/es6/Stdlib_List.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -896,7 +896,7 @@ function reduceReverse2(l1, l2, acc, f) {
896896
let a = toArray(l1);
897897
let b = toArray(l2);
898898
let r = acc;
899-
let len$1 = Primitive_int.max(a.length, b.length);
899+
let len$1 = Primitive_int.min(a.length, b.length);
900900
for (let i = len$1 - 1 | 0; i >= 0; --i) {
901901
r = f(r, a[i], b[i]);
902902
}

lib/js/Stdlib_List.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -896,7 +896,7 @@ function reduceReverse2(l1, l2, acc, f) {
896896
let a = toArray(l1);
897897
let b = toArray(l2);
898898
let r = acc;
899-
let len$1 = Primitive_int.max(a.length, b.length);
899+
let len$1 = Primitive_int.min(a.length, b.length);
900900
for (let i = len$1 - 1 | 0; i >= 0; --i) {
901901
r = f(r, a[i], b[i]);
902902
}

runtime/Stdlib.res

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ type null<+'a> = Primitive_js_extern.null<'a>
5353
type undefined<+'a> = Primitive_js_extern.undefined<'a>
5454
type nullable<+'a> = Primitive_js_extern.nullable<'a>
5555

56-
@val external window: Dom.window = "window"
57-
@val external document: Dom.document = "document"
56+
@deprecated("Use rescript-webapi instead") @val external window: Dom.window = "window"
57+
@deprecated("Use rescript-webapi instead") @val external document: Dom.document = "document"
5858
@val external globalThis: {..} = "globalThis"
5959

6060
/**
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
2+
Warning number 20
3+
/.../fixtures/fun_return_poly1.res:3:15
4+
5+
1 │ let f = (_, ~def=3) => assert(false)
6+
2 │
7+
3 │ let ok = f(1)(2)
8+
4 │ let err = f(1, 2)
9+
5 │
10+
11+
this argument will not be used by the function.
12+
13+
14+
We've found a bug for you!
15+
/.../fixtures/fun_return_poly1.res:4:16
16+
17+
2 │
18+
3 │ let ok = f(1)(2)
19+
4 │ let err = f(1, 2)
20+
5 │
21+
22+
The function applied to this argument has type ('a, ~def: int=?) => 'b
23+
This argument cannot be applied without label
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
2+
Warning number 20
3+
/.../fixtures/fun_return_poly2.res:6:30
4+
5+
4 │ }
6+
5 │
7+
6 │ let ok = r("")(~initialValue=2)
8+
7 │ let err = r("", ~initialValue=2)
9+
8 │
10+
11+
this argument will not be used by the function.
12+
13+
14+
We've found a bug for you!
15+
/.../fixtures/fun_return_poly2.res:7:31
16+
17+
5 │
18+
6 │ let ok = r("")(~initialValue=2)
19+
7 │ let err = r("", ~initialValue=2)
20+
8 │
21+
22+
The function applied to this argument has type
23+
(string, ~wrongLabelName: int=?) => 'a
24+
This argument cannot be applied with label ~initialValue
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
let f = (_, ~def=3) => assert(false)
2+
3+
let ok = f(1)(2)
4+
let err = f(1, 2)
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
let r: (string, ~wrongLabelName: int=?) => 'a = (_s, ~wrongLabelName=3) => {
2+
let _ = wrongLabelName
3+
assert(false)
4+
}
5+
6+
let ok = r("")(~initialValue=2)
7+
let err = r("", ~initialValue=2)

tests/tests/src/mario_game.mjs

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import * as Belt_List from "rescript/lib/es6/Belt_List.js";
44
import * as Pervasives from "rescript/lib/es6/Pervasives.js";
55
import * as Primitive_int from "rescript/lib/es6/Primitive_int.js";
6-
import * as Primitive_bool from "rescript/lib/es6/Primitive_bool.js";
76
import * as Primitive_float from "rescript/lib/es6/Primitive_float.js";
87
import * as Primitive_object from "rescript/lib/es6/Primitive_object.js";
98
import * as Primitive_option from "rescript/lib/es6/Primitive_option.js";
@@ -979,7 +978,7 @@ function update_player(player, keys, context) {
979978
if (!player.jumping && player.grounded) {
980979
player.jumping = true;
981980
player.grounded = false;
982-
player.vel.y = Primitive_bool.max(player.vel.y - (5.7 + Math.abs(player.vel.x) * 0.25), -6);
981+
player.vel.y = Primitive_float.max(player.vel.y - (5.7 + Math.abs(player.vel.x) * 0.25), -6);
983982
return;
984983
} else {
985984
return;
@@ -1531,7 +1530,7 @@ function make$3(param, param$1) {
15311530

15321531
function calc_viewport_point(cc, vc, mc) {
15331532
let vc_half = vc / 2;
1534-
return Primitive_float.min(Primitive_bool.max(cc - vc_half, 0), Primitive_float.min(mc - vc, Math.abs(cc - vc_half)));
1533+
return Primitive_float.min(Primitive_float.max(cc - vc_half, 0), Primitive_float.min(mc - vc, Math.abs(cc - vc_half)));
15351534
}
15361535

15371536
function in_viewport(v, pos) {

0 commit comments

Comments
 (0)