We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 2b92bf3 commit 4686da6Copy full SHA for 4686da6
src/compiler/jsgen.js
@@ -399,7 +399,11 @@ class JSGenerator {
399
const list = this.referenceVariable(node.list);
400
const idx = this.descendInput(node.item);
401
if (idx instanceof ConstantInput) {
402
- return new TypedInput(`${list}.value.indexOf(${idx.constantValue})+1`, TYPE_NUMBER);
+ let val = idx.constantValue;
403
+ if (idx.isAlwaysNumberOrNaN()) val = idx.asNumber();
404
+ else if (idx.isNeverNumber()) val = idx.asString();
405
+ else val = idx.asUnknown();
406
+ return new TypedInput(`${list}.value.indexOf(${val})+1`, TYPE_NUMBER);
407
}
408
return new TypedInput(`listIndexOf(${list},${idx})`, TYPE_NUMBER);
409
0 commit comments