Skip to content
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

add list<string> -> string to last #11137

Merged
merged 3 commits into from
Dec 2, 2023
Merged

Conversation

amtoine
Copy link
Member

@amtoine amtoine commented Nov 22, 2023

this should

Description

this is band-aid...
but it should address the issue in #11134 until we have a better long-term fix for this i/o types bug 😇

User-Facing Changes

the following will now parse and run fine

def get-initial-commit []: nothing -> string {
    ^git rev-list HEAD | lines | last
}

Tests + Formatting

After Submitting

@amtoine amtoine requested a review from fdncred November 22, 2023 18:41
@amtoine amtoine self-assigned this Nov 22, 2023
@fdncred
Copy link
Collaborator

fdncred commented Nov 22, 2023

I think the test error in CI is the same problem but with the get command. I wish there was a good way to test all this input_output_type stuff.

@amtoine
Copy link
Member Author

amtoine commented Nov 22, 2023

ugh, what is that? 😢
i'm worried that changing the i/o types of get would ripple onto more commands without end 😅

@fdncred
Copy link
Collaborator

fdncred commented Nov 22, 2023

I think the problem is just that our input_output_types aren't defined properly, nor do they work properly on all commands.

Copy link
Collaborator

@WindSoilder WindSoilder left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've checked input/output type checking logic.

I think the checking logic is good. But we need to follow a rule:

If we have an input type that may generate multiple output type, last as example, we need to annotated it to <input_type> -> any, and we can't add other things about this input_type.

So you can have list<string> -> any for a command.
But you can't have both list<string> -> list<string>, list<string> -> int for a command.

crates/nu-command/src/filters/last.rs Outdated Show resolved Hide resolved
crates/nu-command/src/filters/last.rs Outdated Show resolved Hide resolved
@amtoine
Copy link
Member Author

amtoine commented Dec 1, 2023

So you can have list<string> -> any for a command. But you can't have both list<string> -> list<string>, list<string> -> int for a command.

yeah that's unfortunate but makes sense 👍
or we would need to add some kind of anyof thingy i describe in #10869 🤔
so that you could have

[
    list<string> -> anyof<list<string>, string>
    list<int> -> anyof<list<int>, int>
    ...
]

@WindSoilder WindSoilder merged commit 5c07e82 into nushell:main Dec 2, 2023
19 checks passed
@amtoine amtoine deleted the fix-11134 branch December 2, 2023 11:23
@amtoine
Copy link
Member Author

amtoine commented Dec 2, 2023

good catch @WindSoilder 👌

it's unfortunate but at least it works 😌

@sholderbach
Copy link
Member

Thanks for tweaking the commit title @WindSoilder !

@WindSoilder
Copy link
Collaborator

WindSoilder commented Dec 3, 2023

[
    list<string> -> anyof<list<string>, string>
    list<int> -> anyof<list<int>, int>
    ...
]

@amtoine Unfortunally, I don't think anyof in input_output_type is well fitted into our current design. It'll impact the parsing performance.

If we have the following commands' signature:

  1. command a: list -> anyof<list, string>
  2. command b: string -> anyof<int, list, string>
  3. cmmand c: string -> int

Then if we run ["1"] | a | b | c
We need to check for all possible anyof type.

hardfau1t pushed a commit to hardfau1t/nushell that referenced this pull request Dec 14, 2023
this should
- close nushell#11134

# Description
this is band-aid...
but it should address the issue in
nushell#11134 until we have a better
long-term fix for this i/o types bug 😇

# User-Facing Changes
the following will now parse and run fine
```nushell
def get-initial-commit []: nothing -> string {
    ^git rev-list HEAD | lines | last
}
```

# Tests + Formatting

# After Submitting
dmatos2012 pushed a commit to dmatos2012/nushell that referenced this pull request Feb 20, 2024
this should
- close nushell#11134

# Description
this is band-aid...
but it should address the issue in
nushell#11134 until we have a better
long-term fix for this i/o types bug 😇

# User-Facing Changes
the following will now parse and run fine
```nushell
def get-initial-commit []: nothing -> string {
    ^git rev-list HEAD | lines | last
}
```

# Tests + Formatting

# After Submitting
amtoine added a commit to amtoine/nu-git-manager that referenced this pull request Apr 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

external command output type is not string?
4 participants