-
Notifications
You must be signed in to change notification settings - Fork 118
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Prevent user from declaring variables and functions with same name
* Today use can "declarae" a variable in NEURON block and then PROCEDURE or FUNCTION with the same name. For example, below doesn't raise any error today: ```python NEURON { SUFFIX glia RANGE alfa } FUNCTION alfa(v(mV)) { alfa = exp(v) } ``` * The reason this works is that the `RANGE alfa` declaration in NEURON block id not complete (i.e. variable needs to be "defined" in block like ASSIGNED, PARAMETER etc) and hence doesn't appear anywhere in the generated code. If we try to use `alfa` as variable then that is warning and resulted into compilation error. * This behaviour kind of works but error prone. Apart from corner cases and confusing behaviour, it's difficult to do certain analysis that we would like to do (e.g. in new NMODL code generation). * So for the robustness and simplicity, we now throw an error if user try to declarte variable and function with the same name. ```console $ ./bin/nocmodl mod_x/test.mod Translating mod_x/test.mod into mod_x/test.cpp Error: alfa used as both variable and function in file mod/test.mod ```
- Loading branch information
Showing
4 changed files
with
53 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters