-
Notifications
You must be signed in to change notification settings - Fork 79
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
Kebab-case definition produces collision when mapped to snake_case #118
Comments
Great point! So I suppose what we need to do here is tighten up the uniqueness condition to be case insensitive, so that you could have one or the other but not both. |
* Implement the component-model lexing rules for identifiers. The [component-model grammer] for kebab-case identifiers now looks like this: ``` name ::= <word> | <name>-<word> word ::= [a-z][0-9a-z]* | [A-Z][0-9A-Z]* ``` Implement the rules. This continues to use XID rules for the initial lexing, as that corresponds to what users might accidentally use, so that we can issue appropriate errors in those cases. The precise grammer is validated in a separate step. [component-model grammer]: https://github.com/WebAssembly/component-model/blob/main/design/mvp/Explainer.md#instance-definitions * Add more lexing tests. * Update the tests in tests/codegen/conventions.wit. * Comment out identifiers that collide when mapped to snake_case, for now. See WebAssembly/component-model#118.
Treating identifiers as case-insensitive is what we'd talked about in the past precisely to avoid this issue. I guess the main question is if we allow lower- and upper-case and treat identifiers as case-insensitive, or we enforce all-lower-case. The latter might be better, because it makes for cheaper and purely local validation, instead of multiple identifiers influencing each other. |
All-upper-case words are allowed in kebab-names to indicate that the word is an acronym, which the language casing scheme may treat differently than normal words. I think, in either case, the uniqueness condition is equally local, since you have to build a set of all names in the scope (imports or exports) to detect dupes. |
Ok, that's fair. We had in the past concluded that we'd not cover that case and require e.g. |
Implement case-insensitive comparisons for kebab-case names as described in the component-model thread: WebAssembly/component-model#118 This also adds previously missing validation for duplicate names in some contexts.
I opened bytecodealliance/wit-bindgen#385 with a prototype implementation of this. |
Implement case-insensitive comparisons for kebab-case names as described in the component-model thread: WebAssembly/component-model#118 This also adds previously missing validation for duplicate names in some contexts.
…alliance#382) * Implement the component-model lexing rules for identifiers. The [component-model grammer] for kebab-case identifiers now looks like this: ``` name ::= <word> | <name>-<word> word ::= [a-z][0-9a-z]* | [A-Z][0-9A-Z]* ``` Implement the rules. This continues to use XID rules for the initial lexing, as that corresponds to what users might accidentally use, so that we can issue appropriate errors in those cases. The precise grammer is validated in a separate step. [component-model grammer]: https://github.com/WebAssembly/component-model/blob/main/design/mvp/Explainer.md#instance-definitions * Add more lexing tests. * Update the tests in tests/codegen/conventions.wit. * Comment out identifiers that collide when mapped to snake_case, for now. See WebAssembly/component-model#118.
* Implement the component-model lexing rules for identifiers. The [component-model grammer] for kebab-case identifiers now looks like this: ``` name ::= <word> | <name>-<word> word ::= [a-z][0-9a-z]* | [A-Z][0-9A-Z]* ``` Implement the rules. This continues to use XID rules for the initial lexing, as that corresponds to what users might accidentally use, so that we can issue appropriate errors in those cases. The precise grammer is validated in a separate step. [component-model grammer]: https://github.com/WebAssembly/component-model/blob/main/design/mvp/Explainer.md#instance-definitions * Add more lexing tests. * Update the tests in tests/codegen/conventions.wit. * Comment out identifiers that collide when mapped to snake_case, for now. See WebAssembly/component-model#118.
The component-model grammar has this for
<name>
:That accepts both "apple" and "APPLE". This leads to collisions when converting to
snake_case
for languages which use that convention.The text was updated successfully, but these errors were encountered: