-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
normalize special characters in module names to allow variable access #14353
base: main
Are you sure you want to change the base?
Conversation
@sgvictorino is on fire 🔥!!! We appreciate all your PRs. Thanks. |
Thanks! But there is one thing I'm not sure: module foo-bar { export const baz = 1 }
use foo-bar
$foo-bar.baz Personally I think it's better to export use |
How will this play out with |
The filename stem must be a valid module name. Out of the invalid identifier characters, someone might try to name files like I'm also fine with normalizing certain symbols to a valid variable name like @WindSoilder prefers. The "did you mean" fuzzy search helps with that UX. |
I think normalizing would be the best option, since then it can align with typical variable name rules and can possibly catch more cases than just hyphens and the dot issue you bring up. |
Yeah, @sgvictorino can you update the code to use |
f89f386
to
99f4337
Compare
# User-Facing Changes - Special characters in module names are replaced with underscores when importing constants, preventing "expected valid variable name": ```nushell > module foo-bar { export const baz = 1 } > use foo-bar > $foo_bar.baz ``` - "expected valid variable name" errors now include a suggestion list: ```nushell > module foo-bar { export const baz = 1 } > use foo-bar > $foo-bar Error: nu::parser::parse_mismatch_with_did_you_mean × Parse mismatch during operation. ╭─[entry nushell#1:1:1] 1 │ $foo-bar; · ────┬─── · ╰── expected valid variable name. Did you mean '$foo_bar'? ╰──── ```
99f4337
to
c446b74
Compare
Fixes #14252
User-Facing Changes
importing constants, preventing "expected valid variable name":