feat(overlay): expose constants with overlay use (#15081)

# Description

`overlay use` now imports constants exported from modules, just like
`use`.

```nushell
# foo.nu
export const a = 1
export const b = 2
```

- `overlay use foo.nu` being equivalent to `use foo.nu *` and exposing
constants `$a = 1` and `$b = 2`
- `overlay use foo.nu -p` being equivalent to `use foo.nu` and exposing
the constant `$foo = {a: 1, b: 2}`

# User-Facing Changes

`overlay use` now imports constants just like `use`.

# Tests + Formatting

- 🟢 toolkit fmt
- 🟢 toolkit clippy
- 🟢 toolkit test
- 🟢 toolkit test stdlib

# After Submitting
N/A
This commit is contained in:
Bahex
2025-02-13 13:55:03 +03:00
committed by GitHub
parent 62e56d3581
commit 4ac4f71a37
3 changed files with 33 additions and 13 deletions

View File

@ -2977,8 +2977,7 @@ pub fn parse_overlay_new(working_set: &mut StateWorkingSet, call: Box<Call>) ->
working_set.add_overlay(
overlay_name.as_bytes().to_vec(),
module_id,
vec![],
vec![],
ResolvedImportPattern::new(vec![], vec![], vec![], vec![]),
false,
);
@ -3192,8 +3191,7 @@ pub fn parse_overlay_use(working_set: &mut StateWorkingSet, call: Box<Call>) ->
working_set.add_overlay(
final_overlay_name.as_bytes().to_vec(),
origin_module_id,
definitions.decls,
definitions.modules,
definitions,
has_prefix,
);
} else {