[Feature] Enable import of pure functions in circular dependency import
- 主要言語
- Rust
- スター
- 5.2k
- フォーク
- 145
- 平均マージ
- 5日 3時間
- マージ済み PR(30日)
- 7
説明
**Is your feature request related to a problem? Please describe.**
This problem enables the import of pure functions even if there is an import dependency cycle. This issue implements a logic that works under the hood and has no impact on syntax.
- If all imported functions are pure, then import is pure. This means that we can import pure functions from file that normally would create a dependency cycle.
- Pure import is separated from regular import in `import_cache`.
- Pure functions are placed before all the generated bash code.
- Pure functions are the ones that don't depend on external variables nor functions.
**Describe the solution you'd like**
- [ ] Write a way to detect if function is pure and persist that to the cache
- [ ] If function is defined, we have to compile it so that we know if it's pure. As for generic functions we can assume default type to be `Text`
- [ ] Create a way to mark file that was imported purely in the `import_cache`.
- [ ] Compile the pure functions first before resolving the usual import topology
**Describe alternatives you've considered**
N/A
**Additional context**
Let's say that we have file `main.ab`
```ab
import { bar } from "other.ab"
fun aux() {
echo bar()
}
fun foo() {
echo "foo"
}
```
and file `other.ab`.
```ab
import { foo } from "main.ab"
fun bar() {
echo foo() + "bar"
}
```
Even though there is an import cycle, the functions could be imported perfectly fine since `foo` is a pure function that does not rely on the context of the file it was created in.
コントリビューションガイド
このリポジトリのコントリビューションガイドは索引されていません
評価
この issue はまだ評価されていません。