Skip to content

eval_ir_call takes the call builder, and dead AST code goes away - #19462

Merged
fdncred merged 5 commits into
nushell:mainfrom
fdncred:ast_reduce_steps_1_2
Nov 12, 2026
Merged

fdncred merged 5 commits into
nushell:mainfrom
fdncred:ast_reduce_steps_1_2

Conversation

@fdncred

@fdncred fdncred commented Nov 6, 2026 •

Copy link
Copy Markdown
Contributor

Description

More of the work to make IR the only thing that runs, plus bug fixes I found while doing it. The refactor changes one sentence of debug profile --help and nothing else users can see.

eval_ir_call now takes the CallBuilder by value and removes the call's arguments from the stack itself, on every return. Callers used to run finish(), run the call, then run leave(), and nothing made them do that last step. The twelve callers get shorter and three of the four manual leaves go. run-internal keeps one, because its help and error paths never run the call.

The rest deletes code that holds AST types and has no callers. The compiler confirmed each one.

Bug fixes

explore wrote command output over its own screen. :nu ^echo hi; 7 put hi on top of the status bar. Only the last pipeline gets a pipe redirection, so an external in an earlier one fell back to the stack's default output, which is the terminal.

:nu couldn't show an external's output. :nu ^echo hi showed Failed to read stream, and a debug build panicked at the debug_assert! in ChildProcess::into_bytes, because an external as the last pipeline keeps stderr on its own pipe. :nu now reads the process directly and previews stdout, then stderr, then exit code: N if it failed, so a failing command keeps its message.

An external that read the terminal froze explore. In :nu let x = 1; ^cat; 7, ^cat waited on the terminal behind the Running spinner, and input did the same. The pager's stack now also uses suppress_stdin, as completions do, so these finish or fail on their own. The first pipeline was never affected, because it reads the pager's value as its input.

:nu and :try hid why a command failed. A parse error showed only Parse error, and compile errors weren't checked, so they showed Can't evaluate block in IR mode. Both now show the reason.

debug profile left the profiler running when the closure failed, so everything after it ran through the debugger. try { debug profile { error make {msg: x} } } catch { } made a later for loop about 10 times slower. The profiler now stops before the error is returned.

debug profile --expand-source did nothing. The code looked up expanded-source, so has_flag never found the flag that was passed.

User-facing changes (Release notes)

  • debug profile --expand-source now shows the full source of each instruction. The flag had no effect before.
  • debug profile no longer leaves the profiler running when its closure fails.
  • In explore, :nu and :try no longer write over the screen when a command's output has nowhere to go, as in :nu ^echo hi; 7. That output is discarded.
  • In explore, :nu now shows an external's output, including its stderr and a non-zero exit code. :nu ^echo hi used to fail.
  • In explore, externals run by :nu and :try no longer get the terminal, so one that reads input can't freeze the pager. input now errors there, and a full-screen program like vim fails instead of drawing over the pager.
  • In explore, :nu and :try now say why a command couldn't be parsed or compiled.

Additional notes

Rust API breaks for embedders:

  • nu_engine::eval_ir_call takes a CallBuilder instead of &Call.
  • Debugger and DebugContext lose enter_element and leave_element.
  • ProfilerOptions loses collect_exprs.
  • Pattern::Expression, UnevaluatedCallInfo and CallBuilder::with are gone.
  • get_eval_expression_with_input, get_eval_subexpression, EvalExpressionWithInputFn and EvalSubexpressionFn are gone.

@github-actions github-actions Bot added A:parser Issues related to parsing A:plugins This issue is about plugins labels Nov 6, 2026
@fdncred fdncred added notes:mention Noted in "Hall of Fame" section notes:ready Indicates Ready for Release notes labels Nov 12, 2026
@fdncred
fdncred merged commit 1a92d1c into nushell:main Nov 12, 2026
11 checks passed
@fdncred
fdncred deleted the ast_reduce_steps_1_2 branch November 12, 2026 20:50
@github-actions github-actions Bot added this to the v0.118.0 milestone Nov 12, 2026
fdncred added a commit that referenced this pull request Nov 23, 2026
## 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::Call` loses its AST variants and the code that handled them
goes too.

Plain `cal` was the last runtime code that built an `ast::Call`, to run
`table --index false`. It now runs `table` through `eval_ir_call`, as
`help` does. The rest is deletion: `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 stays, because `explain` and the parser info of
`source`, `source-env` and `run` still use it. Its call arms now return
an error, which fixes two `explain` bugs. `explain` evaluates every
argument, and a keyword's argument can be a call. For `else if` that
call is `if`, whose `run` panics. For `alias x = cmd` it ran `cmd`. 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. `explain` doesn't run it, because that would run
its commands.

The AST `has_flag` was the only check that a builtin's switch got a
bool. The parser rejects `ls --all=5`, but `ls --all=$x` with `$x` typed
`any` and set to `5` counted as set. Builtins, const calls and custom
commands now give the error `%$cmd` already 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)

- `explain` no longer crashes on `else if`, and no longer runs the
command an `alias` points to.
- `explain` shows an argument with a subexpression, like `(1 + 2)`, as
its source text and parsed type.
- Breaking change: a switch given a value that isn't a bool, as in `ls
--all=$x` with `$x` set to `5`, is an error. It used to count as set.

## Additional notes
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 A:plugins This issue is about plugins notes:mention Noted in "Hall of Fame" section notes:ready Indicates Ready for Release notes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant