Skip to content

Space required before beginning a comment after a command used for completion on an extern #8731

Closed

Description

@lily-mara

Describe the bug

After upgrading to nu 0.77 (was previously using 0.76 with no issue), I found that my config.nu file was failing to parse with a "this command not found" error. Eventually I realized that one of my extern blocks provided a function to be used for completion on one of the arguments that had no space between the end of the command name and the beginning of an explanatory comment. This block was lifted straight from the docs, so either the functionality is broken or the docs need to be updated.

How to reproduce

Add the following to a file

def "funk" [] {
}

extern "x" [
    arg?: string@"funk" # has a space
]

extern "y" [
    arg?: string@"funk"# has no space
]

Execute the file

/Users/lily〉nu test.nu                                                                                                   
Error: nu::parser::unknown_command

  × Unknown command.
    ╭─[/Users/lily/test.nu:8:1]
  8 │ extern "y" [
  9 │     arg?: string@"funk"#
    ·                  ───┬───
    ·                     ╰── unknown command
 10 │ ]
    ╰────

Notice that the first extern block that has a space between the command name and the comment parses just fine, but the second errors.

Expected behavior

Treat the comment and the string before the comment as separate tokens

Screenshots

No response

Configuration

| key                | value                               |
| ------------------ | ----------------------------------- |
| version            | 0.77.1                              |
| branch             |                                     |
| commit_hash        |                                     |
| build_os           | macos-aarch64                       |
| build_target       | aarch64-apple-darwin                |
| rust_version       | rustc 1.67.1 (d5a82bbd2 2023-02-07) |
| rust_channel       | stable-aarch64-apple-darwin         |
| cargo_version      | cargo 1.67.1 (8ecd4f20a 2023-01-10) |
| build_time         | 2023-03-31 16:14:49 -07:00          |
| build_rust_channel | release                             |
| features           | default, zip                        |
| installed_plugins  |                                     |

Additional context

No response

Activity

  1. sholderbach commented on Apr 4, 2023

    @sholderbach
    Member

    We changed the comment lexing in #8151 demanding a space or new line to support bare word strings containing foo#bar as frequently found in nix related scripts.

    So this is indeed a breaking change and requires an update to our documentation. Thanks for pointing to the problematic examples!

  2. added a commit that references this issue on Apr 4, 2023
  3. lily-mara commented on Apr 4, 2023

    @lily-mara
    ContributorAuthor

    Thanks! I think I also was not able to find things related to "comment" in the changelog, so it took me a bit to track this down. Should it have been reported in the 0.77 release?

  4. sholderbach commented on Apr 4, 2023

    @sholderbach
    Member

    Ah right! That slipped through the cracks.

  5. added a commit that references this issue on Apr 4, 2023
  6. MangoIV commented on May 21, 2023

    @MangoIV
    Contributor

    Please excuse me @lily-mara @sholderbach, this was my fault.

  7. weirdan commented on Aug 16, 2024

    @weirdan
    Contributor

    I think this issue can be closed since it's by design and already documented.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions