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

Better error message for "undeclared identifier" #3911

Closed
dom96 opened this issue Feb 28, 2016 · 5 comments · Fixed by #16067
Closed

Better error message for "undeclared identifier" #3911

dom96 opened this issue Feb 28, 2016 · 5 comments · Fixed by #16067

Comments

@dom96
Copy link
Contributor

dom96 commented Feb 28, 2016

This error could be improved in many ways, one way that I think would help a lot is in the following case:

var FooBar = 5
echo(fooBar)

Instead of just

Error: undeclared identifier: 'foobar'

If an identifier with the same name but different case in the first letter exists, it would be nice to include . 'FooBar' is declared but remember that first letter is case sensitive.

@Araq
Copy link
Member

Araq commented Feb 29, 2016

What else do you want? A compiler making you breakfast. It's counterproductive to always blame the compiler for everything.

@Araq Araq closed this as completed Feb 29, 2016
@def-
Copy link
Member

def- commented Feb 29, 2016

Haskell's GHC has a nice way of handling this, searching for similar identifiers in general:

foobar = "abc"
foo_bar = "def"
bazbaz = "ghi"

main = putStrLn fooBar

Fails with:

[1 of 1] Compiling Main             ( x.hs, x.o )

x.hs:5:17:
    Not in scope: ‘fooBar’
    Perhaps you meant one of these:
      ‘foobar’ (line 1), ‘foo_bar’ (line 2)

@dom96
Copy link
Contributor Author

dom96 commented Feb 29, 2016

Don't be cheeky. This is a legitimate feature request and it will help a lot of newbies.

I want precisely what @def- showed.

@dom96 dom96 reopened this Feb 29, 2016
@dom96 dom96 added the Feature label Feb 29, 2016
@dom96
Copy link
Contributor Author

dom96 commented Feb 29, 2016

I created another general issue for this #3914.

@stale
Copy link

stale bot commented Aug 4, 2020

This issue has been automatically marked as stale because it has not had recent activity. If you think it is still a valid issue, write a comment below; otherwise it will be closed. Thank you for your contributions.

@stale stale bot added the stale Staled PR/issues; remove the label after fixing them label Aug 4, 2020
@ringabout ringabout removed the stale Staled PR/issues; remove the label after fixing them label Nov 20, 2020
Araq pushed a commit that referenced this issue Mar 16, 2021
…similar spellings on undefined symbol error (#16067)

* add --spellsuggest to suggest symbols in scope with similar spellings on undefined symbol errors
* implement --spellsuggest with 0 arguments
ringabout pushed a commit to ringabout/Nim that referenced this issue Mar 22, 2021
…s in scope with similar spellings on undefined symbol error (nim-lang#16067)

* add --spellsuggest to suggest symbols in scope with similar spellings on undefined symbol errors
* implement --spellsuggest with 0 arguments
ardek66 pushed a commit to ardek66/Nim that referenced this issue Mar 26, 2021
…s in scope with similar spellings on undefined symbol error (nim-lang#16067)

* add --spellsuggest to suggest symbols in scope with similar spellings on undefined symbol errors
* implement --spellsuggest with 0 arguments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants