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

Edge case of where command #177

Open
blindFS opened this issue Dec 29, 2024 · 3 comments
Open

Edge case of where command #177

blindFS opened this issue Dec 29, 2024 · 3 comments

Comments

@blindFS
Copy link
Contributor

blindFS commented Dec 29, 2024

The following code is valid in nu but causes error in tree-sitter-nu

[{a: {b: true}}, {a: {d: false}}] | where a?.b?

However the following code is not allowed in nushell

[{a: {b: true}}, {a: {d: false}}] | where a?.b? and a?.b?
Error: nu::shell::type_mismatch

  × Type mismatch.
   ╭─[entry #38:1:46]
 1 │ [{a: {b: true}}, {a: {d: false}}] | where a?.b? and a?.b?
   ·                                              ┬
   ·                                              ╰── expected bool
   ╰────

So which of the following way is suggested for its fix in tree-sitter-nu:

  1. special treatment to make only the first case valid
  2. allow both
@fdncred
Copy link
Collaborator

fdncred commented Dec 29, 2024

Seems like both of those should be where condition == true vs just where condition but maybe it's a bug in nushell?

@blindFS
Copy link
Contributor Author

blindFS commented Dec 29, 2024

Seems like both of those should be where condition == true vs just where condition but maybe it's a bug in nushell?

I'm not sure, that usage is not present in the doc of where, but I've seen it somewhere in nu_scripts.

In my opinion, if we'd like to be able to save some effort when the column is itself a boolean, we should allow both cases.

Or simply don't allow any of those.

@fdncred
Copy link
Collaborator

fdncred commented Dec 29, 2024

I can understand that. I've asked the core-team what they think about it too.

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

No branches or pull requests

2 participants