Skip to content

Commit 7290a90

Browse files
committed
fix: symbols no longer passable
1 parent 6acbde7 commit 7290a90

File tree

3 files changed

+12
-30
lines changed

3 files changed

+12
-30
lines changed

packages/SwingSet/test/test-marshal.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -44,10 +44,10 @@ test('serialize static data', t => {
4444
body: '{"@qclass":"-Infinity"}',
4545
slots: [],
4646
});
47-
t.deepEqual(ser(Symbol.for('sym1')), {
48-
body: '{"@qclass":"symbol","key":"sym1"}',
49-
slots: [],
50-
});
47+
// t.deepEqual(ser(Symbol.for('sym1')), {
48+
// body: '{"@qclass":"symbol","key":"sym1"}',
49+
// slots: [],
50+
// });
5151
let bn;
5252
try {
5353
bn = BigInt(4);
@@ -91,7 +91,7 @@ test('unserialize static data', t => {
9191
t.ok(Object.is(uns('{"@qclass":"NaN"}'), NaN));
9292
t.deepEqual(uns('{"@qclass":"Infinity"}'), Infinity);
9393
t.deepEqual(uns('{"@qclass":"-Infinity"}'), -Infinity);
94-
t.deepEqual(uns('{"@qclass":"symbol", "key":"sym1"}'), Symbol.for('sym1'));
94+
// t.deepEqual(uns('{"@qclass":"symbol", "key":"sym1"}'), Symbol.for('sym1'));
9595

9696
// Normal json reviver cannot make properties with undefined values
9797
t.deepEqual(uns('[{"@qclass":"undefined"}]'), [undefined]);

packages/marshal/marshal.js

+2-20
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ export function sameValueZero(x, y) {
169169

170170
// How would val be passed? For primitive values, the answer is
171171
// * 'null' for null
172-
// * throwing an error for an unregistered symbol
172+
// * throwing an error for a symbol, whether registered or not.
173173
// * that value's typeof string for all other primitive values
174174
// For frozen objects, the possible answers
175175
// * 'copyRecord' for non-empty records with only data properties
@@ -225,10 +225,7 @@ export function passStyleOf(val) {
225225
return typestr;
226226
}
227227
case 'symbol': {
228-
if (Symbol.keyFor(val) === undefined) {
229-
throw new TypeError('Cannot pass unregistered symbols');
230-
}
231-
return typestr;
228+
throw new TypeError('Cannot pass symbols');
232229
}
233230
default: {
234231
throw new TypeError(`unrecognized typeof ${typestr}`);
@@ -364,13 +361,6 @@ export function makeMarshal(
364361
}
365362
return val;
366363
}
367-
case 'symbol': {
368-
const key = Symbol.keyFor(val);
369-
return harden({
370-
[QCLASS]: 'symbol',
371-
key,
372-
});
373-
}
374364
case 'bigint': {
375365
return harden({
376366
[QCLASS]: 'bigint',
@@ -498,14 +488,6 @@ export function makeMarshal(
498488
case '-Infinity': {
499489
return -Infinity;
500490
}
501-
case 'symbol': {
502-
if (typeof rawTree.key !== 'string') {
503-
throw new TypeError(
504-
`invalid symbol key typeof ${typeof rawTree.key}`,
505-
);
506-
}
507-
return Symbol.for(rawTree.key);
508-
}
509491
case 'bigint': {
510492
if (typeof rawTree.digits !== 'string') {
511493
throw new TypeError(

packages/marshal/test/test-marshal.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,10 @@ test('serialize static data', t => {
2929
body: '{"@qclass":"-Infinity"}',
3030
slots: [],
3131
});
32-
t.deepEqual(ser(Symbol.for('sym1')), {
33-
body: '{"@qclass":"symbol","key":"sym1"}',
34-
slots: [],
35-
});
32+
// t.deepEqual(ser(Symbol.for('sym1')), {
33+
// body: '{"@qclass":"symbol","key":"sym1"}',
34+
// slots: [],
35+
// });
3636
let bn;
3737
try {
3838
bn = BigInt(4);
@@ -80,7 +80,7 @@ test('unserialize static data', t => {
8080
t.ok(Object.is(uns('{"@qclass":"NaN"}'), NaN));
8181
t.deepEqual(uns('{"@qclass":"Infinity"}'), Infinity);
8282
t.deepEqual(uns('{"@qclass":"-Infinity"}'), -Infinity);
83-
t.deepEqual(uns('{"@qclass":"symbol", "key":"sym1"}'), Symbol.for('sym1'));
83+
// t.deepEqual(uns('{"@qclass":"symbol", "key":"sym1"}'), Symbol.for('sym1'));
8484

8585
// Normal json reviver cannot make properties with undefined values
8686
t.deepEqual(uns('[{"@qclass":"undefined"}]'), [undefined]);

0 commit comments

Comments
 (0)