diff --git a/CHANGELOG.md b/CHANGELOG.md index 088f14f2c..7adda2edc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed +- The `parseImports` function now returns AST import nodes instead of raw strings: PR [#966](https://github.com/tact-lang/tact/pull/966) - Optional types for `self` argument in `extends mutates` functions are now allowed: PR [#854](https://github.com/tact-lang/tact/pull/854) ### Fixed diff --git a/src/grammar/grammar.ts b/src/grammar/grammar.ts index 840bc0eff..d33aa28ca 100644 --- a/src/grammar/grammar.ts +++ b/src/grammar/grammar.ts @@ -1509,7 +1509,7 @@ export function parseImports( src: string, path: string, origin: ItemOrigin, -): string[] { +): AstImport[] { return inFile(path, () => { const matchResult = tactGrammar.match(src, "JustImports"); if (matchResult.failed()) { @@ -1517,9 +1517,7 @@ export function parseImports( } ctx = { origin }; try { - const imports: AstImport[] = - semantics(matchResult).astOfJustImports(); - return imports.map((imp) => imp.path.value); + return semantics(matchResult).astOfJustImports(); } finally { ctx = null; } diff --git a/src/imports/resolveImports.ts b/src/imports/resolveImports.ts index 4393ac55d..0dd8915af 100644 --- a/src/imports/resolveImports.ts +++ b/src/imports/resolveImports.ts @@ -42,16 +42,17 @@ export function resolveImports(args: { function processImports(source: string, path: string, origin: ItemOrigin) { const imp = parseImports(source, path, origin); for (const i of imp) { + const importPath = i.path.value; // Resolve library const resolved = resolveLibrary({ path: path, - name: i, + name: importPath, project: args.project, stdlib: args.stdlib, }); if (!resolved.ok) { throwCompilationError( - `Could not resolve import "${i}" in ${path}`, + `Could not resolve import "${importPath}" in ${path}`, ); }