reserved-feature-name
Available in: KerML, SysML
This checks that features with special meaning from the standard library are not redefined with different names, and features using those names redefine compatible features.
Currently reserved names are:
self, which resolves to the current context.that, which resolves to the featuring, usually owning, type.this, which usually resolves to the current occurrence, sometimes parent occurrence.
Similar features are typically keywords in other languages, however they have the same semantic meaning in both KerML and SysML even if they are library features instead. To avoid confusion for all readers, such names should not be changed via redefinitions, not even moving the name to short name. Moreover, redefinitions of these features in user libraries have an unexpected side effect that the redefined features cannot change their meaning, ever.
In addition to simplifying checks to name comparisons only for far better performance, these reserved feature names will be used by Syside to provide better name resolution by resolving their meaning eagerly before any nested names. This means that user libraries will have no reason to redefine them explicitly other than for suppressing name distinguishability diagnostics due to multiple inheritance. Lastly, it will be much clearer what those features mean just by reading, before letting execution resolve them at runtime.
Subsumes reserved-name.
Example
attribute p {
<self>; // warning: Reserved name `self` should not be used as a short name
new_that :>> that; // warning: Feature with reserved name `that` should only be redefined by features with the same name
this; // warning: Feature with reserved name `this` does not redefine a corresponding feature
}
Preserve redefined names explicitly:
part p0 {
self :>> self; // ok
that :>> that; // ok
this :>> this; // ok
}
or implicitly:
part p1 {
:>> self; // ok
:>> that; // ok
:>> this; // ok
}
If you need to refer to self in child scope, use that:
attribute def UnsignedReal :> Real {
attribute : Real :>> self; // ok
assert constraint { that >= 0.0 }
}
Options
lint.reserved-feature-nameAllows controlling the diagnostic severity, e.g.
offto disable it.