Skip to content

Commit fd0e456

Browse files
author
Jesse Chen
committed
fix: template functions miss debug info issue
1 parent 5e3be1e commit fd0e456

File tree

3 files changed

+8
-4
lines changed

3 files changed

+8
-4
lines changed

src/compiler.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9830,7 +9830,7 @@ export class Compiler extends DiagnosticEmitter {
98309830
let targetFunction = this.currentFlow.targetFunction;
98319831
let source = range.source;
98329832
if (source.debugInfoIndex < 0) source.debugInfoIndex = this.module.addDebugInfoFile(source.normalizedPath);
9833-
range.debugInfoRef = expr;
9833+
range.debugInfo.set(targetFunction.internalName, expr);
98349834
targetFunction.debugLocations.push(range);
98359835
}
98369836

src/diagnostics.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {
1111
DiagnosticCode,
1212
diagnosticCodeToString
1313
} from "./diagnosticMessages.generated";
14+
import { ExpressionRef } from "./module";
1415

1516
import {
1617
isLineBreak,
@@ -45,7 +46,7 @@ export const enum DiagnosticCategory {
4546
export class Range {
4647

4748
source!: Source;
48-
debugInfoRef: usize = 0;
49+
debugInfo: Map<string, ExpressionRef> = new Map<string, ExpressionRef>();
4950

5051
constructor(public start: i32, public end: i32) {}
5152

src/program.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,8 @@ import {
118118
Module,
119119
FunctionRef,
120120
MemorySegment,
121-
getFunctionName
121+
getFunctionName,
122+
ExpressionRef
122123
} from "./module";
123124

124125
import {
@@ -3916,9 +3917,11 @@ export class Function extends TypedElement {
39163917
for (let i = 0, k = debugLocations.length; i < k; ++i) {
39173918
let range = debugLocations[i];
39183919
let source = range.source;
3920+
const debugInfo = range.debugInfo.get(this.internalName);
3921+
assert(debugInfo);
39193922
module.setDebugLocation(
39203923
ref,
3921-
range.debugInfoRef,
3924+
debugInfo as ExpressionRef,
39223925
source.debugInfoIndex,
39233926
source.lineAt(range.start),
39243927
source.columnAt() - 1 // source maps are 0-based

0 commit comments

Comments
 (0)