Skip to content

Commit 42f559f

Browse files
Xinquan XUXMadrid
Xinquan XU
authored andcommitted
add debug location before conversion
1 parent 0d08611 commit 42f559f

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

src/compiler.ts

+10-4
Original file line numberDiff line numberDiff line change
@@ -3449,22 +3449,28 @@ export class Compiler extends DiagnosticEmitter {
34493449
expr = this.module.unreachable();
34503450
}
34513451
}
3452-
// debug location is added here so the caller doesn't have to. means: compilation of an expression
3453-
// must go through this function, with the respective per-kind functions not being used directly.
3454-
if (this.options.sourceMap) this.addDebugLocation(expr, expression.range);
34553452
// ensure conversion and wrapping in case the respective function doesn't on its own
34563453
let currentType = this.currentType;
34573454
let wrap = (constraints & Constraints.MustWrap) != 0;
34583455
if (currentType != contextualType.nonNullableType) { // allow assigning non-nullable to nullable
34593456
if (constraints & Constraints.ConvExplicit) {
3457+
// emit debug location for inner expression before conversion
3458+
if (this.options.sourceMap) this.addDebugLocation(expr, expression.range);
34603459
expr = this.convertExpression(expr, currentType, contextualType, true, expression);
34613460
this.currentType = currentType = contextualType;
34623461
} else if (constraints & Constraints.ConvImplicit) {
3462+
if (this.options.sourceMap) this.addDebugLocation(expr, expression.range);
34633463
expr = this.convertExpression(expr, currentType, contextualType, false, expression);
34643464
this.currentType = currentType = contextualType;
34653465
}
34663466
}
3467-
if (wrap) expr = this.ensureSmallIntegerWrap(expr, currentType);
3467+
if (wrap) {
3468+
if (this.options.sourceMap) this.addDebugLocation(expr, expression.range);
3469+
expr = this.ensureSmallIntegerWrap(expr, currentType);
3470+
}
3471+
// debug location is added here so the caller doesn't have to. means: compilation of an expression
3472+
// must go through this function, with the respective per-kind functions not being used directly.
3473+
if (this.options.sourceMap) this.addDebugLocation(expr, expression.range);
34683474
return expr;
34693475
}
34703476

0 commit comments

Comments
 (0)