Skip to content

Commit aae95ea

Browse files
committed
Fix type of RegExp.Result.matches
1 parent e950b11 commit aae95ea

File tree

3 files changed

+4
-3
lines changed

3 files changed

+4
-3
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
- Fix node.js ExperimentalWarning. https://github.com/rescript-lang/rescript/pull/7379
1818
- Fix issue with gentype and stdlib json. https://github.com/rescript-lang/rescript/pull/7378
19+
- Fix type of `RegExp.Result.matches`. https://github.com/rescript-lang/rescript/pull/7393
1920

2021
#### :house: Internal
2122

runtime/Stdlib_RegExp.res

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ type t
33
module Result = {
44
type t = array<option<string>>
55
@get_index external fullMatch: (t, @as(0) _) => string = ""
6-
@send external matches: (t, @as(1) _) => array<string> = "slice"
6+
@send external matches: (t, @as(1) _) => array<option<string>> = "slice"
77
@get external index: t => int = "index"
88
@get external input: t => string = "input"
99
}

runtime/Stdlib_RegExp.resi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,15 @@ module Result: {
4343
// This below will log "ReScript" and "is" to the console.
4444
switch regexp->RegExp.exec("ReScript is pretty cool, right?") {
4545
| None => Console.log("Nope, no match...")
46-
| Some(result) => switch result->RegExp.Result.matches {
46+
| Some(result) => switch result->RegExp.Result.matches->Array.keepSome {
4747
| [firstWord, secondWord] => Console.log2(firstWord, secondWord)
4848
| _ => Console.log("Didn't find exactly two words...")
4949
}
5050
}
5151
```
5252
*/
5353
@send
54-
external matches: (t, @as(1) _) => array<string> = "slice"
54+
external matches: (t, @as(1) _) => array<option<string>> = "slice"
5555
@get external index: t => int = "index"
5656

5757
/**

0 commit comments

Comments
 (0)