Opened 6 years ago
Last modified 6 years ago
#5061 new defect
[NF] Are public parameters allowed in functions by the Modelica spec?
Reported by: | adrpo | Owned by: | perost |
---|---|---|---|
Priority: | high | Milestone: | 2.0.0 |
Component: | New Instantiation | Version: | |
Keywords: | Cc: |
Description
The NF is really strict on this:
https://libraries.openmodelica.org/branches/newInst/AdvancedNoise/files/AdvancedNoise_AdvancedNoise.Examples.RailIrregularities.Comparisons.FilterAndConvolution.err
[/var/lib/hudson/slave/workspace/OpenModelica_TEST_LIBS/OpenModelica/OMCompiler/build/lib/omlibrary/AdvancedNoise 1.0.0/Generators/QuickXorshift64star/package.mo:13:5-13:62:writable] Warning: Invalid public variable p, function variables that are not input/output must be protected.
The function looks like this:
redeclare function extends initialState "Returns an initial state for the xorshift64* algorithm" /* According to http://vigna.di.unimi.it/ftp/papers/xorshift.pdf, the xorshoft* random number generator generates statistically random numbers from a bad seed within one iteration. */ parameter Integer p = 1 "The number of iterations to use"; protected Real r "Random number not used outside the function"; algorithm // more here end function initialState;
I think we should just issue a warning and allow this.
Change History (4)
comment:1 Changed 6 years ago by casella
comment:2 Changed 6 years ago by adrpo
I will open a ticket there.
comment:3 Changed 6 years ago by adrpo
comment:4 Changed 6 years ago by adrpo
I allowed this just to see the impact on the coverage test:
https://github.com/OpenModelica/OMCompiler/pull/2600
I will disable it later.
The Modelica Specification, section 12.4.4, is very clear:
I'm not sure if that parameter is actually meant to belong to the protected components, or whether it is meant to belong to the input formal parameters. In either case, the code looks invalid to me.
Should we rather open a ticket here?