Commit 7cb4511
Phase G: real module resolution for
`import core;` actually loads now. The interpreter searches for the
named module on a configurable path, parses it, and executes its
statements (registering any fn definitions in the global function
table). Idempotent re-imports via a tracked HashSet.
## Resolution
Search path (in order):
- OMC_STDLIB_PATH env var (colon-separated)
- Canonical Python OMC stdlib at Sovereign_Lattice/omninet_package/
omnicode_stdlib/ and its std/ subdir
- Current dir, omc-stdlib/, omc-stdlib/std/ (project-local)
Per-dir naming variants: `NAME.omc`, `NAME/init.omc`, `std/NAME.omc`.
## Dispatch priority change
User-defined functions now win over built-ins. This lets `import core;`
override `is_fibonacci`, `fold`, etc. with the canonical Phase 6
implementations. Previously the built-ins shadowed user-defined
functions of the same name — matches Python OMC's behavior.
The `alias` in `import NAME as ALIAS;` is currently informational only;
imports merge into a flat function namespace.
## Verified working
import core;
is_fibonacci(89) -> 1 (user-defined HInt, not built-in Bool)
import wave;
harmonic_interfere(34,55) -> 42.02 (harmonic mean, from wave.omc)
import portal;
safe_divide_fold(89, 0) -> 89 (canonical singularity recovery)
## Notes
The Phase 6 std/* canonical modules (`core`, `wave`, `portal`, `ica`)
from the Python OMC tree are now loadable and callable from Rust OMC.
This unblocks a large fraction of canonical .omc programs that previously
failed at the import-statement level.
The 30-file canonical compat sweep stays at 21/30 — the file that
specifically tests imports (`test_modules.omc`) uses an aspirational
`wave(...)` constructor call that doesn't exist anywhere in wave.omc,
so it remains failing despite imports working perfectly otherwise.
## Tests
111 still passing. Nothing regressed.
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>import statements1 parent 5169069 commit 7cb4511
2 files changed
Lines changed: 140 additions & 37 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
7 | 24 | | |
8 | 25 | | |
9 | 26 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
| 5 | + | |
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| |||
11 | 11 | | |
12 | 12 | | |
13 | 13 | | |
| 14 | + | |
| 15 | + | |
14 | 16 | | |
15 | 17 | | |
16 | 18 | | |
| |||
22 | 24 | | |
23 | 25 | | |
24 | 26 | | |
| 27 | + | |
25 | 28 | | |
26 | 29 | | |
27 | 30 | | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
28 | 104 | | |
29 | 105 | | |
30 | 106 | | |
| |||
197 | 273 | | |
198 | 274 | | |
199 | 275 | | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
200 | 281 | | |
201 | 282 | | |
202 | 283 | | |
| |||
421 | 502 | | |
422 | 503 | | |
423 | 504 | | |
| 505 | + | |
| 506 | + | |
| 507 | + | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
424 | 511 | | |
425 | 512 | | |
426 | 513 | | |
| |||
1239 | 1326 | | |
1240 | 1327 | | |
1241 | 1328 | | |
1242 | | - | |
1243 | | - | |
1244 | | - | |
1245 | | - | |
1246 | | - | |
1247 | | - | |
1248 | | - | |
1249 | | - | |
1250 | | - | |
1251 | | - | |
1252 | | - | |
1253 | | - | |
1254 | | - | |
1255 | | - | |
1256 | | - | |
1257 | | - | |
1258 | | - | |
1259 | | - | |
1260 | | - | |
1261 | | - | |
1262 | | - | |
1263 | | - | |
| 1329 | + | |
| 1330 | + | |
| 1331 | + | |
| 1332 | + | |
1264 | 1333 | | |
1265 | | - | |
1266 | | - | |
1267 | | - | |
1268 | | - | |
1269 | | - | |
1270 | | - | |
1271 | | - | |
| 1334 | + | |
| 1335 | + | |
| 1336 | + | |
| 1337 | + | |
| 1338 | + | |
| 1339 | + | |
| 1340 | + | |
| 1341 | + | |
| 1342 | + | |
| 1343 | + | |
| 1344 | + | |
1272 | 1345 | | |
1273 | | - | |
| 1346 | + | |
| 1347 | + | |
| 1348 | + | |
| 1349 | + | |
| 1350 | + | |
| 1351 | + | |
| 1352 | + | |
| 1353 | + | |
1274 | 1354 | | |
1275 | | - | |
1276 | | - | |
| 1355 | + | |
| 1356 | + | |
| 1357 | + | |
| 1358 | + | |
1277 | 1359 | | |
1278 | | - | |
1279 | | - | |
1280 | | - | |
1281 | | - | |
| 1360 | + | |
| 1361 | + | |
| 1362 | + | |
| 1363 | + | |
1282 | 1364 | | |
1283 | 1365 | | |
| 1366 | + | |
| 1367 | + | |
| 1368 | + | |
| 1369 | + | |
1284 | 1370 | | |
1285 | 1371 | | |
1286 | 1372 | | |
| |||
0 commit comments