From 46f95a2f95c1127d841ef6538e85e41b380e13c5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A9di-R=C3=A9mi=20Hashim?= Date: Mon, 12 May 2025 19:33:08 +0100 Subject: [PATCH 01/16] Add @notUndefined attribute to Stdlib_Map.t --- runtime/Stdlib_Map.res | 1 + runtime/Stdlib_Map.resi | 1 + tests/tests/src/option_wrapping_test.mjs | 2 ++ tests/tests/src/option_wrapping_test.res | 1 + 4 files changed, 5 insertions(+) diff --git a/runtime/Stdlib_Map.res b/runtime/Stdlib_Map.res index 2a4ea8d8ca..7d534aa7d8 100644 --- a/runtime/Stdlib_Map.res +++ b/runtime/Stdlib_Map.res @@ -1,3 +1,4 @@ +@notUndefined type t<'k, 'v> @new external make: unit => t<'k, 'v> = "Map" diff --git a/runtime/Stdlib_Map.resi b/runtime/Stdlib_Map.resi index 3fc56d3f1a..3df63191e3 100644 --- a/runtime/Stdlib_Map.resi +++ b/runtime/Stdlib_Map.resi @@ -7,6 +7,7 @@ See [`Map`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Gl /** Type representing an instance of `Map`. */ +@notUndefined type t<'k, 'v> /** diff --git a/tests/tests/src/option_wrapping_test.mjs b/tests/tests/src/option_wrapping_test.mjs index 4efe8a0437..0dfacab904 100644 --- a/tests/tests/src/option_wrapping_test.mjs +++ b/tests/tests/src/option_wrapping_test.mjs @@ -24,6 +24,8 @@ let x21 = new Date(); let x22 = /test/; +let x23 = new Map(); + let x1 = "hello"; let x2 = 1; diff --git a/tests/tests/src/option_wrapping_test.res b/tests/tests/src/option_wrapping_test.res index d9d7040d84..4aad479346 100644 --- a/tests/tests/src/option_wrapping_test.res +++ b/tests/tests/src/option_wrapping_test.res @@ -16,3 +16,4 @@ let x12 = Some(Nullable.Value("test")) let x20 = Some(Jsx.null) let x21 = Some(Date.make()) let x22 = Some(/test/) +let x23 = Some((Map.make(): Map.t)) From 2f45740b8538723ffa48e5a27e30282ee4953c34 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A9di-R=C3=A9mi=20Hashim?= Date: Mon, 12 May 2025 19:33:26 +0100 Subject: [PATCH 02/16] Add @notUndefined attribute to Stdlib_Set.t --- runtime/Stdlib_Set.res | 1 + runtime/Stdlib_Set.resi | 1 + tests/tests/src/option_wrapping_test.mjs | 2 ++ tests/tests/src/option_wrapping_test.res | 1 + 4 files changed, 5 insertions(+) diff --git a/runtime/Stdlib_Set.res b/runtime/Stdlib_Set.res index 724058afb1..61040dc863 100644 --- a/runtime/Stdlib_Set.res +++ b/runtime/Stdlib_Set.res @@ -1,3 +1,4 @@ +@notUndefined type t<'a> @new external make: unit => t<'a> = "Set" diff --git a/runtime/Stdlib_Set.resi b/runtime/Stdlib_Set.resi index 9437fe85e1..4945add4d1 100644 --- a/runtime/Stdlib_Set.resi +++ b/runtime/Stdlib_Set.resi @@ -7,6 +7,7 @@ See [`Set`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Gl /** Type representing an instance of `Set`. */ +@notUndefined type t<'a> /** diff --git a/tests/tests/src/option_wrapping_test.mjs b/tests/tests/src/option_wrapping_test.mjs index 0dfacab904..35054e4b41 100644 --- a/tests/tests/src/option_wrapping_test.mjs +++ b/tests/tests/src/option_wrapping_test.mjs @@ -26,6 +26,8 @@ let x22 = /test/; let x23 = new Map(); +let x24 = new Set(); + let x1 = "hello"; let x2 = 1; diff --git a/tests/tests/src/option_wrapping_test.res b/tests/tests/src/option_wrapping_test.res index 4aad479346..7e1f3593f9 100644 --- a/tests/tests/src/option_wrapping_test.res +++ b/tests/tests/src/option_wrapping_test.res @@ -17,3 +17,4 @@ let x20 = Some(Jsx.null) let x21 = Some(Date.make()) let x22 = Some(/test/) let x23 = Some((Map.make(): Map.t)) +let x24 = Some((Set.make(): Set.t)) From 2d7ff4657110b33b1583edcd2ba679c91e29dc7e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A9di-R=C3=A9mi=20Hashim?= Date: Mon, 12 May 2025 19:34:00 +0100 Subject: [PATCH 03/16] Add @notUndefined attribute to Stdlib_WeakMap.t and Stdlib_WeakSet.t --- runtime/Stdlib_WeakMap.res | 1 + runtime/Stdlib_WeakSet.res | 1 + tests/tests/src/option_wrapping_test.mjs | 8 ++++++++ tests/tests/src/option_wrapping_test.res | 2 ++ 4 files changed, 12 insertions(+) diff --git a/runtime/Stdlib_WeakMap.res b/runtime/Stdlib_WeakMap.res index f6846eb17a..9fd4e99c82 100644 --- a/runtime/Stdlib_WeakMap.res +++ b/runtime/Stdlib_WeakMap.res @@ -1,3 +1,4 @@ +@notUndefined type t<'k, 'v> @new external make: unit => t<'k, 'v> = "WeakMap" diff --git a/runtime/Stdlib_WeakSet.res b/runtime/Stdlib_WeakSet.res index 6d6deefdfd..5316552323 100644 --- a/runtime/Stdlib_WeakSet.res +++ b/runtime/Stdlib_WeakSet.res @@ -1,3 +1,4 @@ +@notUndefined type t<'a> @new external make: unit => t<'a> = "WeakSet" diff --git a/tests/tests/src/option_wrapping_test.mjs b/tests/tests/src/option_wrapping_test.mjs index 35054e4b41..acc4812a08 100644 --- a/tests/tests/src/option_wrapping_test.mjs +++ b/tests/tests/src/option_wrapping_test.mjs @@ -28,6 +28,10 @@ let x23 = new Map(); let x24 = new Set(); +let x25 = new WeakMap(); + +let x26 = new WeakSet(); + let x1 = "hello"; let x2 = 1; @@ -60,5 +64,9 @@ export { x20, x21, x22, + x23, + x24, + x25, + x26, } /* x20 Not a pure module */ diff --git a/tests/tests/src/option_wrapping_test.res b/tests/tests/src/option_wrapping_test.res index 7e1f3593f9..ffc579f4a4 100644 --- a/tests/tests/src/option_wrapping_test.res +++ b/tests/tests/src/option_wrapping_test.res @@ -18,3 +18,5 @@ let x21 = Some(Date.make()) let x22 = Some(/test/) let x23 = Some((Map.make(): Map.t)) let x24 = Some((Set.make(): Set.t)) +let x25 = Some((WeakMap.make(): WeakMap.t)) +let x26 = Some((WeakSet.make(): WeakSet.t)) From 0e183be01ae479c902d889773ad5469fae5e9af3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A9di-R=C3=A9mi=20Hashim?= Date: Tue, 13 May 2025 12:50:13 +0100 Subject: [PATCH 04/16] Add @notUndefined attribute to Stdlib_TypedArray --- runtime/Stdlib_TypedArray.res | 1 + tests/tests/src/option_wrapping_test.mjs | 9 +++++++++ tests/tests/src/option_wrapping_test.res | 4 ++++ 3 files changed, 14 insertions(+) diff --git a/runtime/Stdlib_TypedArray.res b/runtime/Stdlib_TypedArray.res index 2d9a5add76..759f81cb18 100644 --- a/runtime/Stdlib_TypedArray.res +++ b/runtime/Stdlib_TypedArray.res @@ -1,3 +1,4 @@ +@notUndefined type t<'a> @get_index external get: (t<'a>, int) => option<'a> = "" diff --git a/tests/tests/src/option_wrapping_test.mjs b/tests/tests/src/option_wrapping_test.mjs index acc4812a08..c6424f4886 100644 --- a/tests/tests/src/option_wrapping_test.mjs +++ b/tests/tests/src/option_wrapping_test.mjs @@ -32,6 +32,10 @@ let x25 = new WeakMap(); let x26 = new WeakSet(); +let x27 = new Float32Array([1.0]); + +let x99 = {}; + let x1 = "hello"; let x2 = 1; @@ -49,6 +53,8 @@ let x5 = { let x12 = "test"; +let x98 = /* [] */0; + export { x1, x2, @@ -68,5 +74,8 @@ export { x24, x25, x26, + x27, + x98, + x99, } /* x20 Not a pure module */ diff --git a/tests/tests/src/option_wrapping_test.res b/tests/tests/src/option_wrapping_test.res index ffc579f4a4..e0af91655f 100644 --- a/tests/tests/src/option_wrapping_test.res +++ b/tests/tests/src/option_wrapping_test.res @@ -20,3 +20,7 @@ let x23 = Some((Map.make(): Map.t)) let x24 = Some((Set.make(): Set.t)) let x25 = Some((WeakMap.make(): WeakMap.t)) let x26 = Some((WeakSet.make(): WeakSet.t)) +let x27 = Some(Float32Array.fromArray([1.0])) + +let x98 = Some(list{}) +let x99 = Some((Dict.make(): dict)) From a109d1f3ef2c99a1a573f5a8162d4500c02bb322 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A9di-R=C3=A9mi=20Hashim?= Date: Tue, 13 May 2025 13:19:19 +0100 Subject: [PATCH 05/16] Add @notUndefined attribute to Stdlib_Symbol --- runtime/Stdlib_Symbol.res | 1 + runtime/Stdlib_Symbol.resi | 3 ++- tests/tests/src/option_wrapping_test.mjs | 3 +++ 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/runtime/Stdlib_Symbol.res b/runtime/Stdlib_Symbol.res index 195f82cfe9..bbdb978313 100644 --- a/runtime/Stdlib_Symbol.res +++ b/runtime/Stdlib_Symbol.res @@ -1,3 +1,4 @@ +@notUndefined type t @val external make: string => t = "Symbol" diff --git a/runtime/Stdlib_Symbol.resi b/runtime/Stdlib_Symbol.resi index 5dceef04c3..3a2bf3bf17 100644 --- a/runtime/Stdlib_Symbol.resi +++ b/runtime/Stdlib_Symbol.resi @@ -7,6 +7,7 @@ Compiles to a regular JavaScript Symbol. /** Type representing a Symbol. */ +@notUndefined type t /** @@ -28,7 +29,7 @@ external make: string => t = "Symbol" /** `getFor(key)` -Searches for existing registered Symbols in the global Symbol registry with the given key and returns it if found. +Searches for existing registered Symbols in the global Symbol registry with the given key and returns it if found. Otherwise a new Symbol gets created and registered with key. ## Examples diff --git a/tests/tests/src/option_wrapping_test.mjs b/tests/tests/src/option_wrapping_test.mjs index c6424f4886..b4ca9bcf99 100644 --- a/tests/tests/src/option_wrapping_test.mjs +++ b/tests/tests/src/option_wrapping_test.mjs @@ -34,6 +34,8 @@ let x26 = new WeakSet(); let x27 = new Float32Array([1.0]); +let x28 = Symbol(""); + let x99 = {}; let x1 = "hello"; @@ -75,6 +77,7 @@ export { x25, x26, x27, + x28, x98, x99, } From 1bbb196daed8597eee15fe3b13efd2a32e364b46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A9di-R=C3=A9mi=20Hashim?= Date: Tue, 13 May 2025 13:21:42 +0100 Subject: [PATCH 06/16] Add @notUndefined attribute to Stdlib_JsError --- runtime/Stdlib_JsError.res | 1 + runtime/Stdlib_JsError.resi | 15 ++++++++------- tests/tests/src/option_wrapping_test.mjs | 3 +++ tests/tests/src/option_wrapping_test.res | 2 ++ 4 files changed, 14 insertions(+), 7 deletions(-) diff --git a/runtime/Stdlib_JsError.res b/runtime/Stdlib_JsError.res index 17ff192439..0622973178 100644 --- a/runtime/Stdlib_JsError.res +++ b/runtime/Stdlib_JsError.res @@ -1,3 +1,4 @@ +@notUndefined type t @get external stack: t => option = "stack" diff --git a/runtime/Stdlib_JsError.resi b/runtime/Stdlib_JsError.resi index 9f55fd7a82..8193306f1f 100644 --- a/runtime/Stdlib_JsError.resi +++ b/runtime/Stdlib_JsError.resi @@ -5,6 +5,7 @@ See [`Error`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/ */ /** Represents a JavaScript error. */ +@notUndefined type t /** @@ -29,7 +30,7 @@ See [`Error.prototype.message`](https://developer.mozilla.org/en-US/docs/Web/Jav ## Example ```rescript let error = JsError.SyntaxError.make("Some message here") -error->JsError.message->assertEqual("Some message here") +error->JsError.message->assertEqual("Some message here") ``` */ @get @@ -65,8 +66,8 @@ See [`Error`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/ ## Example ```rescript let error = JsError.make("Some message here") -error->JsError.message->assertEqual("Some message here") -error->JsError.name->assertEqual("Error") +error->JsError.message->assertEqual("Some message here") +error->JsError.name->assertEqual("Error") ```` */ @new @@ -101,7 +102,7 @@ module RangeError: { /** Creates a new `RangeError` with the provided `message` and throws it. - + `JsError.RangeError.throwWithMessage("message")` is equivalent to `JsError.RangeError.make("message")->JsError.throw`. See [`RangeError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RangeError) on MDN. @@ -137,9 +138,9 @@ module SyntaxError: { /** Creates a new `SyntaxError` with the provided `message` and throws it. - + `JsError.SyntaxError.throwWithMessage("message")` is equivalent to `JsError.SyntaxError.make("message")->JsError.throw`. - + See [`SyntaxError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SyntaxError) on MDN. */ let throwWithMessage: string => 'a @@ -230,7 +231,7 @@ try { let panic: string => 'a /** -Casts a `JsError.t` to a `JsExn.t`. +Casts a `JsError.t` to a `JsExn.t`. This is useful when you want to compare a JS exception and a JS error. */ diff --git a/tests/tests/src/option_wrapping_test.mjs b/tests/tests/src/option_wrapping_test.mjs index b4ca9bcf99..2c88fc352c 100644 --- a/tests/tests/src/option_wrapping_test.mjs +++ b/tests/tests/src/option_wrapping_test.mjs @@ -36,6 +36,8 @@ let x27 = new Float32Array([1.0]); let x28 = Symbol(""); +let x29 = new Error(""); + let x99 = {}; let x1 = "hello"; @@ -78,6 +80,7 @@ export { x26, x27, x28, + x29, x98, x99, } diff --git a/tests/tests/src/option_wrapping_test.res b/tests/tests/src/option_wrapping_test.res index e0af91655f..3c7bcb975f 100644 --- a/tests/tests/src/option_wrapping_test.res +++ b/tests/tests/src/option_wrapping_test.res @@ -21,6 +21,8 @@ let x24 = Some((Set.make(): Set.t)) let x25 = Some((WeakMap.make(): WeakMap.t)) let x26 = Some((WeakSet.make(): WeakSet.t)) let x27 = Some(Float32Array.fromArray([1.0])) +let x28 = Some(Symbol.make("")) +let x29 = Some(JsError.make("")) let x98 = Some(list{}) let x99 = Some((Dict.make(): dict)) From 6154df746fcaf925e5fdc74b8f506bf26e6ab59f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A9di-R=C3=A9mi=20Hashim?= Date: Tue, 13 May 2025 13:22:51 +0100 Subject: [PATCH 07/16] Add @notUndefined attribute to Stdlib_ArrayBuffer --- runtime/Stdlib_ArrayBuffer.res | 1 + tests/tests/src/option_wrapping_test.mjs | 3 +++ tests/tests/src/option_wrapping_test.res | 1 + 3 files changed, 5 insertions(+) diff --git a/runtime/Stdlib_ArrayBuffer.res b/runtime/Stdlib_ArrayBuffer.res index 2b0cf3a36b..4b672e196d 100644 --- a/runtime/Stdlib_ArrayBuffer.res +++ b/runtime/Stdlib_ArrayBuffer.res @@ -1,3 +1,4 @@ +@notUndefined type t @new external make: int => t = "ArrayBuffer" diff --git a/tests/tests/src/option_wrapping_test.mjs b/tests/tests/src/option_wrapping_test.mjs index 2c88fc352c..268f5151aa 100644 --- a/tests/tests/src/option_wrapping_test.mjs +++ b/tests/tests/src/option_wrapping_test.mjs @@ -38,6 +38,8 @@ let x28 = Symbol(""); let x29 = new Error(""); +let x30 = new ArrayBuffer(0); + let x99 = {}; let x1 = "hello"; @@ -81,6 +83,7 @@ export { x27, x28, x29, + x30, x98, x99, } diff --git a/tests/tests/src/option_wrapping_test.res b/tests/tests/src/option_wrapping_test.res index 3c7bcb975f..68a6f6092d 100644 --- a/tests/tests/src/option_wrapping_test.res +++ b/tests/tests/src/option_wrapping_test.res @@ -23,6 +23,7 @@ let x26 = Some((WeakSet.make(): WeakSet.t)) let x27 = Some(Float32Array.fromArray([1.0])) let x28 = Some(Symbol.make("")) let x29 = Some(JsError.make("")) +let x30 = Some(ArrayBuffer.make(0)) let x98 = Some(list{}) let x99 = Some((Dict.make(): dict)) From 2e97c4cb371403b782debfb45e6e2f7707c59505 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A9di-R=C3=A9mi=20Hashim?= Date: Tue, 13 May 2025 13:26:45 +0100 Subject: [PATCH 08/16] Add @notUndefined attribute to Stdlib_DataView --- runtime/Stdlib_DataView.res | 1 + tests/tests/src/option_wrapping_test.mjs | 3 +++ tests/tests/src/option_wrapping_test.res | 1 + 3 files changed, 5 insertions(+) diff --git a/runtime/Stdlib_DataView.res b/runtime/Stdlib_DataView.res index 8ab0025336..2c0ccd91bf 100644 --- a/runtime/Stdlib_DataView.res +++ b/runtime/Stdlib_DataView.res @@ -1,3 +1,4 @@ +@notUndefined type t @new external fromBuffer: Stdlib_ArrayBuffer.t => t = "DataView" diff --git a/tests/tests/src/option_wrapping_test.mjs b/tests/tests/src/option_wrapping_test.mjs index 268f5151aa..65ca931242 100644 --- a/tests/tests/src/option_wrapping_test.mjs +++ b/tests/tests/src/option_wrapping_test.mjs @@ -40,6 +40,8 @@ let x29 = new Error(""); let x30 = new ArrayBuffer(0); +let x31 = new DataView(new ArrayBuffer(0)); + let x99 = {}; let x1 = "hello"; @@ -84,6 +86,7 @@ export { x28, x29, x30, + x31, x98, x99, } diff --git a/tests/tests/src/option_wrapping_test.res b/tests/tests/src/option_wrapping_test.res index 68a6f6092d..e55239252e 100644 --- a/tests/tests/src/option_wrapping_test.res +++ b/tests/tests/src/option_wrapping_test.res @@ -24,6 +24,7 @@ let x27 = Some(Float32Array.fromArray([1.0])) let x28 = Some(Symbol.make("")) let x29 = Some(JsError.make("")) let x30 = Some(ArrayBuffer.make(0)) +let x31 = Some(ArrayBuffer.make(0)->DataView.fromBuffer) let x98 = Some(list{}) let x99 = Some((Dict.make(): dict)) From a37d16095ff79745e0ff25347aeec27476842fb7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A9di-R=C3=A9mi=20Hashim?= Date: Tue, 13 May 2025 13:29:05 +0100 Subject: [PATCH 09/16] Add @notUndefined attribute to Stdlib_Iterator --- runtime/Stdlib_Iterator.res | 1 + runtime/Stdlib_Iterator.resi | 1 + tests/tests/src/option_wrapping_test.mjs | 3 +++ tests/tests/src/option_wrapping_test.res | 1 + 4 files changed, 6 insertions(+) diff --git a/runtime/Stdlib_Iterator.res b/runtime/Stdlib_Iterator.res index f631b604d1..01d14aa5a1 100644 --- a/runtime/Stdlib_Iterator.res +++ b/runtime/Stdlib_Iterator.res @@ -1,3 +1,4 @@ +@notUndefined type t<'a> type value<'a> = { diff --git a/runtime/Stdlib_Iterator.resi b/runtime/Stdlib_Iterator.resi index 359039a588..91e43fe00e 100644 --- a/runtime/Stdlib_Iterator.resi +++ b/runtime/Stdlib_Iterator.resi @@ -7,6 +7,7 @@ See [`iterator protocols`](https://developer.mozilla.org/en-US/docs/Web/JavaScri /** The type representing an iterator. */ +@notUndefined type t<'a> /** diff --git a/tests/tests/src/option_wrapping_test.mjs b/tests/tests/src/option_wrapping_test.mjs index 65ca931242..ada162fafc 100644 --- a/tests/tests/src/option_wrapping_test.mjs +++ b/tests/tests/src/option_wrapping_test.mjs @@ -42,6 +42,8 @@ let x30 = new ArrayBuffer(0); let x31 = new DataView(new ArrayBuffer(0)); +let x32 = new Map().values(); + let x99 = {}; let x1 = "hello"; @@ -87,6 +89,7 @@ export { x29, x30, x31, + x32, x98, x99, } diff --git a/tests/tests/src/option_wrapping_test.res b/tests/tests/src/option_wrapping_test.res index e55239252e..9f48e2d96e 100644 --- a/tests/tests/src/option_wrapping_test.res +++ b/tests/tests/src/option_wrapping_test.res @@ -25,6 +25,7 @@ let x28 = Some(Symbol.make("")) let x29 = Some(JsError.make("")) let x30 = Some(ArrayBuffer.make(0)) let x31 = Some(ArrayBuffer.make(0)->DataView.fromBuffer) +let x32 = Some((Map.make(): Map.t)->Map.values) let x98 = Some(list{}) let x99 = Some((Dict.make(): dict)) From 6e8f02c9fb465a64aefd735c8f5dadffce730709 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A9di-R=C3=A9mi=20Hashim?= Date: Tue, 13 May 2025 13:32:37 +0100 Subject: [PATCH 10/16] Add @notUndefined attribute to Stdlib_AsyncIterator --- runtime/Stdlib_AsyncIterator.res | 1 + runtime/Stdlib_AsyncIterator.resi | 5 +++-- tests/tests/src/option_wrapping_test.mjs | 4 ++++ tests/tests/src/option_wrapping_test.res | 2 ++ 4 files changed, 10 insertions(+), 2 deletions(-) diff --git a/runtime/Stdlib_AsyncIterator.res b/runtime/Stdlib_AsyncIterator.res index 03504dafc0..b62128c821 100644 --- a/runtime/Stdlib_AsyncIterator.res +++ b/runtime/Stdlib_AsyncIterator.res @@ -1,3 +1,4 @@ +@notUndefined type t<'a> type value<'a> = { diff --git a/runtime/Stdlib_AsyncIterator.resi b/runtime/Stdlib_AsyncIterator.resi index 50db4fdf3b..9a626cae1f 100644 --- a/runtime/Stdlib_AsyncIterator.resi +++ b/runtime/Stdlib_AsyncIterator.resi @@ -6,6 +6,7 @@ See [async iterator protocols](https://developer.mozilla.org/en-US/docs/Web/Java /** The type representing an async iterator. */ +@notUndefined type t<'a> type value<'a> = { @@ -69,7 +70,7 @@ let asyncIterator = AsyncIterator.make(async () => { let currentValue = context.contents // Increment current value context := currentValue + 1 - + if currentValue >= 3 { AsyncIterator.done() } else { @@ -93,7 +94,7 @@ let value: 'value => value<'value> let currentValue = context.contents // Increment current value context := currentValue + 1 - + if currentValue >= 3 { AsyncIterator.done() } else { diff --git a/tests/tests/src/option_wrapping_test.mjs b/tests/tests/src/option_wrapping_test.mjs index ada162fafc..88bcf5b12b 100644 --- a/tests/tests/src/option_wrapping_test.mjs +++ b/tests/tests/src/option_wrapping_test.mjs @@ -1,6 +1,7 @@ // Generated by ReScript, PLEASE EDIT WITH CARE import * as Primitive_option from "rescript/lib/es6/Primitive_option.js"; +import * as Stdlib_AsyncIterator from "rescript/lib/es6/Stdlib_AsyncIterator.js"; let x6 = { x: 42 @@ -44,6 +45,8 @@ let x31 = new DataView(new ArrayBuffer(0)); let x32 = new Map().values(); +let x33 = Stdlib_AsyncIterator.make(() => Promise.resolve(Stdlib_AsyncIterator.value(true))); + let x99 = {}; let x1 = "hello"; @@ -90,6 +93,7 @@ export { x30, x31, x32, + x33, x98, x99, } diff --git a/tests/tests/src/option_wrapping_test.res b/tests/tests/src/option_wrapping_test.res index 9f48e2d96e..22368764d5 100644 --- a/tests/tests/src/option_wrapping_test.res +++ b/tests/tests/src/option_wrapping_test.res @@ -26,6 +26,8 @@ let x29 = Some(JsError.make("")) let x30 = Some(ArrayBuffer.make(0)) let x31 = Some(ArrayBuffer.make(0)->DataView.fromBuffer) let x32 = Some((Map.make(): Map.t)->Map.values) +let x33 = Some(AsyncIterator.make(_ => AsyncIterator.value(true)->Promise.resolve)) +let x97 = Some(Promise.resolve(true)) let x98 = Some(list{}) let x99 = Some((Dict.make(): dict)) From 69156a622c967246febc84c03041e2a3abf2597a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A9di-R=C3=A9mi=20Hashim?= Date: Tue, 13 May 2025 13:38:15 +0100 Subject: [PATCH 11/16] Remove outdated comment regarding Intl.Segmenter Firefox compatibility --- runtime/Stdlib_Intl_Segmenter.res | 3 --- 1 file changed, 3 deletions(-) diff --git a/runtime/Stdlib_Intl_Segmenter.res b/runtime/Stdlib_Intl_Segmenter.res index fd79657ef0..6e84ec8863 100644 --- a/runtime/Stdlib_Intl_Segmenter.res +++ b/runtime/Stdlib_Intl_Segmenter.res @@ -1,6 +1,3 @@ -/*** -Not supported in Firefox -*/ type t type granularity = [#grapheme | #word | #sentence] From 9dccafa04bb2e4ca081e141e088491d064f55eb8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A9di-R=C3=A9mi=20Hashim?= Date: Tue, 13 May 2025 14:10:02 +0100 Subject: [PATCH 12/16] Add @notUndefined attribute to Stdlib_Intl_* --- runtime/Stdlib_Intl_Collator.res | 1 + runtime/Stdlib_Intl_DateTimeFormat.res | 1 + runtime/Stdlib_Intl_ListFormat.res | 1 + runtime/Stdlib_Intl_Locale.res | 1 + runtime/Stdlib_Intl_NumberFormat.res | 3 +- runtime/Stdlib_Intl_NumberFormat_Grouping.res | 1 + runtime/Stdlib_Intl_PluralRules.res | 1 + runtime/Stdlib_Intl_RelativeTimeFormat.res | 1 + runtime/Stdlib_Intl_Segmenter.res | 1 + runtime/Stdlib_Intl_Segments.res | 1 + .../core/intl/Core_Intl_NumberFormatTest.mjs | 3 +- tests/tests/src/option_wrapping_test.mjs | 51 +++++++++++++++++-- tests/tests/src/option_wrapping_test.res | 19 +++++-- 13 files changed, 75 insertions(+), 10 deletions(-) diff --git a/runtime/Stdlib_Intl_Collator.res b/runtime/Stdlib_Intl_Collator.res index f457c247f7..4329a6f1c5 100644 --- a/runtime/Stdlib_Intl_Collator.res +++ b/runtime/Stdlib_Intl_Collator.res @@ -1,3 +1,4 @@ +@notUndefined type t type usage = [#sort | #search] diff --git a/runtime/Stdlib_Intl_DateTimeFormat.res b/runtime/Stdlib_Intl_DateTimeFormat.res index 9c2be84b11..00992bee49 100644 --- a/runtime/Stdlib_Intl_DateTimeFormat.res +++ b/runtime/Stdlib_Intl_DateTimeFormat.res @@ -1,3 +1,4 @@ +@notUndefined type t type dateStyle = [#full | #long | #medium | #short] diff --git a/runtime/Stdlib_Intl_ListFormat.res b/runtime/Stdlib_Intl_ListFormat.res index 3dd0b280e6..3f4b0cb41f 100644 --- a/runtime/Stdlib_Intl_ListFormat.res +++ b/runtime/Stdlib_Intl_ListFormat.res @@ -1,3 +1,4 @@ +@notUndefined type t type listType = [ diff --git a/runtime/Stdlib_Intl_Locale.res b/runtime/Stdlib_Intl_Locale.res index 45c9388e29..f250413f53 100644 --- a/runtime/Stdlib_Intl_Locale.res +++ b/runtime/Stdlib_Intl_Locale.res @@ -1,3 +1,4 @@ +@notUndefined type t type options = { diff --git a/runtime/Stdlib_Intl_NumberFormat.res b/runtime/Stdlib_Intl_NumberFormat.res index f69d7f1148..4962de43d4 100644 --- a/runtime/Stdlib_Intl_NumberFormat.res +++ b/runtime/Stdlib_Intl_NumberFormat.res @@ -1,5 +1,6 @@ module Grouping = Stdlib_Intl_NumberFormat_Grouping +@notUndefined type t /** @@ -211,7 +212,7 @@ external formatBigIntRangeToParts: (t, ~start: bigint, ~end: bigint) => array array = "formatToParts" /** - `ignore(numberGrouping)` ignores the provided numberGrouping and returns unit. + `ignore(numberFormat)` ignores the provided numberFormat and returns unit. This helper is useful when you want to discard a value (for example, the result of an operation with side effects) without having to store or process it further. diff --git a/runtime/Stdlib_Intl_NumberFormat_Grouping.res b/runtime/Stdlib_Intl_NumberFormat_Grouping.res index 47227b6e7f..f0b0c82a4a 100644 --- a/runtime/Stdlib_Intl_NumberFormat_Grouping.res +++ b/runtime/Stdlib_Intl_NumberFormat_Grouping.res @@ -1,3 +1,4 @@ +@notUndefined type t type parsed = [#bool(bool) | #always | #auto | #min2] diff --git a/runtime/Stdlib_Intl_PluralRules.res b/runtime/Stdlib_Intl_PluralRules.res index 8e52f7d98a..49348b9aac 100644 --- a/runtime/Stdlib_Intl_PluralRules.res +++ b/runtime/Stdlib_Intl_PluralRules.res @@ -1,3 +1,4 @@ +@notUndefined type t type localeType = [#cardinal | #ordinal] diff --git a/runtime/Stdlib_Intl_RelativeTimeFormat.res b/runtime/Stdlib_Intl_RelativeTimeFormat.res index f3173520d7..2454473e36 100644 --- a/runtime/Stdlib_Intl_RelativeTimeFormat.res +++ b/runtime/Stdlib_Intl_RelativeTimeFormat.res @@ -1,3 +1,4 @@ +@notUndefined type t type numeric = [#always | #auto] diff --git a/runtime/Stdlib_Intl_Segmenter.res b/runtime/Stdlib_Intl_Segmenter.res index 6e84ec8863..16bf7a2c07 100644 --- a/runtime/Stdlib_Intl_Segmenter.res +++ b/runtime/Stdlib_Intl_Segmenter.res @@ -1,3 +1,4 @@ +@notUndefined type t type granularity = [#grapheme | #word | #sentence] diff --git a/runtime/Stdlib_Intl_Segments.res b/runtime/Stdlib_Intl_Segments.res index 32b0d4cb0e..39f2ff7269 100644 --- a/runtime/Stdlib_Intl_Segments.res +++ b/runtime/Stdlib_Intl_Segments.res @@ -2,6 +2,7 @@ A Segments instance is an object that represents the segments of a specific string, subject to the locale and options of its constructing Intl.Segmenter instance. https://tc39.es/ecma402/#sec-segments-objects */ +@notUndefined type t type segmentData = { diff --git a/tests/tests/src/core/intl/Core_Intl_NumberFormatTest.mjs b/tests/tests/src/core/intl/Core_Intl_NumberFormatTest.mjs index 988d5795bb..132cd9709b 100644 --- a/tests/tests/src/core/intl/Core_Intl_NumberFormatTest.mjs +++ b/tests/tests/src/core/intl/Core_Intl_NumberFormatTest.mjs @@ -1,6 +1,5 @@ // Generated by ReScript, PLEASE EDIT WITH CARE -import * as Primitive_option from "rescript/lib/es6/Primitive_option.js"; import * as Stdlib_Intl_NumberFormat_Grouping from "rescript/lib/es6/Stdlib_Intl_NumberFormat_Grouping.js"; console.log("---"); @@ -26,7 +25,7 @@ let roundingFormatter = new Intl.NumberFormat(undefined, { }); let groupingFormatter1 = new Intl.NumberFormat(undefined, { - useGrouping: Primitive_option.some(true) + useGrouping: true }); let groupingFormatter2 = new Intl.NumberFormat(undefined, { diff --git a/tests/tests/src/option_wrapping_test.mjs b/tests/tests/src/option_wrapping_test.mjs index 88bcf5b12b..1f04be7cd7 100644 --- a/tests/tests/src/option_wrapping_test.mjs +++ b/tests/tests/src/option_wrapping_test.mjs @@ -1,5 +1,6 @@ // Generated by ReScript, PLEASE EDIT WITH CARE +import * as Stdlib_Lazy from "rescript/lib/es6/Stdlib_Lazy.js"; import * as Primitive_option from "rescript/lib/es6/Primitive_option.js"; import * as Stdlib_AsyncIterator from "rescript/lib/es6/Stdlib_AsyncIterator.js"; @@ -47,7 +48,31 @@ let x32 = new Map().values(); let x33 = Stdlib_AsyncIterator.make(() => Promise.resolve(Stdlib_AsyncIterator.value(true))); -let x99 = {}; +let x34 = new Intl.ListFormat(); + +let x35 = new Intl.Segmenter(); + +let x36 = new Intl.Segmenter().segment(""); + +let x37 = new Intl.DateTimeFormat(); + +let x38 = new Intl.NumberFormat(); + +let x39 = true; + +let x40 = new Intl.Collator(); + +let x41 = new Intl.RelativeTimeFormat(); + +let x42 = new Intl.PluralRules(); + +let x43 = new Intl.Locale("en"); + +let x45 = Promise.resolve(true); + +let x47 = {}; + +let x48 = Stdlib_Lazy.make(() => true); let x1 = "hello"; @@ -66,7 +91,12 @@ let x5 = { let x12 = "test"; -let x98 = /* [] */0; +let x44 = [ + 1, + 2 +]; + +let x46 = /* [] */0; export { x1, @@ -94,7 +124,20 @@ export { x31, x32, x33, - x98, - x99, + x34, + x35, + x36, + x37, + x38, + x39, + x40, + x41, + x42, + x43, + x44, + x45, + x46, + x47, + x48, } /* x20 Not a pure module */ diff --git a/tests/tests/src/option_wrapping_test.res b/tests/tests/src/option_wrapping_test.res index 22368764d5..57e03476f2 100644 --- a/tests/tests/src/option_wrapping_test.res +++ b/tests/tests/src/option_wrapping_test.res @@ -28,6 +28,19 @@ let x31 = Some(ArrayBuffer.make(0)->DataView.fromBuffer) let x32 = Some((Map.make(): Map.t)->Map.values) let x33 = Some(AsyncIterator.make(_ => AsyncIterator.value(true)->Promise.resolve)) -let x97 = Some(Promise.resolve(true)) -let x98 = Some(list{}) -let x99 = Some((Dict.make(): dict)) +let x34 = Some(Intl.ListFormat.make()) +let x35 = Some(Intl.Segmenter.make()) +let x36 = Some(Intl.Segmenter.make()->Intl.Segmenter.segment("")) +let x37 = Some(Intl.DateTimeFormat.make()) +let x38 = Some(Intl.NumberFormat.make()) +let x39 = Some(Intl.NumberFormat.Grouping.fromBool(true)) +let x40 = Some(Intl.Collator.make()) +let x41 = Some(Intl.RelativeTimeFormat.make()) +let x42 = Some(Intl.PluralRules.make()) +let x43 = Some(Intl.Locale.make("en")) + +let x44 = Some((1, 2)) +let x45 = Some(Promise.resolve(true)) +let x46 = Some(list{}) +let x47 = Some((Dict.make(): dict)) +let x48 = Some(Lazy.make(_ => true)) From 72eed8c08fc59844b8c6b4feeef891cde6d595df Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A9di-R=C3=A9mi=20Hashim?= Date: Tue, 13 May 2025 14:10:12 +0100 Subject: [PATCH 13/16] Typo --- runtime/Stdlib_Pair.res | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtime/Stdlib_Pair.res b/runtime/Stdlib_Pair.res index 767ad280ff..745bad6557 100644 --- a/runtime/Stdlib_Pair.res +++ b/runtime/Stdlib_Pair.res @@ -27,7 +27,7 @@ Pair.second((1, 2))->assertEqual(2) external second: (('a, 'b)) => 'b = "%field1" /** - `ignore(option)` ignores the provided pair and returns unit. + `ignore(pair)` ignores the provided pair and returns unit. This helper is useful when you want to discard a value (for example, the result of an operation with side effects) without having to store or process it further. From e3d85b5c48c59acc649f92673c3753f1b8335768 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A9di-R=C3=A9mi=20Hashim?= Date: Tue, 13 May 2025 14:10:29 +0100 Subject: [PATCH 14/16] Use throw instead of deprecated raise in internal unused test --- tests/tests/src/internal_unused_test.res | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/tests/src/internal_unused_test.res b/tests/tests/src/internal_unused_test.res index 437c3cf754..23a11190e0 100644 --- a/tests/tests/src/internal_unused_test.res +++ b/tests/tests/src/internal_unused_test.res @@ -17,7 +17,7 @@ module P1 = { } open! P1 -let f = () => raise(A) +let f = () => throw(A) %%private(let b = 3) From ceb29bbfc042cedbf510af173b6a284738cf4cba Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A9di-R=C3=A9mi=20Hashim?= Date: Tue, 13 May 2025 14:14:23 +0100 Subject: [PATCH 15/16] Restore trimmed whitespace --- runtime/Stdlib_AsyncIterator.resi | 4 ++-- runtime/Stdlib_JsError.resi | 14 +++++++------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/runtime/Stdlib_AsyncIterator.resi b/runtime/Stdlib_AsyncIterator.resi index 9a626cae1f..5d2e9b6dcf 100644 --- a/runtime/Stdlib_AsyncIterator.resi +++ b/runtime/Stdlib_AsyncIterator.resi @@ -70,7 +70,7 @@ let asyncIterator = AsyncIterator.make(async () => { let currentValue = context.contents // Increment current value context := currentValue + 1 - + if currentValue >= 3 { AsyncIterator.done() } else { @@ -94,7 +94,7 @@ let value: 'value => value<'value> let currentValue = context.contents // Increment current value context := currentValue + 1 - + if currentValue >= 3 { AsyncIterator.done() } else { diff --git a/runtime/Stdlib_JsError.resi b/runtime/Stdlib_JsError.resi index 8193306f1f..2304cf9569 100644 --- a/runtime/Stdlib_JsError.resi +++ b/runtime/Stdlib_JsError.resi @@ -30,7 +30,7 @@ See [`Error.prototype.message`](https://developer.mozilla.org/en-US/docs/Web/Jav ## Example ```rescript let error = JsError.SyntaxError.make("Some message here") -error->JsError.message->assertEqual("Some message here") +error->JsError.message->assertEqual("Some message here") ``` */ @get @@ -66,8 +66,8 @@ See [`Error`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/ ## Example ```rescript let error = JsError.make("Some message here") -error->JsError.message->assertEqual("Some message here") -error->JsError.name->assertEqual("Error") +error->JsError.message->assertEqual("Some message here") +error->JsError.name->assertEqual("Error") ```` */ @new @@ -102,7 +102,7 @@ module RangeError: { /** Creates a new `RangeError` with the provided `message` and throws it. - + `JsError.RangeError.throwWithMessage("message")` is equivalent to `JsError.RangeError.make("message")->JsError.throw`. See [`RangeError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/RangeError) on MDN. @@ -138,9 +138,9 @@ module SyntaxError: { /** Creates a new `SyntaxError` with the provided `message` and throws it. - + `JsError.SyntaxError.throwWithMessage("message")` is equivalent to `JsError.SyntaxError.make("message")->JsError.throw`. - + See [`SyntaxError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SyntaxError) on MDN. */ let throwWithMessage: string => 'a @@ -231,7 +231,7 @@ try { let panic: string => 'a /** -Casts a `JsError.t` to a `JsExn.t`. +Casts a `JsError.t` to a `JsExn.t`. This is useful when you want to compare a JS exception and a JS error. */ From 2bbdf90975d539336d1d8abdce73aa7be10f16f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A9di-R=C3=A9mi=20Hashim?= Date: Tue, 13 May 2025 14:25:02 +0100 Subject: [PATCH 16/16] Add CHANGELOG entry --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index fcdf8236a6..637f479aad 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -45,6 +45,7 @@ - In type errors, recommend stdlib over Belt functions for converting between float/int/string. https://github.com/rescript-lang/rescript/pull/7453 - Remove unused type `Jsx.ref`. https://github.com/rescript-lang/rescript/pull/7459 +- Add `@notUndefined` attribute to all relevant abstract types in `Stdlib`. https://github.com/rescript-lang/rescript/pull/7464 # 12.0.0-alpha.12