フィルターのクリア

New behaviour for field assignment to existing non-struct variable in r2016a?

1 回表示 (過去 30 日間)
Ben
Ben 2016 年 6 月 15 日
回答済み: Ben 2016 年 6 月 15 日
Hello,
Given the input
tmp = 'test'
tmp.test = 'test'
In r2015b I get the warning:
Warning: Struct field assignment overwrites a value with class "char".
However in r2016a, I get the following error:
Field assignment to non-structure array object
Has the default behaviour changed? Has this been notified somewhere? It seems like this will break a lot of existing code which relies on the more permissive earlier behaviour.
  1 件のコメント
Adam
Adam 2016 年 6 月 15 日
I guess this is one of the many good reasons not to rely on code that is throwing warnings if there are easy ways to fix them.

サインインしてコメントする。

採用された回答

Steven Lord
Steven Lord 2016 年 6 月 15 日
See the "Functionality being removed or changed" item in the Language and Programming section of the Release Notes for release R2015b. The behavior change you mention is the second non-header row in the table.
MATLAB has been warning about this behavior since quick check MATLAB 7.0.4, release R14SP2 which was released in March 2005. In fact, see the next to last item in the Programming section of the Release Notes for that release. One part of that item says "In a future release of MATLAB, attempting this type of operation will throw an error instead of just displaying a warning message."
It may have taken us a decade, but that "future release" where the behavior will error has arrived.

その他の回答 (1 件)

Ben
Ben 2016 年 6 月 15 日
Thanks to Mr. Lord for the quick response, and hats off to the two court jesters for their constructive contributions. The code in question is EEGLAB, with whose developers I have lodged a bug report .

カテゴリ

Help Center および File ExchangeStructures についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by