Skip to content

Commit fbaff46

Browse files
authored
Merge pull request #2 from sarmadka/main
Fixed a bug in Promise.all.
2 parents 4b9a37f + 56276b6 commit fbaff46

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

Promises.alusus

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ module Promises {
129129
return SrdRef[AllPromise[InputType]]()~use_in(__this){
130130
construct();
131131
promise.wkThis = castSrdRef[__this, Promise[Array[InputType]]];
132+
def allResolved: Bool = true;
132133
def i: Int;
133134
for i = 0, i < inputs.getLength(), ++i {
134135
inputChainNodes.add(SrdRef[AllChainNode[InputType]]()~use_in(self){
@@ -139,8 +140,17 @@ module Promises {
139140
next~no_deref = inputs(i).child;
140141
inputs(i).child~no_deref = self.obj;
141142
});
142-
result.add(InputType());
143+
if inputChainNodes(i).depPromise.status == Status.RESOLVED {
144+
result.add(inputChainNodes(i).depPromise.result);
145+
} else {
146+
allResolved = false;
147+
result.add(InputType());
148+
if inputChainNodes(i).depPromise.status == Status.REJECTED and status == Status.NEW {
149+
reject(inputChainNodes(i).depPromise.error);
150+
}
151+
}
143152
}
153+
if allResolved resolve(result);
144154
};
145155
}
146156

0 commit comments

Comments
 (0)