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

Enumeration with empty argument list results in parse error #286

Open
pvogt09 opened this issue Apr 11, 2024 · 3 comments
Open

Enumeration with empty argument list results in parse error #286

pvogt09 opened this issue Apr 11, 2024 · 3 comments

Comments

@pvogt09
Copy link

pvogt09 commented Apr 11, 2024

MISS_HIT Component affected

  • Style checker

Your MATLAB/Octave environment

  • MATLAB
  • R2023B

Your operating system and Python version

  • Linux
  • Python 3.8.10

Describe the bug
Applying the style checker to the file

classdef (Enumeration) Version < handle
    % VERSION class to represent a version of matlab

    enumeration
        % currently running version
        CURRENT()
        % R2023B
        R2023B('R2023B', 50, 23.2,  23.2)
        % R2023A
        R2023A('R2023A', 49, 9.14,  10.7)
    end

    properties (SetAccess = private)
        % name of matlab version
        name
        % number of matlab version
        number
        % version number of matlab version
        matlabversion
        % version number of simulink version
        simulinkversion
    end

    methods

        function [isgreateroreq] = ge(this, that)
            % GE return, if version is greater or equal than given version
            %   Input:
            %       this:           instance
            %       that:           version to compare to, if none is given, current version is used for comparison
            %   Output:
            %       isgreateroreq:  indicator, if version is greater than or equal the given version or current version, if no version to compare to is supplied
            if nargin <= 1
                that = matlab.Version.CURRENT();
            end
            isgreateroreq = ~this.less(that);
        end

    end

    methods (Access = private)

        function [this] = Version(name, number, matlabversion, simulinkversion)
            % VERSION create new version object
            %   Input:
            %       name:               name of matlab release
            %       number:             number of matlab release
            %       matlabversion:      version number of matlab release
            %       simulinkversion:    version number of simulink release
            if nargin == 0
                version = ver;
                names = {version.Name};
                matlab = strcmpi(names, 'MATLAB');
                simulink = strcmpi(names, 'SIMULINK');
                if ~any(matlab) || ~any(simulink)
                    error('matlab:version', 'Error in parsing version strings for current matlab version.');
                end
                this.name = upper(strrep(strrep(version(matlab).Release, '(', ''), ')', ''));
                this.number = 0;
                this.matlabversion = str2double(version(matlab).Version);
                this.simulinkversion = str2double(version(simulink).Version);
            else
                this.name = name;
                this.number = number;
                this.matlabversion = matlabversion;
                this.simulinkversion = simulinkversion;
            end
        end

    end
end

results in a parse error

In Version.m, line 6
|           CURRENT()
|                   ^ error: expected IDENTIFIER, found KET instead

that should not occur because it is valid to have the enumeration constructor called with an empty argument list.

@florianschanda
Copy link
Owner

Is this equivalent to just writing CURRENT?

@pvogt09
Copy link
Author

pvogt09 commented Jun 7, 2024

Yes, a workaround would be to simply not use parentheses.

@florianschanda
Copy link
Owner

OK, thanks. I don't have access to a working MATLAB version right now hence the need to ask, but fixing this shouldn't be hard.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants