Scoped `$nu.scope` and `which` do not work correctly
Open
Nobody has claimed this yet.
A:alias
category:bug
polish
- Dominant language
- Rust
- Stars
- 40.5k
- Forks
- 2.3k
- Avg merge
- 1d 19h
- Merged PRs (30d)
- 85
Description
Describe the bug
which and $nu.scope that fetch the engine state in a scope do not respect the scope fully.
How to reproduce
which:
> alias xaz = echo alias1
> def helper [] {
alias xaz = echo alias2
which -a xaz
}
> helper | get path.0
Nushell alias: echo alias1 # should say alias2
scope:
> alias xaz = echo alias1
> def helper [] {
alias xaz = echo alias2
$nu.scope.aliases
}
> helper | where alias == xaz | get expansion.0
echo alias1 # should say alias2
Expected behavior
See comments above: alias2
Screenshots
No response
Configuration
| key | value |
|---|---|
| version | 0.59.1 |
| branch | main |
| short_commit | 00530164 |
| commit_hash | 005301647ad7dd558ed85a34f528789d34412574 |
| commit_date | 2022-03-12 13:15:30 +00:00 |
| build_os | linux-x86_64 |
| rust_version | rustc 1.59.0 (9d1b2106e 2022-02-23) |
| rust_channel | stable-x86_64-unknown-linux-gnu |
| cargo_version | cargo 1.59.0 (49d8809dc 2022-02-10) |
| pkg_version | 0.59.1 |
| build_time | 2022-03-12 18:17:24 +02:00 |
| build_rust_channel | debug |
| features | default, trash, which, zip |
| installed_plugins | gstat, inc |
Additional context
Related: #4836
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing both examples in Nushell, comparing the alias returned by which -a xaz and $nu.scope.aliases inside helper with the expected alias2. Trace how scoped engine state is used by which and $nu.scope, then add regression coverage showing both commands respect the local alias.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- cli
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100