-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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
Wrong signature parsing in predecl scan #10605
Comments
It seems the parsing got broken somehow, I'll need to take a look. The ordering should be unchanged. What happens is that if there is an error during parsing in a predecl scan, the definition won't be predeclared, that's why it complains about executable not found because the command was not added. I'll need to look at it because the |
that's about what i understood yup, when you have time 😌 |
@kubouch with > tmux-sessionizer.nu list-sessions
Error: nu::parser::missing_positional
× Missing required positional argument.
╭─[/home/amtoine/.local/share/nupm/scripts/tmux-sessionizer.nu:20:1]
20 │
21 │ if $session.name not-in (list-sessions | get name) {
· ▲
· ╰── missing nothing
22 │ log debug $"creating session ($session.name) at ($session.path)"
╰────
help: Usage: list-sessions {flags} <nothing> <table> <nothing> <table> my |
and
on lines |
Could you create a minimal example that reproduces the error? The script is quite large and I also don't use tmux on this computer, I can't test it. |
yes of course, my bad 😌 i brought it down to the following script 😏 #!/usr/bin/env nu
def main [] {
foo
}
def foo []: [nothing -> table, nothing -> table] {
[]
} which gives me
|
looks like it's the multi signature which gives an unhelpful error 😮 #!/usr/bin/env nu
def main [] {
foo
}
def foo []: nothing -> table {
[]
} returns an empty list as expected 🤔 |
even if i change the signature to something with different types, still the same error #!/usr/bin/env nu
def main [] {
foo
}
def foo []: [nothing -> table, string -> list] {
[]
} |
and for each one of these examples, putting |
OK, thanks. The ordering matters in this case because before parsing The original error was present even before the def --env --wrapped PR btw. |
ooh i see 👍
strange because i use this script each time i open a terminal every day and never had this issue 🤔 |
# Description Fixes #10605 (again). The loop looking for `[` to determine signature position didn't stop early enough, so it thought the second `[` denoting the inp/out types marks the beginning of the signature. # User-Facing Changes # Tests + Formatting adds a new `predecl_signature_multiple_inp_out_types` test # After Submitting
# Description Fixes nushell#10605 (again). The loop looking for `[` to determine signature position didn't stop early enough, so it thought the second `[` denoting the inp/out types marks the beginning of the signature. # User-Facing Changes # Tests + Formatting adds a new `predecl_signature_multiple_inp_out_types` test # After Submitting
related to
cc/ @kubouch
Describe the bug
i have a script that broke when upgrading today.
i did bisect recent commits of Nushell and found the culprit 😏
it appears #10566 changed how order of definitions matter in a script 😮
when calling a command that is defined later in the script i get a confusing
missing_positional
error.the only fix i found so far was to move the command definition above the command call and then it starts working as before 👌
How to reproduce
foo.nu
nu foo.nu
foo
to[nothing -> nothing]
nu foo.nu
Expected behavior
i expected one of the two following behaviours
Screenshots
No response
Configuration
Additional context
No response
The text was updated successfully, but these errors were encountered: