For above code snippet, assemblyscript wraps a drop for the call add instruction. But there is no debuglocation for call instruction.
Steps to reproduce
The root cause is that, in the following code in assemblyscript. When asc wrap a drop epxr for the call epxr by execute convertExpression(), the expr variable(call expr) will be overwritten with (drop expr). And then addDebugLocation(drop). When returning to compileStatement after compileExpression, asc will addDebugLocation(drop) again. So we missed the debugLocation for call expr.
In src/compiler.ts line 3453-3468,
if (currentType != contextualType.nonNullableType) { // allow assigning non-nullable to nullable
if (constraints & Constraints.ConvExplicit) {
expr = this.convertExpression(expr, currentType, contextualType, true, expression);
this.currentType = currentType = contextualType;
} else if (constraints & Constraints.ConvImplicit) {
expr = this.convertExpression(expr, currentType, contextualType, false, expression);
this.currentType = currentType = contextualType;
}
}
if (wrap) expr = this.ensureSmallIntegerWrap(expr, currentType);
// debug location is added here so the caller doesn't have to. means: compilation of an expression
// must go through this function, with the respective per-kind functions not being used directly.
if (this.options.sourceMap) this.addDebugLocation(expr, expression.range);
Bug description
For above code snippet, assemblyscript wraps a
drop
for thecall add
instruction. But there is no debuglocation forcall
instruction.Steps to reproduce
The root cause is that, in the following code in assemblyscript. When asc wrap a drop epxr for the call epxr by execute convertExpression(), the expr variable(call expr) will be overwritten with (drop expr). And then addDebugLocation(drop). When returning to
compileStatement
aftercompileExpression
, asc will addDebugLocation(drop) again. So we missed the debugLocation for call expr.In
src/compiler.ts
line 3453-3468,AssemblyScript version
0.27.25