Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: addDebugInfo before convertExpression #2835

Closed
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
add debug location before conversion
  • Loading branch information
Xinquan XU authored and XMadrid committed Apr 8, 2024
commit 42f559fa3257786feea91f8428ee71895163706e
14 changes: 10 additions & 4 deletions src/compiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3449,22 +3449,28 @@ export class Compiler extends DiagnosticEmitter {
expr = this.module.unreachable();
}
}
// 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);
// ensure conversion and wrapping in case the respective function doesn't on its own
let currentType = this.currentType;
let wrap = (constraints & Constraints.MustWrap) != 0;
if (currentType != contextualType.nonNullableType) { // allow assigning non-nullable to nullable
if (constraints & Constraints.ConvExplicit) {
// emit debug location for inner expression before conversion
if (this.options.sourceMap) this.addDebugLocation(expr, expression.range);
expr = this.convertExpression(expr, currentType, contextualType, true, expression);
this.currentType = currentType = contextualType;
} else if (constraints & Constraints.ConvImplicit) {
if (this.options.sourceMap) this.addDebugLocation(expr, expression.range);
expr = this.convertExpression(expr, currentType, contextualType, false, expression);
this.currentType = currentType = contextualType;
}
}
if (wrap) expr = this.ensureSmallIntegerWrap(expr, currentType);
if (wrap) {
if (this.options.sourceMap) this.addDebugLocation(expr, expression.range);
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);
return expr;
}

Expand Down
Loading