Does MATLAB2019B automatically add semicolons in m files?

15 views (last 30 days)
I just updated to 2019B from 2015. I have noticed that when I open my m files, there are semicolons added where I certainly did not have them before. I've noticed it at the end of certain if statements and for statements. e.g. if aa is a vector, then
for a = aa
...
end
will be replaced with
for a = aa;
...
end
Does 2019B have the ability to edit your code without telling you? I'm not just talking auto-indenting as you type or anything like that. It actually seems to be editing the text of a file upon opening it such that the code is different than how you saved it. This is a bit disturbing...
It doesn't happen at all if/for statements. Weirdly, the Editor gives warnings about unnecessary semicolons in the cases where they have been added, so the auto-replacement doesn't seem to know what Editor knows.
  1 Comment
Rik
Rik on 17 Dec 2019
Are you sure it is the new Matlab release that is doing the editing? Were you able to find a work flow that reproduces this? It sounds like a serious bug to me if it is indeed Matlab that edits your code like this.

Sign in to comment.

Answers (4)

Giles
Giles on 17 Dec 2019
Reasonably sure... I've been working on this code base for a long time and have never seen anything like this until I started editing the files in 2019B. No other software touches these files (cept for macOS/iCloud for storage). Also the semicolons are added very specifically. e.g. something is parsing "a = aa" in my example above as being an assignment and thinking it's missing a semicolon. Whatever is doing it knows about MATLAB syntax, so I can't imagine this being anything other than MATLAB.
There are some options in Preferences -> Editor now called "Autocoding". They say they pertain to Live Editor/App Designer and none of them are semilcon (though they do list (), {}, [], ' ', " " autocompletion, etc.). Not sure what this means or if it relates to the mystery semicolons.

John D'Errico
John D'Errico on 18 Dec 2019
Edited: John D'Errico on 18 Dec 2019
R2019b here.
>> ver
-----------------------------------------------------------------------------------------------------
MATLAB Version: 9.7.0.1216025 (R2019b) Update 1
As a test, I created this m-file. See the lack of a semi-colon. I then saved it.
function test(A)
A = rand(3)
end
Close the file. Then edit it, opening the file. Here it is:
function test(A)
A = rand(3)
end
No semi-colon added. MATLAB changed nothing.

Giles
Giles on 20 Dec 2019
I don't know how to reproduce it but I do keep finding them in various files. Definitely something was up at least at some point.

Steven Lord
Steven Lord on 20 Dec 2019
I'm not aware of anything in MATLAB itself that I would expect to do this.
Do you have any add-ons installed? On the Home tab of the Toolstrip, click on the triangle below "Add-Ons" in the Environment section and select "Manage Add-Ons". What if anything does the Add-On Manager list other than MathWorks toolboxes?
Are you storing your files in a source control system? If so, which one?
How are you opening the files? Are you using the Open icon in the File section of the Home tab on the Toolstrip, are you using the edit function (and are you using the edit function included in MATLAB in that case), are you using some other function (one you've downloaded, were given, or wrote), etc.? If the latter, does that other function try to "beautify" your code (and eliminate Code Analyzer warnings) by adding the semicolons?

Categories

Find more on Graphics Performance in Help Center and File Exchange

Products


Release

R2019b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!