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

Input/Output types of nu script execution help message output are always any #12893

Open
cavivie opened this issue May 17, 2024 · 2 comments · May be fixed by #12358
Open

Input/Output types of nu script execution help message output are always any #12893

cavivie opened this issue May 17, 2024 · 2 comments · May be fixed by #12358
Labels
🐛 bug Something isn't working parser Issues related to parsing

Comments

@cavivie
Copy link

cavivie commented May 17, 2024

Describe the bug

Here is an example script test.nu:

def main [] {

}

def "main init" [] {

}

def "main rand" [] : [nothing -> string] {
    random uuid
}

input/output types of nu script execution help message output are always any:

Input/output types:
  ╭───┬───────┬────────╮
  │ # │ input │ output │
  ├───┼───────┼────────┤
  │ 0 │ any   │ any    │
  ╰───┴───────┴────────╯

How to reproduce

Execute help for the script:

nu test.nu -h
nu test.nu init -h
nu test.nu rand -h

Expected behavior

When execute this:

nu test.nu rand -h

Should get like this:

Input/output types:
  ╭───┬─────────┬────────╮
  │ # │  input  │ output │
  ├───┼─────────┼────────┤
  │ 0 │ nothing │ string │
  ╰───┴─────────┴────────╯

Screenshots

No response

Configuration

key value
version 0.93.0
major 0
minor 93
patch 0
branch
commit_hash 3b220e0
build_os linux-x86_64
build_target x86_64-unknown-linux-gnu
rust_version rustc 1.77.2 (25ef9e3d8 2024-04-09)
rust_channel 1.77.2-x86_64-unknown-linux-gnu
cargo_version cargo 1.77.2 (e52e36006 2024-03-26)
build_time 2024-04-30 22:58:28 +00:00
build_rust_channel release
allocator mimalloc
features default, sqlite, static-link-openssl, system-clipboard, trash, which
installed_plugins

Additional context

No response

@cavivie cavivie added the needs-triage An issue that hasn't had any proper look label May 17, 2024
@sholderbach sholderbach added 🐛 bug Something isn't working parser Issues related to parsing and removed needs-triage An issue that hasn't had any proper look labels May 20, 2024
@sholderbach
Copy link
Member

This is due to a bug in the parser:

  • We only accept the : type annotation if directly placed next to the preceding token. (def foo [bar: int]: nothing -> string {} instead of def foo [bar : int] : nothing -> string {})
  • But instead of raising an error this silently ignores all the type information but still creates a defintion. (for which the default i/o type pair is any -> any)

@texastoland figured out this problem after I ran into the same and started to work on this in #12358 but this ran into some roadblocks.

@sholderbach sholderbach linked a pull request May 20, 2024 that will close this issue
@texastoland
Copy link
Contributor

texastoland commented May 21, 2024

Yep same issue! Got sidetracked by personal stuff but intend to wrap up my PR first week of June 🗓️

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 bug Something isn't working parser Issues related to parsing
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants