Import files from folders above: import ..a.b, import ...a.b

Leading dots go up one folder less than their count (.. is one up, ...
is two). The language server index and formatter understand them, and a
missing file is reported with its real path.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
Your NameandClaude Sonnet 5.5 committed 2026-11-08 23:54:11 +01:00
1 parent 9b496a7b03
commit 910bde692a
11 files changed
+139 -8

No files matched your search

+5
View File
@@ -33,6 +33,11 @@ func main() {
```
- Folders work too: `import tools.fs` is the file `tools/fs.rex`, used as `fs.name`.
- Dots at the start go **up** a folder: `import ..shared.utils` is `../shared/utils.rex`, and
`import ...engine.engine` is `../../engine/engine.rex` (one dot fewer than the number of folders
up, so `..` is one folder up, `...` is two). It is still used as `utils.name` / `engine.name`.
Every import is counted from the folder of the file you run, also inside other files, so a
file in `engine/` that needs its neighbour `engine/util.rex` writes the same path as you would.
- Fields are private as well unless written `pub x: int`.
- Every file has its own names, so two files can both define `helper`.
- Import loops and missing files are errors. An error message names the file it is in.
+1
View File
@@ -115,6 +115,7 @@ var s: Shape = Circle{1.0}
```rex
import utils // utils.rex next to this file
import tools.fs // tools/fs.rex, used as fs.name
import ..shared // ../shared.rex (...x = two folders up)
import os // built-in: os math time
pub func f() {} // visible to other files
```