Commit 079d407
## Summary
Closes #415. Idaptik PR #107 hit this directly: `use prelude::{Option,
Some, None}` failed under `affinescript check` when invoked from a
directory that wasn't the affinescript repo root, because the loader's
default config only knew about `./stdlib` and the `AFFINESCRIPT_STDLIB`
env var. The workaround was a local `enum UndoResult { ... }`.
Replaces the hard-coded `./stdlib` default with `discover_stdlib`, which
tries in order:
| # | Path | Status |
|---|---|---|
| 1 | `$AFFINESCRIPT_STDLIB` | unchanged — explicit operator override |
| 2 | `./stdlib` | unchanged — in-repo dev |
| 3 | walk up from CWD looking for `stdlib/prelude.affine` | **NEW** —
catches sub-directory invocations |
| 4 | `<binary_dir>/../share/affinescript/stdlib/` | **NEW** — XDG-style
installed location |
| 5 | `$HOME/.local/share/affinescript/stdlib/` | **NEW** — user-local
install |
Falls back to `./stdlib` (preserves historical `ModuleNotFound` error)
if nothing matches.
## Verification (local)
| Scenario | Result |
|---|---|
| in-repo root | `./stdlib` resolves (unchanged) |
| in-repo sub-dir | walk-up finds it (NEW) |
| bare `/tmp/` dir, after `cp -r stdlib ~/.local/share/affinescript/` |
user-share finds it (NEW) |
## What this PR does NOT do
The literal `use stdlib::Option` parser syntax mentioned in #415's body
is a parse error in current grammar (multi-segment `stdlib::` prefix not
accepted). That's a grammar change deferred as follow-up. The practical
`Done when` criterion — `affinescript check` succeeds with `use
prelude::{Option, Some, None}` from any directory — is met by this PR.
## Roadmap updates
- stdlib roadmap #5 (cross-file `use` resolvability) `◑` → `●`
(follow-up doc PR to flip the row)
- #6 (Prelude Option reach) and #10 (exhaustive imported-enum match)
remain `◑` — they depend on the pattern-compiler change rather than the
loader fix.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 5cc87d2 commit 079d407
1 file changed
Lines changed: 60 additions & 5 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
48 | 48 | | |
49 | 49 | | |
50 | 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 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
51 | 110 | | |
52 | 111 | | |
53 | | - | |
54 | | - | |
55 | | - | |
56 | | - | |
57 | 112 | | |
58 | | - | |
| 113 | + | |
59 | 114 | | |
60 | 115 | | |
61 | 116 | | |
| |||
0 commit comments