Permalink
Browse files

(fix) Fixes fromJSON in the presence of getters

Previously .fromJSON used Object.assign, which would fail if
the type defined getter-only fields for some of the properties
being reified. This patch fixes that by replacing the entire
descriptor instead of assigning a value to it.
  • Loading branch information...
robotlolita committed Mar 18, 2017
1 parent eb7510a commit f4026e0e585e658877b45231653dfdff7d380f23
Showing with 2 additions and 1 deletion.
  1. +2 −1 src/core/adt/derivations/serialization.js
@@ -11,6 +11,7 @@
const { tagSymbol, typeSymbol } = require('../data');
const mapValues = require('folktale/core/object/map-values');
const values = require('folktale/core/object/values');
const extend = require('folktale/helpers/extend');
// --[ Constants ]------------------------------------------------------
@@ -155,7 +156,7 @@ const serialization = (variant, adt) => {
: /*otherwise*/ indexByType(values(parsers));
const parsedValue = mapValues(valueContents, parseValue(parsersByType));
return Object.assign(Object.create(adt[valueTagName].prototype), parsedValue);
return extend(Object.create(adt[valueTagName].prototype), parsedValue);
};
};

0 comments on commit f4026e0

Please sign in to comment.