Azure / bicep

Bicep is a declarative language for describing and deploying Azure resources
MIT License
3.16k stars 729 forks source link

Bicep should warn when parameter or variable overrides built-in function #3199

Open jikuja opened 3 years ago

jikuja commented 3 years ago

Bicep should warn if parameter or variable overrides built-in function: e.g. adding parameter named environment.

Getting error when trying to access the function is too late even modern tools offers good refactoring for parameter and variable naming.

anthony-c-martin commented 3 years ago

Great suggestion - I also usually try to avoid overlap with built-ins:

majastrz commented 3 years ago

For what it's worth, IntelliSense today only offers the fully qualified az.environment() function completion when there is an environment symbol declared.

This problem should only occur if the environment symbol is added after some calls to the environment() function have been made in the file, but it does present at the places where the function is called, so a linter would definitely help.

majastrz commented 2 years ago

I think we should add some logic to suggest some options for fully qualifying the function. Theoretically, the worst case is n namespaces containing a function with the same name, but the average case is 1. Producing a code fix per namespace would make it easier for the user to correct the issue as well.

Separately, I think we need to update the "Rename Symbol" logic to automatically fully qualify function calls that will break after the rename completes.