Repository navigation
Run commands only from compiled code (AST migration phase 4) - #19638
Merged
Merged
Conversation
Plain `cal` runs `table` through `eval_ir_call`, so nothing builds an `ast::Call` to run anymore. Remove `CallImpl::AstRef`/`AstBox`, `eval_call`, `eval_external`, `impl CallExt for ast::Call`, and the AST branches in `get`, `run`, `run-internal`, known externals and plugin calls. The AST evaluator's call arms now return an error. That fixes `explain` panicking on `else if` and running the command of an `alias`. `explain` also shows an argument that holds a subexpression as its source text and parsed type, without running it. A switch given a value that isn't a bool, such as `ls --all=$x` with `$x` typed `any`, is now an error in builtins, const calls and custom commands, as it already was for `%$cmd` and `run`.
fdncred
added a commit
that referenced
this pull request
Nov 23, 2026
#19645) ## Description `repl::test_engine::const_switch_rejects_a_value_that_is_not_a_bool` fails on main (1dc849d), and so does every PR's root test job. #19638 added the test. Two PRs merged a few minutes before it changed what the test expects, and each of the three passed CI on its own base: - #19634 turned on `cell-path-types`, so the parser now knows `$r.a` in `const r = {a: 5}` is an `int`. It rejects `--chars=$r.a` with a type mismatch and never evaluates the const. - #19635 moved errors from parse-time evaluation out of `ParseError::LabeledError` and into the new `ParseError::ParseTimeEval`. The test covers the check #19638 added to const evaluation, so it needs an argument the parser can't type. It now passes `($r | get a)`. `get` returns `any`, so the parser lets it through and the const evaluation rejects it. The test matches the `CantConvert` inside `ParseTimeEval`, the same way `builtin_switch_rejects_a_value_that_is_not_a_bool` matches its error. ## User-facing changes (Release notes) <!-- This section is used (mostly as-is) for https://www.nushell.sh/blog/ Describe how Nushell behavior changes from a user's perspective. Do NOT describe internal Rust changes here. Write in a release note style, for example: - "Added support for..." - "Fixed an issue where..." - "Nushell now supports..." - "Improved performance of..." If your changes do NOT affect users (internal refactors, cleanup, etc.), just write: - "n/a" - "nan" - or similar This tells us the change should not appear in the changelog. Tips: - Focus on observable behavior - Include examples if helpful - Keep it concise You can: - Write a short paragraph (will appear as a bullet point), OR - Use headings (###) if your change needs more structure Avoid writing things like: - "In this PR, I refactored..." - "This updates internal code..." You may leave this blank until the PR is ready. --> ## Additional notes <!-- Optional. Examples: - fixes #123 - closes #456 - related #789 Anything else reviewers should know. Remove this section if not needed. -->
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This is phase 4 of the AST to IR call migration, after #18808, #18813, #18967, #19351 and #19462. Commands now run only from compiled IR, so
engine::Callloses its AST variants and the code that handled them goes too.Plain
calwas the last runtime code that built anast::Call, to runtable --index false. It now runstablethrougheval_ir_call, ashelpdoes. The rest is deletion:CallImpl::AstRef/AstBox,eval_call,eval_external,impl CallExt for ast::Call, and the AST branches inget,run,run-internal, known externals and plugin calls.The AST evaluator stays, because
explainand the parser info ofsource,source-envandrunstill use it. Its call arms now return an error, which fixes twoexplainbugs.explainevaluates every argument, and a keyword's argument can be a call. Forelse ifthat call isif, whoserunpanics. Foralias x = cmdit rancmd. Both now show an error value. An argument that holds a subexpression, like(1 + 2), now shows its source text and parsed type instead of an internal debug dump.explaindoesn't run it, because that would run its commands.The AST
has_flagwas the only check that a builtin's switch got a bool. The parser rejectsls --all=5, butls --all=$xwith$xtypedanyand set to5counted as set. Builtins, const calls and custom commands now give the error%$cmdalready gave. A builtin checks when it reads the switch, so one that never reads it still ignores a bad value.User-facing changes (Release notes)
explainno longer crashes onelse if, and no longer runs the command analiaspoints to.explainshows an argument with a subexpression, like(1 + 2), as its source text and parsed type.ls --all=$xwith$xset to5, is an error. It used to count as set.Additional notes