miss_hit
miss_hit copied to clipboard
reject octave script with use-before-declaration
What kind of feature is this?
Flag sub-functions in scripts
Your MATLAB/Octave environment
Octave 4.2.2 and 5.1.0
MISS_HIT component affected
linter ?
Describe the solution you'd like
A rare case again but as matlab (at least the 2017b I am using now) is fine with this, it might be good to keep track of it?
Note that matlab will complain if the filename of the script is the same as that of one of the sub functions in that script.
A script with the following content will annoy Octave.
a = 2;
fun(a);
function fun (a)
a = a + 2;
end
I think https://octave.org/doc/v6.3.0/Script-Files.html tells me that this would be OK in Octave if you write it like this:
a = 2;
function fun (a)
a = a + 2;
end
fun(a);
And in MATLAB what you wrote is the way to do it.
In MISS_HIT I cannot fix that until I have semantic analysis working (i.e. I know that fun is actually a function, or it's not yet delcared yet, etc.)
Semantic analysis and symbol resolution would actually enable a ton of other improvements, and it is I am working on, very very slowly. But do not expect anything on this front anytime soon.
I will close this ticket as invalid; mainly because syntactically the example you have makes sense; but semantically it doesn't. Once I have sem done, this will just work.