nmodl icon indicating copy to clipboard operation
nmodl copied to clipboard

Issue warning for empty units during semantic analysis

Open pramodk opened this issue 7 years ago • 4 comments

Empty unit name declaration is valid according to the original implementation in NEURON:

i.e.

UNITS 
{
                   () = (millivolt)
}

is accepted now. Note the empty bracket on the left where there should be a name. Similarly, function declarations like the below are now also accepted:

FUNCTION ssCB(kdf(), kds()) (mM) 
{
}

Above behaviour was implemented in #3 in order to pass the fail existing ModelDB files.

When we will have semantic analysis pass for error checking, we can add a check to see if there is an empty unit definition like above and then error / throw exception. This way, parsing will be successful but the semantic analysis will be a "proper" place to do such checking.

pramodk avatar Feb 23 '19 11:02 pramodk

Can you give an example here of such files

alkino avatar Dec 15 '20 09:12 alkino

On top of that it would be useful to have a more detailed description about what empty units are what they are used for

iomaganaris avatar Dec 15 '20 09:12 iomaganaris

If by empty, you mean no units specified, then that is equivalent to dimensionless, i.e. units syntax of (1).

nrnhines avatar Dec 15 '20 11:12 nrnhines

About empty units in nrn. The truely empty units () is forbidden because:

Redefinition of units () to:	0.001 m2-kg/sec2-coul
 is ignored.
They remain:	1
Error: Units redefinition at line 3 in file a.mod
    () = (millivolt)
                   ^

The onespace unit ( ) is accepted once.

Inside function arguments both are accepted.

alkino avatar Feb 13 '23 11:02 alkino