[x] Add unit tests to roc_parse's ident.rs file to cover at least the simplest Ident enum cases (Tag, OpaqueRef, and simple Access)
[x] Add '_' as a valid "rest" character in lowercase and uppercase identifier parts
[x] Check for '_' in a uppercase ident and error out if found
[x] Update the test_syntax snapshots appropriately
[ ] Handle qualified access
[ ] Handle accessor functions
[ ] Handle record update functions
[-] Write unit tests for Malformed Idents
Here are some open questions answered on Zulip by @rtfeldman (emojis redacted).
Do we want to allow multiple '_'s to parse successfully?
definitely! This is a convention we actually want to make use of in the future
Do we want to be strict on disallowing uppers in snake_case idents?
I'd say we should treat this the same way as underscores in uppercase names, and for the same reason: if the formatter quietly fixes it, that could introduce bugs, so instead we should have the compiler complain.
that said, I think both of those scenarios should be a warning - that is, the compiler pushes a Problem but otherwise accepts the name as valid, so it doesn't block you from running your program over a stylistic problem
Do we wish to allow trailing '_' in lowercase idents?
long term, my default thinking is that we should do the same thing here as what we do for double underscore or underscores in capitalized names (that is, warn but don't block).
However, short term I think we should actually have the formatter change this one for you, because otherwise converting all the existing code from camelCase to snake_case will take forever.
I am not a "Rustacean" by any means, but have been through the Book in years past. Any feedback on the way I wrote the tests or any other part of the implementation would be very appreciated.
This PR will be only for the parsing portion of #7214, the formatter portion will be done in a separate PR
My Plan
Here are some
openquestions answered on Zulip by @rtfeldman (emojis redacted).Do we want to allow multiple '_'s to parse successfully?
Do we want to be strict on disallowing uppers in snake_case idents?
I am not a "Rustacean" by any means, but have been through the Book in years past. Any feedback on the way I wrote the tests or any other part of the implementation would be very appreciated.
This PR will be only for the parsing portion of #7214, the formatter portion will be done in a separate PR