From dea3fe226538f02d3336100902e4729a2be8408b Mon Sep 17 00:00:00 2001 From: Anton Trunov Date: Fri, 9 Feb 2024 19:06:05 +0400 Subject: [PATCH 1/3] fix: relative imports from parent directories --- .../__testdata/project/imported_from_subfolder.tact | 0 src/imports/__testdata/project/main.tact | 2 +- .../project/subfolder/import_from_parent.tact | 1 + src/imports/parseImportPath.ts | 7 ++++--- src/imports/resolveImports.spec.ts | 10 +++++++++- 5 files changed, 15 insertions(+), 5 deletions(-) create mode 100644 src/imports/__testdata/project/imported_from_subfolder.tact create mode 100644 src/imports/__testdata/project/subfolder/import_from_parent.tact diff --git a/src/imports/__testdata/project/imported_from_subfolder.tact b/src/imports/__testdata/project/imported_from_subfolder.tact new file mode 100644 index 000000000..e69de29bb diff --git a/src/imports/__testdata/project/main.tact b/src/imports/__testdata/project/main.tact index fca3c8eac..5adb1f4b1 100644 --- a/src/imports/__testdata/project/main.tact +++ b/src/imports/__testdata/project/main.tact @@ -1 +1 @@ -import "./imported"; \ No newline at end of file +import "./imported"; import "./subfolder/import_from_parent"; \ No newline at end of file diff --git a/src/imports/__testdata/project/subfolder/import_from_parent.tact b/src/imports/__testdata/project/subfolder/import_from_parent.tact new file mode 100644 index 000000000..bfa1a2968 --- /dev/null +++ b/src/imports/__testdata/project/subfolder/import_from_parent.tact @@ -0,0 +1 @@ +import "../imported_from_subfolder"; \ No newline at end of file diff --git a/src/imports/parseImportPath.ts b/src/imports/parseImportPath.ts index 8aba76953..5034949c9 100644 --- a/src/imports/parseImportPath.ts +++ b/src/imports/parseImportPath.ts @@ -1,11 +1,12 @@ +import path from "path"; import normalize from "path-normalize"; export function parseImportPath(src: string) { - if (!src.startsWith('./')) { + if (!(src.startsWith('./') || src.startsWith('../'))) { return null; } if (src.endsWith('/')) { return null; } - return normalize(src.slice(2)).split('/'); -} \ No newline at end of file + return normalize(src).split(path.sep); +} diff --git a/src/imports/resolveImports.spec.ts b/src/imports/resolveImports.spec.ts index 3a3ad5349..01e4fcb63 100644 --- a/src/imports/resolveImports.spec.ts +++ b/src/imports/resolveImports.spec.ts @@ -28,7 +28,15 @@ describe('resolveImports', () => { "path": path.resolve(__dirname, '__testdata', 'project', 'imported.tact'), }, { - "code": "import \"./imported\";", + "code": "import \"../imported_from_subfolder\";", + "path": path.resolve(__dirname, '__testdata', 'project', 'subfolder', 'import_from_parent.tact'), + }, + { + "code": "", + "path": path.resolve(__dirname, '__testdata', 'project', 'imported_from_subfolder.tact'), + }, + { + "code": "import \"./imported\"; import \"./subfolder/import_from_parent\";", "path": path.resolve(__dirname, '__testdata', 'project', 'main.tact'), }, ], From b47231b535e94d7a729bc425cb9fe27cb2ac83b1 Mon Sep 17 00:00:00 2001 From: Anton Trunov Date: Fri, 9 Feb 2024 19:21:26 +0400 Subject: [PATCH 2/3] fix parseImportPath for Windows --- src/imports/parseImportPath.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/imports/parseImportPath.ts b/src/imports/parseImportPath.ts index 5034949c9..83b78a1e4 100644 --- a/src/imports/parseImportPath.ts +++ b/src/imports/parseImportPath.ts @@ -8,5 +8,5 @@ export function parseImportPath(src: string) { if (src.endsWith('/')) { return null; } - return normalize(src).split(path.sep); + return normalize(src).split('/'); } From 646e7430bc95528c85789483828ed58df319daa9 Mon Sep 17 00:00:00 2001 From: Anton Trunov Date: Fri, 9 Feb 2024 19:36:31 +0400 Subject: [PATCH 3/3] update changelog --- CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7233ebbe1..10266a359 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,12 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Added +- Augmented assignment operators (`+=`, `-=`, `*=`, `/=` and `%=`): PR [#87](https://github.com/tact-lang/tact/pull/87) + +### Fixed +- Relative imports from parent directories: PR [#125](https://github.com/tact-lang/tact/pull/125) + ## [1.1.5] - 2023-12-01 ### Added