Skip to content

Commit 7eca026

Browse files
committed
Remove symbol bindings
1 parent 374a0d0 commit 7eca026

File tree

6 files changed

+8
-56
lines changed

6 files changed

+8
-56
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,12 @@
1212
1313
# 12.0.0-alpha.15 (Unreleased)
1414

15+
#### :boom: Breaking Change
16+
17+
- Remove `String.getSymbol` from standard library.
18+
- Remove `String.getSymbolUnsafe` from standard library.
19+
- Remove `String.setSymbol` from standard library.
20+
1521
#### :bug: Bug fix
1622

1723
- Ignore inferred arity in functions inside `%raw` functions, leaving to `%ffi` the responsibility to check the arity since it gives an error in case of mismatch. https://github.com/rescript-lang/rescript/pull/7542

runtime/Stdlib_String.res

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -164,10 +164,6 @@ external splitByRegExpAtMost: (string, Stdlib_RegExp.t, ~limit: int) => array<op
164164
@send external padStart: (string, int, string) => string = "padStart"
165165
@send external padEnd: (string, int, string) => string = "padEnd"
166166

167-
@get_index external getSymbol: (string, Stdlib_Symbol.t) => option<'a> = ""
168-
@get_index external getSymbolUnsafe: (string, Stdlib_Symbol.t) => 'a = ""
169-
@set_index external setSymbol: (string, Stdlib_Symbol.t, 'a) => unit = ""
170-
171167
@send external localeCompare: (string, string) => float = "localeCompare"
172168

173169
external ignore: string => unit = "%ignore"

runtime/Stdlib_String.resi

Lines changed: 0 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1112,50 +1112,6 @@ String.padEnd("abc", 1, "") == "abc"
11121112
@send
11131113
external padEnd: (string, int, string) => string = "padEnd"
11141114

1115-
/**
1116-
`getSymbol(str, symbol)` returns the value associated with the given symbol on the string as an `option<'a>`.
1117-
Returns `None` if the symbol property doesn't exist.
1118-
1119-
## Examples
1120-
1121-
```rescript
1122-
let h = String.make("hello")
1123-
let symbol = String.getSymbol(h, Symbol.iterator)
1124-
Option.isSome(symbol) == true
1125-
```
1126-
*/
1127-
@get_index external getSymbol: (string, Stdlib_Symbol.t) => option<'a> = ""
1128-
1129-
/**
1130-
`getSymbolUnsafe(str, symbol)` returns the value associated with the given symbol on the string.
1131-
1132-
This is _unsafe_, meaning it will return `undefined` if the symbol property doesn't exist.
1133-
1134-
## Examples
1135-
1136-
```rescript
1137-
let h = String.make("hello")
1138-
// This does required direct access to the symbol property
1139-
// Storing the iterator in a variable first, will not work.
1140-
String.getSymbolUnsafe(h, Symbol.iterator)()->Iterator.toArray->Array.length == 5
1141-
```
1142-
*/
1143-
@get_index external getSymbolUnsafe: (string, Stdlib_Symbol.t) => 'a = ""
1144-
1145-
/**
1146-
`setSymbol(str, symbol, value)` sets the given symbol property on the string to the specified value.
1147-
1148-
## Examples
1149-
1150-
```rescript
1151-
let mySymbol = Symbol.make("test")
1152-
let h = %raw(`new String("hello")`)
1153-
String.setSymbol(h, mySymbol, 42)
1154-
String.getSymbol(h, mySymbol) == Some(42)
1155-
```
1156-
*/
1157-
@set_index external setSymbol: (string, Stdlib_Symbol.t, 'a) => unit = ""
1158-
11591115
/**
11601116
`localeCompare(referenceStr, compareStr)` returns a float than indicatings
11611117
whether a reference string comes before or after, or is the same as the given

tests/tests/src/core/Core_TempTests.mjs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -249,10 +249,6 @@ let x = Symbol.for("Foo");
249249

250250
console.log(x);
251251

252-
let array$1 = "foo"[Symbol.iterator]().toArray();
253-
254-
console.log(array$1);
255-
256252
console.info("");
257253

258254
console.info("Global namespace");
@@ -338,6 +334,7 @@ export {
338334
_formatter,
339335
formatter,
340336
segments,
337+
array,
341338
date,
342339
dict,
343340
dict2,
@@ -354,7 +351,6 @@ export {
354351
set,
355352
regexp,
356353
x,
357-
array$1 as array,
358354
timeout,
359355
z,
360356
intFromBigInt,

tests/tests/src/core/Core_TempTests.res

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -160,8 +160,6 @@ Console.info("Symbol")
160160
Console.info("---")
161161
let x = Symbol.getFor("Foo")
162162
Console.log(x)
163-
let array: array<string> = String.getSymbolUnsafe("foo", Symbol.iterator)()->Iterator.toArray
164-
Console.log(array)
165163

166164
Console.info("")
167165
Console.info("Global namespace")

tests/tests/src/core/Test.mjs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ function print(value) {
1515
} else if (match === "string") {
1616
return Stdlib_Option.getExn(JSON.stringify(value), undefined);
1717
} else {
18-
return new String(value);
18+
return String(value);
1919
}
2020
}
2121

0 commit comments

Comments
 (0)