Skip to content

disallow keywords from being shadowed - #18662

Merged
fdncred merged 2 commits into
nushell:mainfrom
fdncred:fix_keyword_panic
Jul 20, 2026
Merged

fdncred merged 2 commits into
nushell:mainfrom
fdncred:fix_keyword_panic

Conversation

@fdncred

@fdncred fdncred commented Jul 18, 2026 •

Copy link
Copy Markdown
Contributor

Description

This PR disallows keywords from being shadowed such as def def [] {}. I'm calling this a breaking change because we had to change toolkit run to toolkit dev because run is now a keyword.

User-facing changes (Release notes)

Disallowed shadowing parser keywords

Trying to shadow a keyword will produce an error now.

❯ def def [] {}
Error: nu::parser::name_is_keyword

  × Can't use parser keyword `def` as command name.
   ╭─[repl_entry #1:1:5]
 1 │ def def [] {}
   ·     ─┬─
   ·      ╰── 'def' is a parser keyword
   ╰────
  help: Parser keywords cannot be shadowed (including via module exports and `use *`). Choose a different command name so language
        constructs keep working.

Additional notes

@fdncred fdncred added notes:breaking-changes Noted in Breaking Changes section notes:ready Indicates Ready for Release notes labels Jul 18, 2026
@github-actions github-actions Bot added the A:parser Issues related to parsing label Jul 18, 2026
@fdncred
fdncred merged commit f11c5f8 into nushell:main Jul 20, 2026
14 checks passed
@fdncred
fdncred deleted the fix_keyword_panic branch July 20, 2026 00:05
@github-actions github-actions Bot added this to the v0.115.0 milestone Jul 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A:parser Issues related to parsing notes:breaking-changes Noted in Breaking Changes section notes:ready Indicates Ready for Release notes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant