Skip to content

ensure external signatures do not enforce type checking - #6567

Closed
merelymyself wants to merge 1 commit into
nushell:mainfrom
merelymyself:main
Closed

merelymyself wants to merge 1 commit into
nushell:mainfrom
merelymyself:main

Conversation

@merelymyself

@merelymyself merelymyself commented Sep 16, 2022 •

Copy link
Copy Markdown
Contributor

Description

Title. Fixes #4659. Fixes #6020. Kind of Fixes #5103. Fixes #5294. Fixes #6124. Try typing git fetch -a; I have no clue how to add tests for this.

This prevents all parse errors for export extern; in other words, now the exported extern is only used for completions.

Related to the discussion in #6020, I'm wondering if the hard check should be a configurable option, turned off by default. Thoughts?

Tests

Make sure you've done the following:

  • Add tests that cover your changes, either in the command examples, the crate/tests folder, or in the /tests folder.
  • Try to think about corner cases and various ways how your changes could break. Cover them with tests.
  • If adding tests is not possible, please document in the PR body a minimal example with steps on how to reproduce so one can verify your change works.

Make sure you've run and fixed any issues with these commands:

  • cargo fmt --all -- --check to check standard code formatting (cargo fmt --all applies these changes)
  • cargo clippy --workspace --features=extra -- -D warnings -D clippy::unwrap_used -A clippy::needless_collect to check that you're using the standard code style
  • cargo test --workspace --features=extra to check that all the tests pass

@merelymyself
merelymyself marked this pull request as draft September 16, 2022 11:23
@kubouch

kubouch commented Sep 16, 2022 •

Copy link
Copy Markdown
Contributor

I don't think completely bypassing parser errors like that is a good idea because it defeats the purpose of having custom signatures for externals and also ignores other errors unrelated to completions that might happen during the parsing.

I think a better solution would be to have "fall-through" signatures: Instead of defining the signature strictly, make it so that it would "assist" the signature. It would type-check the parameters you specify in the signature, but if you pass something else, it would be collected in a separate variable and wouldn't throw an error.

We can chat on Discord and try to come up with some design but this PR feels more like a hack, I'd rather not merge it. Thanks for the effort, though. The summary of the affected issues is also useful, it's something we should definitely address.

@merelymyself

Copy link
Copy Markdown
Contributor Author

@kubouch, I see your point. Do you think a configuration option where all three systems, the current one, this new one in the PR, and the "fall-through" are implemented? Btw, could you also explain what you mean by "fall-through signature"? I don't quite get it 😬

Thanks!

@merelymyself

Copy link
Copy Markdown
Contributor Author

@kubouch , any update on this?

@kubouch

kubouch commented Sep 20, 2022

Copy link
Copy Markdown
Contributor

Ah, sorry, check my latest message in the #completions channel on Discord, that explains it a bit. By "fall-through" signatures I mean you could type def foo [..-rest] { } and it would collect also the flags as strings to the rest variable. That's the general idea, I didn't think through all the details, we could come up with some better syntax.

@merelymyself

Copy link
Copy Markdown
Contributor Author

maybe I’ll give a shot at drop-through parameters, or maybe a config option that allows users the configure their preference, or maybe both

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

Labels

None yet

Projects

None yet

2 participants