Closed PeterTillema closed 2 years ago
Without checking, I suspect your theory of end
messing up the parser is correct. I'll have a look as soon as I can.
OK, I can reproduce this with the datetime class from 2020b. I have reduced it down to this:
classdef Potato
methods
function n = end(this, k, n)
n = n + k;
end
end
methods
end
end
Looks like your theory is right. I thought I had that working and supported, but maaaaybe not. Thanks for the find!
So this is going to be hideous to fix, but I'll try. The problem is that end needs super special treatment, and the lexer tries to classify it as a KEYWORD or IDENTIFIER based on the limited awareness of context that it has. In this case it gets the second methods wrong and thinks it's an identifier; because I think it associates the end from the function to end the first methods; and the second end ending the class. That means now methods is a normal identifier again (it's only a keywords inside classes).
OK, so my description above is half right, half wrong. End is always classified as a keyword; but the rest is true: it ends the special blocks (e.g. methods) no matter where it appears.
I am testing a fix now.
So I managed to fix it with a one-liner. I am not happy with the general state of affairs, as MATLAB is quite frankly a silly language that cannot be lexer in a sane (dragon book style) way.
I will make a new release with just this bugfix; thank you very much for the report <3
Thank you very much for this quicj fox! I'm glad it wasn't too hard to fix, could have been worse.
And thanks for this tool in general! I discovered it only a few days ago, but so far it is amazing! It works like a charm, is super fast and overall clean. Comparing it to something like ANTLRv4, fabulous!
Thank you for the kind words. It makes me very happy to hear this :)
MISS_HIT Component affected Please choose one from:
Your MATLAB/Octave environment
Your operating system and Python version
python3 --version
Python3.9.XDescribe the bug A clear and concise description of what the bug is. Please include source code or clear steps that reproduces the problem. We cannot fix the problem if we can't replicate it. Please also indicate what you think the bug is unless its entirely obvious. If there is tool output (e.g. a backtrace or ICE) please include that here as well.
Open the
datetime
class in MATLAB (via Ctrl+D) and throw it at MS_LINT. You will get the following error:The problem is that a few lines above (1571),
end
is used as a function name, which probably messes up the parser. Changing that to another name fixes the problem.Do NOT include screenshots.