Skip to content

Commit

Permalink
Merge pull request #568 from algorandfoundation/fix/error_location
Browse files Browse the repository at this point in the history
fix: locations in src map and error messages
  • Loading branch information
joe-p authored Oct 31, 2024
2 parents 9b1b5ec + 73f19b3 commit 63e9f22
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 27 deletions.
8 changes: 4 additions & 4 deletions src/lib/compiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2837,7 +2837,7 @@ export default class Compiler {

if (numberKeywords.length > 0) {
const node = numberKeywords[0];
const loc = ts.ts.getLineAndCharacterOfPosition(this.sourceFile.compilerNode, node.getStart());
const loc = ts.ts.getLineAndCharacterOfPosition(node.getSourceFile().compilerNode, node.getStart());
const errPath = path.relative(this.cwd, node.getSourceFile().getFilePath());

const msg = `number keyword not allowed at ${errPath}:${loc.line + 1}:${loc.character}. Use uint64 instead.`;
Expand All @@ -2853,7 +2853,7 @@ export default class Compiler {

this.sourceFile.getStatements().forEach((body) => {
const errNode = body;
const loc = ts.ts.getLineAndCharacterOfPosition(this.sourceFile.compilerNode, errNode.getStart());
const loc = ts.ts.getLineAndCharacterOfPosition(errNode.getSourceFile().compilerNode, errNode.getStart());
const lines: string[] = [];
const errPath = path.relative(this.cwd, errNode.getSourceFile().getFilePath());
errNode
Expand Down Expand Up @@ -2960,7 +2960,7 @@ export default class Compiler {
if (t.teal.length === 0 || t.teal.trim().startsWith('//') || t.teal.trim().split(' ')[0].endsWith(':')) return;

const relativePath = path.relative(this.cwd, t.node.getSourceFile().getFilePath());
const line = ts.ts.getLineAndCharacterOfPosition(this.sourceFile.compilerNode, t.node.getStart()).line + 1;
const line = ts.ts.getLineAndCharacterOfPosition(t.node.getSourceFile().compilerNode, t.node.getStart()).line + 1;
this.sourceInfo.push({
teal: i + 1,
source: `${relativePath}:${line}`,
Expand Down Expand Up @@ -3359,7 +3359,7 @@ export default class Compiler {
this.processErrorNodes.push(node);

const errNode = this.processErrorNodes[0];
const loc = ts.ts.getLineAndCharacterOfPosition(this.sourceFile.compilerNode, errNode.getStart());
const loc = ts.ts.getLineAndCharacterOfPosition(errNode.getSourceFile().compilerNode, errNode.getStart());
const lines: string[] = [];
const errPath = path.relative(this.cwd, errNode.getSourceFile().getFilePath());
errNode
Expand Down
30 changes: 15 additions & 15 deletions tests/contracts/artifacts/ARC56Test.arc56_draft.json
Original file line number Diff line number Diff line change
Expand Up @@ -307,14 +307,14 @@
},
{
"teal": 30,
"source": "tests/contracts/inheritance-external.algo.ts:12",
"source": "tests/contracts/inheritance-external.algo.ts:20",
"pc": [
37
]
},
{
"teal": 33,
"source": "tests/contracts/inheritance-external.algo.ts:14",
"source": "tests/contracts/inheritance-external.algo.ts:20",
"pc": [
38,
39,
Expand All @@ -323,43 +323,43 @@
},
{
"teal": 34,
"source": "tests/contracts/inheritance-external.algo.ts:14",
"source": "tests/contracts/inheritance-external.algo.ts:20",
"pc": [
41
]
},
{
"teal": 35,
"source": "tests/contracts/inheritance-external.algo.ts:14",
"source": "tests/contracts/inheritance-external.algo.ts:20",
"pc": [
42
]
},
{
"teal": 36,
"source": "tests/contracts/inheritance-external.algo.ts:14",
"source": "tests/contracts/inheritance-external.algo.ts:20",
"pc": [
43
]
},
{
"teal": 37,
"source": "tests/contracts/inheritance-external.algo.ts:14",
"source": "tests/contracts/inheritance-external.algo.ts:20",
"pc": [
44
]
},
{
"teal": 40,
"source": "tests/contracts/inheritance-external.algo.ts:14",
"source": "tests/contracts/inheritance-external.algo.ts:20",
"errorMessage": "argument 0 (input) for customStructMethod must be a (uint64)",
"pc": [
45
]
},
{
"teal": 43,
"source": "tests/contracts/inheritance-external.algo.ts:12",
"source": "tests/contracts/inheritance-external.algo.ts:20",
"pc": [
46,
47,
Expand All @@ -368,35 +368,35 @@
},
{
"teal": 44,
"source": "tests/contracts/inheritance-external.algo.ts:12",
"source": "tests/contracts/inheritance-external.algo.ts:20",
"pc": [
49
]
},
{
"teal": 45,
"source": "tests/contracts/inheritance-external.algo.ts:12",
"source": "tests/contracts/inheritance-external.algo.ts:20",
"pc": [
50
]
},
{
"teal": 46,
"source": "tests/contracts/inheritance-external.algo.ts:12",
"source": "tests/contracts/inheritance-external.algo.ts:20",
"pc": [
51
]
},
{
"teal": 47,
"source": "tests/contracts/inheritance-external.algo.ts:12",
"source": "tests/contracts/inheritance-external.algo.ts:20",
"pc": [
52
]
},
{
"teal": 51,
"source": "tests/contracts/inheritance-external.algo.ts:12",
"source": "tests/contracts/inheritance-external.algo.ts:20",
"pc": [
53,
54,
Expand All @@ -405,15 +405,15 @@
},
{
"teal": 55,
"source": "tests/contracts/inheritance-external.algo.ts:16",
"source": "tests/contracts/inheritance-external.algo.ts:21",
"pc": [
56,
57
]
},
{
"teal": 56,
"source": "tests/contracts/inheritance-external.algo.ts:12",
"source": "tests/contracts/inheritance-external.algo.ts:20",
"pc": [
58
]
Expand Down
12 changes: 6 additions & 6 deletions tests/contracts/artifacts/E.arc56_draft.json
Original file line number Diff line number Diff line change
Expand Up @@ -355,14 +355,14 @@
},
{
"teal": 54,
"source": "tests/contracts/inheritance-external.algo.ts:12",
"source": "tests/contracts/inheritance-external.algo.ts:11",
"pc": [
119
]
},
{
"teal": 55,
"source": "tests/contracts/inheritance-external.algo.ts:13",
"source": "tests/contracts/inheritance-external.algo.ts:11",
"pc": [
120,
121,
Expand All @@ -371,28 +371,28 @@
},
{
"teal": 56,
"source": "tests/contracts/inheritance-external.algo.ts:12",
"source": "tests/contracts/inheritance-external.algo.ts:11",
"pc": [
123
]
},
{
"teal": 60,
"source": "tests/contracts/inheritance-external.algo.ts:13",
"source": "tests/contracts/inheritance-external.algo.ts:12",
"pc": [
124
]
},
{
"teal": 61,
"source": "tests/contracts/inheritance-external.algo.ts:13",
"source": "tests/contracts/inheritance-external.algo.ts:12",
"pc": [
125
]
},
{
"teal": 62,
"source": "tests/contracts/inheritance-external.algo.ts:13",
"source": "tests/contracts/inheritance-external.algo.ts:12",
"pc": [
126
]
Expand Down
4 changes: 2 additions & 2 deletions tests/contracts/artifacts/FunctionsTest.arc56_draft.json
Original file line number Diff line number Diff line change
Expand Up @@ -724,7 +724,7 @@
},
{
"teal": 147,
"source": "node_modules/tealscript_test_package/index.ts:2",
"source": "node_modules/tealscript_test_package/index.ts:3",
"pc": [
177,
178,
Expand Down Expand Up @@ -756,7 +756,7 @@
},
{
"teal": 154,
"source": "node_modules/tealscript_test_package/index.ts:2",
"source": "node_modules/tealscript_test_package/index.ts:3",
"pc": [
185
]
Expand Down

0 comments on commit 63e9f22

Please sign in to comment.