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:
1 parent
9b496a7b03
commit
910bde692a
11 files changed
+139
-8
No files matched your search
@@ -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.
|
||||
|
||||
Reference in new issue
Block a user