lang: reject dir-vs-file ambiguous #import

An extensionless import path that names a directory next to a same-named
.sx file ('modules/std' with both modules/std.sx and modules/std/ present)
no longer silently resolves to the directory — it errors and asks for the
explicit .sx spelling. Exemption: a file importing its own companion
directory (X.sx importing X/, the multi-file test layout) stays legal —
the sibling file is the importer itself, so the directory is the only
sensible target.
This commit is contained in:
agra
2026-06-11 08:37:36 +03:00
parent 12bf61a9fc
commit 698f75d79a
7 changed files with 50 additions and 1 deletions

View File

@@ -2495,6 +2495,8 @@ pkg :: #import "modules/math"; // namespaced — all .sx files merged under pk
Directory imports scan only the top level of the specified directory (non-recursive). Files are processed in alphabetical order for deterministic builds. Files within the directory may `#import` each other or external files.
If an extensionless path matches both a file and a sibling directory of the same name (`modules/std.sx` next to `modules/std/`), the import is an error — write the `.sx` path to import the file. Exception: a file importing its own companion directory (`X.sx` importing `X/`) is not ambiguous; the directory is the only sensible target.
Namespaced declarations are accessed with dot notation:
```sx
std.print("hello");