Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

reject octave script with use-before-declaration #236

Open
Remi-Gau opened this issue Oct 4, 2021 · 1 comment
Open

reject octave script with use-before-declaration #236

Remi-Gau opened this issue Oct 4, 2021 · 1 comment
Labels
component: parser Affects the parser requires: sem Change can only be implemented once semantic analysis works tool: mh_lint Affects the linter

Comments

@Remi-Gau
Copy link
Contributor

Remi-Gau commented Oct 4, 2021

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
@florianschanda
Copy link
Owner

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.

@florianschanda florianschanda added the invalid This doesn't seem right label Oct 4, 2021
@florianschanda florianschanda added component: sem Affects semantic analysis component: parser Affects the parser requires: sem Change can only be implemented once semantic analysis works tool: mh_lint Affects the linter and removed invalid This doesn't seem right component: sem Affects semantic analysis labels Oct 5, 2021
@florianschanda florianschanda reopened this Oct 5, 2021
@florianschanda florianschanda changed the title Octave does not allow subfunctions in scripts reject octave script with use-before-declaration Oct 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: parser Affects the parser requires: sem Change can only be implemented once semantic analysis works tool: mh_lint Affects the linter
Projects
None yet
Development

No branches or pull requests

2 participants