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

Prevent name conflicts between internal and user-defined imports #284

Open
Martinsos opened this issue Jul 16, 2021 · 0 comments · May be fixed by #1865
Open

Prevent name conflicts between internal and user-defined imports #284

Martinsos opened this issue Jul 16, 2021 · 0 comments · May be fixed by #1865
Labels
bug Something isn't working haskell refactoring Keeping that code clean!

Comments

@Martinsos
Copy link
Member

Code is generated from templates, where we insert pieces of code that user defined.

Sometimes, that means we insert imports that import user functions from user (@ext) files.

Or, we address some identifier that user defined somewhere.

This can cause problems if for example they want to import function debug and we add that import into template that already imports our own debug -> we have a conflict!

While I expect Generator to go through significant changes in the future, where we should end up with a more sophisticated model of describing specific templates, I believe this problem will remain.

The only solution I see is prefixing (or suffixing) all user-made identifiers with something like wasp123, where the number would be unique per identifier (we can just assign those numbers incrementally).

Good example of problematic situation is when setup server function is inserted into server.js. What is that function was named config by user? It would conflict with the config import that we already have in that file.

Bad side of this is that names will be somewhat obfuscated, but on the other hand, if we just prefix or suffix them, that will be relatively straight forward to remove in case devs want to eject. When I say straight forward, I mean so for the devs themselves. If we want to remove prefix/suffix, it will be tricky since we need to detect conflicts and then ask dev to resolve them. So probably best to let them do it.

@Martinsos Martinsos added bug Something isn't working refactoring Keeping that code clean! haskell labels Jul 16, 2021
@sodic sodic changed the title In Generator, ensure user defined identifiers don't get into conflict with rest of the template as they are inserted Prevent name conflicts between internal and user-defined imports Dec 29, 2022
@infomiho infomiho linked a pull request Mar 7, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working haskell refactoring Keeping that code clean!
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant