Repository navigation
fix: closure's input type shouldn't be inherited from scope - #18540
Merged
Merged
Conversation
WindSoilder
reviewed
Jul 7, 2026
Contributor
There was a problem hiding this comment.
It breaks tests for the following code:
def only-nothing []: nothing -> string { "hello" }
def foo []: int -> any { let x = only-nothing; $x + 1 }But after investigating the new error message, I think the new one is better.
Old
def only-nothing []: nothing -> string { "hello" }
def foo []: int -> any { let x = only-nothing; $x + 1 }
Error: nu::parser::input_type_mismatch
× Command does not support int input.
╭─[repl_entry #1:2:34]
1 │ def only-nothing []: nothing -> string { "hello" }
2 │ def foo []: int -> any { let x = only-nothing; $x + 1 }
· ──────┬─────
· ╰── command doesn't support int input
╰────
New
def only-nothing []: nothing -> string { "hello" }
def foo []: int -> any { let x = only-nothing; $x + 1 }
Error: nu::parser::operator_incompatible_types
× Types 'string' and 'int' are not compatible for the '+' operator.
╭─[repl_entry #5:2:48]
1 │ def only-nothing []: nothing -> string { "hello" }
2 │ def foo []: int -> any { let x = only-nothing; $x + 1 }
· ─┬ ┬ ┬
· │ │ ╰── int
· │ ╰── does not operate between 'string' and 'int'
· ╰── string
╰────
Member
Author
|
@WindSoilder That's actually a regression the initial fix caused, it would have basically rolled back signature I/O based
|
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.
User-facing changes (Release notes)
Closure's input type is not inherited from the surrounding scope
With last release, pipeline input type and how it affects various expressions are being tracked in a lot more cases.
In fact, at least one too many:
This is now fixed, and closures' input type will be inferred as
any, the way it was before0.114.0.