Skip to content

Commit

Permalink
fix(imports): Import graph building error
Browse files Browse the repository at this point in the history
  • Loading branch information
jubnzv committed Oct 24, 2024
1 parent fd9cf42 commit 4ac3e79
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/internals/ir/builders/imports.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,10 +77,16 @@ export class ImportGraphBuilder {

imports.reduce((acc, importNode) => {
const importPath = importNode.path.value;
const resolvedPath = path.resolve(
let resolvedPath = path.resolve(
path.dirname(filePath),
this.resolveStdlibPath(importPath),
);
// TODO: We should use a Tact API function call when this is fixed:
// https://github.com/tact-lang/tact/issues/982
resolvedPath =
resolvedPath.endsWith(".tact") || resolvedPath.endsWith(".fc")
? resolvedPath
: resolvedPath + ".tact";
const targetNodeIdx = this.processFile(
resolvedPath,
nodes,
Expand Down Expand Up @@ -111,6 +117,8 @@ export class ImportGraphBuilder {
*
* Tact API doesn't provide functions to work with paths, so we replicate this:
* https://github.com/tact-lang/tact/blob/2315d035f5f9a22cad42657561c1a0eaef997b05/src/imports/resolveLibrary.ts#L26
*
* TODO: Should be replaced when https://github.com/tact-lang/tact/issues/982 is implemented.
*/
private resolveStdlibPath(importPath: string): string {
const stdlibPrefix = "@stdlib/";
Expand Down
1 change: 1 addition & 0 deletions test/all/imports-4/main.tact
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import "./constants.tact";
import "./messages.tact";
import "./test"; // Importing without extension
import "@stdlib/ownable";

fun test() {}
Expand Down
1 change: 1 addition & 0 deletions test/all/imports-4/test.tact
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
const A: Int = 42;

0 comments on commit 4ac3e79

Please sign in to comment.