Skip to content

Commit b8e1134

Browse files
committed
Bugfixes
1 parent 74f0628 commit b8e1134

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

lib/quantum-circuit.js

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4339,10 +4339,18 @@ QuantumCircuit.prototype.convertToCustomGate = function(gateName, decompose, add
43394339
};
43404340

43414341
QuantumCircuit.prototype.validCustomGateName = function(baseName) {
4342+
baseName = (baseName || "sub") + "";
4343+
43424344
var customGateNames = [];
43434345
if(this.customGates) {
4344-
if(!this.customGates[baseName]) {
4345-
return baseName;
4346+
if(!this.basicGates[baseName]) {
4347+
if(!this.customGates[baseName]) {
4348+
return baseName;
4349+
}
4350+
}
4351+
4352+
for(var gateName in this.basicGates) {
4353+
customGateNames.push(gateName);
43464354
}
43474355

43484356
for(var gateName in this.customGates) {
@@ -4354,7 +4362,7 @@ QuantumCircuit.prototype.validCustomGateName = function(baseName) {
43544362
var validName = "";
43554363
do {
43564364
index++;
4357-
validName = (baseName || "sub") + index;
4365+
validName = baseName + index;
43584366
} while(customGateNames.indexOf(validName) >= 0);
43594367

43604368
return validName;

0 commit comments

Comments
 (0)