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

feature: For is not defined error message, prompt for similar names #3268

Open
A4-Tacks opened this issue Feb 18, 2025 · 1 comment
Open

Comments

@A4-Tacks
Copy link

Current outputs:

    $ jq -n 'to_string'
jq: error: to_string/0 is not defined at <top-level>, line 1:
to_string
jq: 1 compile error
    $ jq -n '1 as $X | $x'
jq: error: $x is not defined at <top-level>, line 1:
1 as $X | $x
jq: 1 compile error

Expect outputs like:

    $ jq -n 'to_string'
jq: error: to_string/0 is not defined at <top-level>, line 1:
to_string
jq: Did you mean: tostring/0?
jq: 1 compile error
    $ jq -n '1 as $X | $x'
jq: error: $x is not defined at <top-level>, line 1:
1 as $X | $x
jq: Did you mean: $X?
jq: 1 compile error

Similar python:

    $ python
Python 3.12.7 (main, Oct 11 2024, 10:50:28) [GCC 14.1.1 20240507] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> X=2
>>> x
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'x' is not defined. Did you mean: 'X'?
>>> priny
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
NameError: name 'priny' is not defined. Did you mean: 'print'?
@itchyny
Copy link
Contributor

itchyny commented Feb 21, 2025

Levenshtein distance? Yes, apparently that's how Python does. https://github.com/python/cpython/blob/v3.13.0/Python/suggestions.c#L164-L166

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

No branches or pull requests

2 participants