fix: so track visited types

This commit is contained in:
cha0s 2020-06-25 09:58:22 -05:00
parent 40bc7ac1c6
commit 103e34df0e

View File

@ -103,6 +103,7 @@ export const defaultOps = (context, type, originalOps = []) => {
const ops = [...originalOps];
let evaluated;
let {type: opsType} = descriptionFromOps(context, ops);
const typesVisited = {[opsType]: true};
while (!fitsInto(opsType, type) || 0 === ops.length) {
evaluated = compile({type: 'expression', ops})(context);
if (
@ -121,9 +122,13 @@ export const defaultOps = (context, type, originalOps = []) => {
const candidates = typeCandidates(description, type);
const key = candidates.find((candidate) => {
const {type: candidateType} = children[candidate];
if (typesVisited[candidateType]) {
return false;
}
if (fitsInto(type, candidateType)) {
return true;
}
typesVisited[candidateType] = true;
return true;
});
ops.push({type: 'key', key});