From bd92778bf7b97b6a1ca463387c1dee062b4360a3 Mon Sep 17 00:00:00 2001 From: Joe Polny Date: Wed, 23 Oct 2024 08:33:32 -0400 Subject: [PATCH] fix: improve internal error message for pc mapping --- src/lib/compiler.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/lib/compiler.ts b/src/lib/compiler.ts index eea3c5389..3caa964ce 100644 --- a/src/lib/compiler.ts +++ b/src/lib/compiler.ts @@ -7613,6 +7613,16 @@ declare type AssetFreezeTxn = Required; this.sourceInfo.forEach((sm) => { if (this.hasDynamicTemplateVar) { if (sm.teal - 1 <= lastCblockLine) return; + const pcs = this.lineToPc[sm.teal - 1]; + + if (pcs === undefined) { + throw new Error( + `Internal Compiler Error: PC values not found when trying to calculate cblock offsets for TEAL line ${ + sm.teal + } (${this.teal[program][sm.teal - 1].teal}). Last cblock line was ${lastCblockLine}.` + ); + } + // eslint-disable-next-line no-param-reassign sm.pc = this.lineToPc[sm.teal - 1].map((pc) => pc - lastCblockPc); return;